HolderInitializer

HolderInitializer struct

This class used to get persistent reference to the object instance, whatever it is lvalue or rvalue. To ubtain such reference, use ‘HoldIfTemporary’ method, that has there overloads. Two of them take rvalue as a parameter, and just return the reference to it. The third one, in opposite, takes lvalue as a parameter, makes a pointer copy, then return reference to that copy. Also, class has ‘Hold’ method to hold passed value unconditionally (used to copy values of a local on-stack variables or it’s child references)

template<typename T,bool>class HolderInitializer

Template parameters

ParameterDescription
TThe type of the object to hold to.
RTrue, if T is a reference type (SmartPtr specialization or System::String type), and temporary references holding is actually required, false - otherwise.

Methods

MethodDescription
const T& Hold(const T&)Copies passed lvalue to holder, then return the holder reference Caller should use this method to hold passed value unconditionally.
HolderInitializer(T&)Initializes holder reference with passed one.
const T& HoldIfTemporary(const T&)Returns reference to rvalue (const)
const T& HoldIfTemporary(T&)Returns reference to rvalue (non-const)
const T& HoldIfTemporary(T&&)Copies passed lvalue to holder, then return the holder reference.

See Also