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. 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.

  1. T* emplace(T* chunk)
  2. T* emplace(T* chunk, Args args)
    T*
    emplace
    (
    T
    Args...
    )
    (,
    auto ref Args args
    )
    if (
    is(T == struct) ||
    Args.length == 1
    )
  3. T emplace(T chunk, Args args)
  4. T emplace(void[] chunk, Args args)
  5. T* emplace(void[] chunk, Args args)

Return Value

Type: T*

A pointer to the newly constructed object (which is the same as chunk).

Examples

int a;
int b = 42;
assert(*emplace!int(&a, b) == 42);

Meta