Skip to content

Irrelevant debug block in ddoc'd example of assumeSafeAppend #10830

@quickfur

Description

@quickfur

Quote from https://dlang.org/library/object/assume_safe_append.html:

int[] a = [1, 2, 3, 4];

// Without assumeSafeAppend. Appending relocates.
int[] b = a [0 .. 3];
b ~= 5;
assert(a.ptr != b.ptr);

debug(SENTINEL) {} else
{
    // With assumeSafeAppend. Appending overwrites.
    int[] c = a [0 .. 3];
    c.assumeSafeAppend() ~= 5;
    writeln(a.ptr); // c.ptr
}

The bit about debug(SENTINEL) {} else is irrelevant and shouldn't be included in the ddoc.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions