String.opAssign - multiple declarations

Function String.opAssign

Assigns another string.

ref String opAssign(S) (
  S that
)
if (is(S == String));

ref String opAssign(S) (
  ref S that
) @trusted
if (is(Unqual!S == String));

If that is passed by value, it won't be copied, but moved. This string will take the ownership over that's storage and the allocator.

If that is passed by reference, it will be copied.

Parameters

NameDescription
S Content type.
that The value should be assigned.

Returns

this.

Example

auto s = String("Черная, потом пропахшая выть!");
s = String("Как мне тебя не ласкать, не любить?");

Function String.opAssign

Assigns a stringish range.

ref String opAssign(S) (
  S that
)
if (!isInfinite!S && isInputRange!S && isSomeChar!(ElementType!S));

Parameters

NameDescription
S String type.
that Initial string.

Returns

this.

Throws

UTFException.

Example

auto s = String("Оловом светится лужная голь...");
s = "Грустная песня, ты - русская боль.";
assert(s == "Грустная песня, ты - русская боль.");