newShared

Create a new shared pointer of type T*, using allocator Allocator. T will be creating by using constructor that accepts Args, or by implicitly stating *newMem = args[0]. The default allocator is Mallocator.

  1. auto newShared(Args args)
  2. auto newShared(Args args)
    @safe @nogc @trusted
    newShared
    (
    T
    Allocator = Mallocator
    Args...
    )
    (
    Args args
    )
    if (
    !is(T == class)
    )

Examples

auto sptr = newShared!int(42);
assert((*sptr.ptr) == 42);

Meta