emplace

fnT * emplace(T)(T * chunk) @safe pure nothrow

Given a pointer chunk to uninitialized memory (but already typed as T), constructs an object of non-class type T at that address. If T is a class, initializes the class reference to null.

Returns

A pointer to the newly constructed object (which is the same

as chunk).

fnT * emplace(T, Args...)(T * chunk, auto ref Args args) if (is(T == struct) || Args.length == 1)

Given a pointer chunk to uninitialized memory (but already typed as a non-class type T), constructs an object of type T at that address from arguments args. If T is a class, initializes the class reference to args[0]. This function can be @trusted if the corresponding constructor of T is @safe.

Returns

A pointer to the newly constructed object (which is the same

as chunk).

fnT emplace(T, Args...)(T chunk, auto ref Args args) if (is(T == class))

Given a raw memory area chunk (but already typed as a class type T), constructs an object of class type T at that address. The constructor is passed the arguments Args. If T is an inner class whose outer field can be used to access an instance of the enclosing class, then Args must not be empty, and the first member of it must be a valid initializer for that outer field. Correct initialization of this field is essential to access members of the outer class inside T methods.

Note

This function is @safe if the corresponding constructor of T is @safe.

Returns

The newly constructed object.
fnT emplace(T, Args...)(void[] chunk, auto ref Args args) if (is(T == class))

Given a raw memory area chunk, constructs an object of class type T at that address. The constructor is passed the arguments Args. If T is an inner class whose outer field can be used to access an instance of the enclosing class, then Args must not be empty, and the first member of it must be a valid initializer for that outer field. Correct initialization of this field is essential to access members of the outer class inside T methods. Preconditions: chunk must be at least as large as T needs and should have an alignment multiple of T's alignment. (The size of a class instance is obtained by using

__traits(classInstanceSize, T)).

Note

This function can be @trusted if the corresponding constructor of T is @safe.

Returns

The newly constructed object.
fnT * emplace(T, Args...)(void[] chunk, auto ref Args args) if (!is(T == class))

Given a raw memory area chunk, constructs an object of non-class type T at that address. The constructor is passed the arguments args, if any. Preconditions: chunk must be at least as large as T needs and should have an alignment multiple of T's alignment.

Note

This function can be @trusted if the corresponding constructor of

T is @safe.

Returns

A pointer to the newly constructed object.