Functions for user-defined lifetime implementation.
Moves source into target.
Forwards function arguments with saving ref-ness.
int foo(int n) { return 1; } int foo(ref int n) { return 2; } int bar()(auto ref int x) { return foo(forward!x); } assert(bar(1) == 1); int i; assert(bar(i) == 2);
void foo(int n, ref string s) { s = null; foreach (i; 0..n) s ~= "Hello"; } // forwards all arguments which are bound to parameter tuple void bar(Args...)(auto ref Args args) { return foo(forward!args); } // forwards all arguments with swapping order void baz(Args...)(auto ref Args args) { return foo(forward!args[$/2..$], forward!args[0..$/2]); } string s; bar(1, s); assert(s == "Hello"); baz(s, 2); assert(s == "HelloHello");
Constructs an object of type T in given chunk of uninitialized memory just like T t = arg;.
Constructs an object of struct type S in given chunk of uninitialized memory just like auto s = S(args);.
Constructs an object of class type C at given reference to uninitialized memory just like auto c = new C(args); except given memory is used instead of allocating.
Destroys the given class instance and puts it in an invalid state. It's used to destroy an object so that any cleanup which its destructor or finalizer does is done. It does not initiate a GC cycle or free any GC memory. It always zero class instance __vptr. If resetMemory is true it will also set class instance memory to its initial state so that it no longer references any other objects.
Determines whether class instance t is finalized.
Also returns true if t's memory is zero-filled.
T must be either class or interface.
Destructs t exactly the same way a compiler does in a case it goes out of scope. Also puts destructed object in its init state if resetInitialState is true, otherwise object state will be undefined (i.e. possibly invalid).
Sets the passed object to its `init` state.
Use this function instead of dealing with tricky typeid(T).init().
Sets all elements of the passed dynamic array to its `init` state.
Use this function for better performance instead of calling setToInitialState on each element.
Calls the postblit of the given object, if any.
Faster and convenient replacement for typeid(T).postblit(&t).
Calls the destructor of the given object, if any.
Faster and convenient replacement for typeid(T).destroy(&t).