template<typename T>
class maxon::ResultRef< T >
ResultRef<T> wraps a pointer. When the pointer is nullptr, this has to be interpreted as an out-of-memory error condition, otherwise GetValue() returns the pointer as a C++ reference.
ResultRef<T> can be used instead of the more general Result<T&> when only out-of-memory conditions can occur in a function. It will lead to more efficient code.
Sometimes it is necessary to convert a ResultRef<T> to a ResultPtr<T>, for example if the variable to which the result shall be assigned already exists:
BaseArray<Int> array;
if (some condition)
{
}
maxon::Int Int
Definition: ge_sys_math.h:64
char ** ptr
Definition: pycore_dtoa.h:13
#define iferr_return
Definition: resultbase.h:1519
The result of the second call to Append has to be converted from ResultRef<Int> to ResultPtr<Int> so that (in the successful case) ptr can be set to a pointer to the new array element. For this purpose the address-of operator & is overloaded at ResultRef to do exactly this conversion.
All error handling features of the MAXON API (such as iferr, iferr_return and Result) support ResultRef.
|
MAXON_IMPLICIT | ResultRef (T *value=nullptr) |
|
MAXON_IMPLICIT | ResultRef (T &value) |
|
MAXON_IMPLICIT | ResultRef (ERROR_FAILED) |
|
void | operator= (T &)=delete |
|
template<typename T2 , typename = typename std::enable_if<(STD_IS_REPLACEMENT(same, const T, const T2) || STD_IS_REPLACEMENT(base_of, T, T2)) && (STD_IS_REPLACEMENT(const, T) >= STD_IS_REPLACEMENT(const, T2))>::type> |
MAXON_IMPLICIT | ResultRef (const ResultRef< T2 > &src) |
|
template<typename T2 , typename = typename std::enable_if<(STD_IS_REPLACEMENT(same, const T, const T2) || STD_IS_REPLACEMENT(base_of, T, T2)) && (STD_IS_REPLACEMENT(const, T) >= STD_IS_REPLACEMENT(const, T2))>::type> |
MAXON_IMPLICIT | ResultRef (const ResultPtr< T2 > &src) |
|
Bool | operator== (ERROR_OK) const |
|
Bool | operator== (ERROR_FAILED) const |
|
T & | GetValue () const |
|
T & | UncheckedGetValue () const |
|
T * | GetPointer () const |
|
const ResultPtr< T > & | operator& () const |
|