SharedPtr.make

Constructs a SharedPtr with element as the pointer to the managed object.

Uses the specified deleter as the deleter. The expression deleter(element) must be well formed, have well-defined behavior and not throw any exceptions. The construction of deleter and of the stored deleter from d must not throw exceptions.

  1. auto make(Args args)
  2. auto make(ElementReferenceType element, DeleterType deleter)
    struct SharedPtr
    static
    make
    (
    AllocatorType = DefaultAllocator
    bool supportGC = platformSupportGC
    DeleterType
    )
    if (
    isCallable!DeleterType
    )
  3. auto make(size_t n, Args args)

Examples

long deleted = -1;
auto x = SharedPtr!long.make(new long(123), (long* data){
	deleted = *data;
});
assert(deleted == -1);
assert(*x == 123);

x = null;
assert(deleted == 123);

Meta