BasicString.opIndex - multiple declarations
Function BasicString.opIndex
Return slice of all character.
The slice returned may be invalidated by further calls to other member functions that modify the object.
Examples
()@system{
BasicString!char str = "123";
char[] slice = str[];
assert(slice .length == str .length);
assert(slice .ptr is str .ptr);
str .reserve(str .capacity * 2);
assert(slice .length == str .length);
assert(slice .ptr !is str .ptr); // slice contains dangling pointer.
}();
()@safe{
FixedString!(char, 20) str = "123";
char[] slice = str[];
assert(slice .length == str .length);
assert(slice .ptr is str .ptr);
assert(slice == "123");
}();
Function BasicString.opIndex
Returns character at specified location pos
.
Examples
BasicString!char str = "abcd";
assert(str[1] == 'b');