std.conv.emplace
- multiple declarations
- Function emplace
- Function emplace
- Function emplace
- Function emplace
Function emplace
Given a raw memory area
, constructs an chunk
object
of non-class
type T
at that address. The constructor is passed the
arguments
, if any. The args
must be as least as large
as chunk
T
needs and should have an alignment multiple of T
's
alignment.
This function can be @trusted
if the corresponding constructor of
T
is @safe
.
Prototype
T* emplace(T, Args...)( void[] chunk, Args args ) if (!is(T == class));
Returns
Example
struct S { int a, b; } auto p = new void[S.sizeof]; S s; s.a = 42; s.b = 43; auto s1 = emplace!S(p, s); assert(s1.a == 42 && s1.b == 43);
Function emplace
Given a raw memory area
, constructs an chunk
object
of class
type T
at that address. The constructor is passed the arguments
Args
. The
must be as least as large as chunk
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)
).
This function can be @trusted
if the corresponding constructor of
T
is @safe
.
Prototype
T emplace(T, Args...)( void[] chunk, Args args ) if (is(T == class));
Returns
Function emplace
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
This function can be @trusted
if the corresponding constructor of
T
is @safe
.
Prototypes
T* emplace(T, Args...)( T* chunk, Args args ) if (!is(T == struct) && Args.length == 1); T* emplace(T, Args...)( T* chunk, Args args ) if (is(T == struct));
Returns
A pointer to
the newly constructed object
(which is the same
as
).
chunk
Function emplace
Given a pointer chunk
to
uninitialized memory (but already typed
as T
), constructs an object
of non-class
type T
at that
address.
Prototype
T* emplace(T)( T* chunk ) pure nothrow @safe;
Returns
A pointer to
the newly constructed object
(which is the same
as
).
chunk
Authors
Walter Bright, Andrei Alexandrescu, Shin Fujishiro, Adam D. Ruppe, Kenji Hara