BasicString.this - multiple declarations

Function BasicString.this

Constructs a empty BasicString object.

this (
  typeof(null) nil,
  Forward fw = Forward.init
) scope pure nothrow @nogc scope @safe;

Examples

{
	BasicString!char str = null;
	assert(str.empty);
}

Function BasicString.this

Constructs a empty BasicString object with allocator.

this (
  BasicString.AllocatorType allocator
) scope scope;

Parameters

allocator allocator parameter.

Examples

{
	BasicString!(char, DefaultAllocator) str = DefaultAllocator.init;
	assert(str.empty);
}

Function BasicString.this

Constructs a BasicString object, initializing its value to char value character.

this(C) (
  const C character,
  Forward fw = Forward.init
) scope scope
if (isSomeChar!C);

Parameters

character can by type char|wchar|dchar.

Examples

{
	BasicString!char str = 'x';
	assert(str == "x");
}

{
	BasicString!char str = '読';
	assert(str == "読");
}

Function BasicString.this

Constructs a BasicString object, initializing its value to char value character.

this(C) (
  const C character,
  BasicString.AllocatorType allocator
) scope scope
if (isSomeChar!C);

Parameters

character can by type char|wchar|dchar.

allocator allocator parameter.

Examples

{
	auto str = BasicString!(char, DefaultAllocator)('読', DefaultAllocator.init);
	assert(str == "読");
}

Function BasicString.this

Constructs a BasicString object from char slice slice.

this(This) (
  scope const BasicString.CharType[] slice,
  Forward fw = Forward.init
) scope scope;

this(This, C) (
  scope const C[] slice,
  Forward fw = Forward.init
) scope scope
if (isSomeChar!C && !is(immutable(C) == immutable(CharType)));

Parameters

slice is slice of characters (const char[], const wchar[], const dchar[]).

Examples

{
	BasicString!char str = "test";
	assert(str == "test");
}

{
	BasicString!char str = "test 読"d;
	assert(str == "test 読");
}

{
	wchar[3] data = [cast(wchar)'1', '2', '3'];
	BasicString!char str = data[];
	assert(str == "123");
}

Function BasicString.this

Constructs a BasicString object from char slice slice.

this(This) (
  scope const BasicString.CharType[] slice,
  BasicString.AllocatorType allocator
) scope scope;

this(This, C) (
  scope const C[] slice,
  BasicString.AllocatorType allocator
) scope scope
if (isSomeChar!C && !is(immutable(C) == immutable(CharType)));

Parameters

slice is slice of characters (const char[], const wchar[], const dchar[]).

allocator allocator parameter.

Examples

{
	auto str = BasicString!(char, DefaultAllocator)("test", DefaultAllocator.init);
	assert(str == "test");
}

{
	auto str = BasicString!(char, DefaultAllocator)("test 読"d, DefaultAllocator.init);
	assert(str == "test 読");
}

{

	wchar[3] data = [cast(wchar)'1', '2', '3'];
	auto str = BasicString!(char, DefaultAllocator)(data[], DefaultAllocator.init);
	assert(str == "123");
}

Function BasicString.this

Constructs a BasicString object, initializing its value from integer integer.

this(I) (
  I integer,
  Forward fw = Forward.init
) scope scope
if (isIntegral!I);

Parameters

integer integers value.

Examples

{
	BasicString!char str = 123uL;
	assert(str == "123");
}

{
	BasicString!dchar str = -123;
	assert(str == "-123");
}

Function BasicString.this

Constructs a BasicString object, initializing its value from integer integer.

this(I) (
  I integer,
  BasicString.AllocatorType allocator
) scope scope
if (isIntegral!I);

Parameters

integer integers value.

allocator allocator parameter.

Examples

{
	auto str = BasicString!(char, DefaultAllocator)(123uL, DefaultAllocator.init);
	assert(str == "123");
}

{
	auto str = BasicString!(dchar, DefaultAllocator)(-123, DefaultAllocator.init);
	assert(str == "-123");
}

Function BasicString.this

Constructs a BasicString object from other BasicString object.

this(This, Rhs) (
  auto scope ref Rhs rhs
) scope scope
if (isBasicString!Rhs && isConstructable!(Rhs, This) && (isRef!rhs || !is(immutable(This) == immutable(Rhs))));

this(This, Rhs) (
  auto scope const ref Rhs rhs,
  BasicString.AllocatorType allocator
) scope scope
if (isBasicString!Rhs);

Parameters

rhs BasicString rvalue/lvalue

allocator optional allocator parameter.

Examples

{
	BasicString!char a = "123";
	BasicString!char b = a;
	assert(b == "123");
}

{
	BasicString!dchar a = "123";
	BasicString!char b = a;
	assert(b == "123");
}

{
	BasicString!dchar a = "123";
	auto b = BasicString!char(a, DefaultAllocator.init);
	assert(b == "123");
}

import core.lifetime : move;
{
	BasicString!char a = "123";
	BasicString!char b = move(a);
	assert(b == "123");
}

Function BasicString.this

Forward constructor.

this(This, Rhs) (
  auto scope ref Rhs rhs,
  Forward
) scope scope
if (isBasicString!Rhs && isConstructable!(Rhs, This));

Function BasicString.this

Copy constructor if AllocatorType is statless.

this (
  scope const ref typeof(this) rhs
) scope scope;

Parameter rhs is const.

Function BasicString.this

Copy constructor if AllocatorType has state.

this (
  scope ref typeof(this) rhs
) scope scope;

Parameter rhs is mutable.