.. index:: pair: class; EE::Result .. _doxid-class_e_e_1_1_result: template class EE::Result ========================= .. toctree:: :hidden: Overview ~~~~~~~~ A synchronous success-or-error value. :ref:`More...` .. ref-code-block:: cpp :class: doxyrest-overview-code-block #include template class Result { public: // typedefs typedef T :target:`ValueType`; typedef E :target:`ErrorType`; // fields T :target:`mValue`; E :target:`mError`; // construction template , int> = 0> :target:`Result`(:ref:`OkValue`&& ok); template , int> = 0> :target:`Result`(const :ref:`OkValue`& ok); template , int> = 0> :target:`Result`(:ref:`ErrValue`&& err); template , int> = 0> :target:`Result`(const :ref:`ErrValue`& err); :target:`Result`(const Result& other); :target:`Result`(Result&& other); :target:`~Result`(); // methods Result& :target:`operator=`(const Result& other); Result& :target:`operator=`(Result&& other); bool :target:`hasValue`() const; bool :target:`hasError`() const; :target:`operator bool`() const; T& :target:`value`(); const T& :target:`value`() const; T&& :target:`value`(); E& :target:`error`(); const E& :target:`error`() const; E&& :target:`error`(); T* :target:`operator->`(); const T* :target:`operator->`() const; T& :target:`operator*`(); const T& :target:`operator*`() const; T&& :target:`operator*`(); }; .. _details-class_e_e_1_1_result: Detailed Documentation ~~~~~~~~~~~~~~~~~~~~~~ A synchronous success-or-error value. Result holds either a T or an E, stored inline in a union. It has no threading or async semantics. Payload construction and assignment can propagate exceptions; accessing the inactive member is a contract violation reported by a debug assertion. Move-only types are supported. Assignment requires at least one alternative to be nothrow move-constructible, so a failed cross-alternative construction preserves the destination's previous alternative and value. Assignment within one alternative follows that payload's exception guarantee. .. ref-code-block:: cpp Result statResult = Ok( std::move( info ) ); if ( statResult ) consume( statResult.value() ); else report( statResult.error() );