CodePorting.Translator.Cs2Cpp.Framework
System::HolderInitializer< T, R > Struct Template Reference

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

#include <holder_initializer.h>

Public Member Functions

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

Detailed Description

template<typename T, bool R = System::IsSmartPtr<T>::value || std::is_same<System::String, T>::value>
struct System::HolderInitializer< T, R >

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

Constructor & Destructor Documentation

◆ HolderInitializer()

template<typename T , bool R = System::IsSmartPtr<T>::value || std::is_same<System::String, T>::value>
System::HolderInitializer< T, R >::HolderInitializer ( T &  holder)
inline

Initializes holder reference with passed one.

Member Function Documentation

◆ Hold()

template<typename T , bool R = System::IsSmartPtr<T>::value || std::is_same<System::String, T>::value>
const T & System::HolderInitializer< T, R >::Hold ( const T &  value)
inline

Copies passed lvalue to holder, then return the holder reference Caller should use this method to hold passed value unconditionally.

◆ HoldIfTemporary() [1/3]

template<typename T , bool R = System::IsSmartPtr<T>::value || std::is_same<System::String, T>::value>
const T & System::HolderInitializer< T, R >::HoldIfTemporary ( const T &  value)
inline

Returns reference to rvalue (const)

◆ HoldIfTemporary() [2/3]

template<typename T , bool R = System::IsSmartPtr<T>::value || std::is_same<System::String, T>::value>
const T & System::HolderInitializer< T, R >::HoldIfTemporary ( T &&  value)
inline

Copies passed lvalue to holder, then return the holder reference.

◆ HoldIfTemporary() [3/3]

template<typename T , bool R = System::IsSmartPtr<T>::value || std::is_same<System::String, T>::value>
const T & System::HolderInitializer< T, R >::HoldIfTemporary ( T &  value)
inline

Returns reference to rvalue (non-const)