RPNX::QueryGraph
Typed, memoized, concurrent query evaluation for C++23
Loading...
Searching...
No Matches
rpnx::querygraph::result< T > Class Template Reference

Internal value-or-error state shared by query awaitables and dumps. More...

#include <querygraph.hpp>

Public Member Functions

 result ()=default
 Construct a pending result.
 
 result (T value)
 Construct a completed result from value.
 
 result (std::exception_ptr exception)
 Construct a failed result from an unexpected exception.
 
void test () const
 Rethrow the stored error, if one exists.
 
T & get () &
 Return the value or throw the stored error.
 
T const & get () const &
 Return the value or throw the stored error.
 
T && get () &&
 Return the value or throw the stored error.
 
T const && get () const &&
 Return the value or throw the stored error.
 
T & value () &
 Alias for get() preserving the value category.
 
T const & value () const &
 Alias for get() preserving the value category.
 
T && value () &&
 Alias for get() preserving the value category.
 
T const && value () const &&
 Alias for get() preserving the value category.
 
void set_value (T value)
 Replace any prior state with a completed value.
 
void set_error (error_result error)
 Replace any prior state with error.
 
void set_error (std::exception_ptr exception)
 Replace any prior state with an unexpected exception.
 
void set_exception (std::exception_ptr exception)
 Compatibility spelling for set_error(exception).
 
bool has_result () const
 Return whether evaluation produced either a value or an error.
 
bool has_value () const
 Return whether evaluation completed successfully.
 
bool has_error () const
 Return whether evaluation completed with an error.
 
bool has_exception () const
 Compatibility spelling for has_error().
 
bool has_canonical_error () const
 Return whether the result contains a canonical error.
 
bool has_unexpected_exception () const
 Return whether the result contains an unexpected exception.
 
error_result const & get_error_result () const
 Return the stored error state without throwing.
 
std::exception_ptr get_error () const
 Materialize the stored error as an exception pointer.
 
status result_status () const
 Return the status used when serializing this result.
 
 operator bool () const
 Return whether evaluation has reached any terminal state.
 

Detailed Description

template<typename T>
class rpnx::querygraph::result< T >

Internal value-or-error state shared by query awaitables and dumps.

Unlike std::expected, a default-constructed instance is pending: it has neither a value nor an error. Accessors rethrow stored errors before returning a value.

Template Parameters
TSuccessful value type.

Definition at line 512 of file querygraph.hpp.

Constructor & Destructor Documentation

◆ result() [1/2]

template<typename T>
rpnx::querygraph::result< T >::result ( T value)
inline

Construct a completed result from value.

Definition at line 522 of file querygraph.hpp.

References value().

◆ result() [2/2]

template<typename T>
rpnx::querygraph::result< T >::result ( std::exception_ptr exception)
inline

Construct a failed result from an unexpected exception.

Definition at line 527 of file querygraph.hpp.

Member Function Documentation

◆ get() [1/4]

template<typename T>
T & rpnx::querygraph::result< T >::get ( ) &
inline

Return the value or throw the stored error.

Definition at line 541 of file querygraph.hpp.

References test().

Referenced by value(), value(), and rpnx::querygraph::result< void >::value().

◆ get() [2/4]

template<typename T>
T && rpnx::querygraph::result< T >::get ( ) &&
inline

Return the value or throw the stored error.

Definition at line 557 of file querygraph.hpp.

References test().

◆ get() [3/4]

template<typename T>
T const & rpnx::querygraph::result< T >::get ( ) const &
inline

Return the value or throw the stored error.

Definition at line 549 of file querygraph.hpp.

References test().

◆ get() [4/4]

template<typename T>
T const && rpnx::querygraph::result< T >::get ( ) const &&
inline

Return the value or throw the stored error.

Definition at line 565 of file querygraph.hpp.

References test().

◆ get_error()

template<typename T>
std::exception_ptr rpnx::querygraph::result< T >::get_error ( ) const
inline

Materialize the stored error as an exception pointer.

Definition at line 665 of file querygraph.hpp.

◆ get_error_result()

template<typename T>
error_result const & rpnx::querygraph::result< T >::get_error_result ( ) const
inline

Return the stored error state without throwing.

Definition at line 659 of file querygraph.hpp.

Referenced by rpnx::querygraph::debug_abi::graph::node_debug_io_capture_enabled(), and rpnx::querygraph::debug_abi::graph::register_binary_descriptors().

◆ has_canonical_error()

template<typename T>
bool rpnx::querygraph::result< T >::has_canonical_error ( ) const
inline

Return whether the result contains a canonical error.

Definition at line 647 of file querygraph.hpp.

◆ has_error()

template<typename T>
bool rpnx::querygraph::result< T >::has_error ( ) const
inline

Return whether evaluation completed with an error.

Definition at line 635 of file querygraph.hpp.

Referenced by has_exception(), and rpnx::querygraph::result< void >::has_exception().

◆ has_exception()

template<typename T>
bool rpnx::querygraph::result< T >::has_exception ( ) const
inline

Compatibility spelling for has_error().

Definition at line 641 of file querygraph.hpp.

References has_error().

Referenced by rpnx::querygraph::debug_abi::graph::register_binary_descriptors().

◆ has_result()

template<typename T>
bool rpnx::querygraph::result< T >::has_result ( ) const
inline

Return whether evaluation produced either a value or an error.

Definition at line 623 of file querygraph.hpp.

Referenced by rpnx::querygraph::debug_abi::graph::node_debug_io_capture_enabled(), operator bool(), and rpnx::querygraph::result< void >::operator bool().

◆ has_unexpected_exception()

template<typename T>
bool rpnx::querygraph::result< T >::has_unexpected_exception ( ) const
inline

Return whether the result contains an unexpected exception.

Definition at line 653 of file querygraph.hpp.

Referenced by rpnx::querygraph::debug_abi::graph::node_debug_io_capture_enabled().

◆ has_value()

template<typename T>
bool rpnx::querygraph::result< T >::has_value ( ) const
inline

Return whether evaluation completed successfully.

Definition at line 629 of file querygraph.hpp.

Referenced by rpnx::querygraph::debug_abi::graph::register_binary_descriptors().

◆ operator bool()

template<typename T>
rpnx::querygraph::result< T >::operator bool ( ) const
inlineexplicit

Return whether evaluation has reached any terminal state.

Definition at line 681 of file querygraph.hpp.

References has_result().

◆ result_status()

template<typename T>
status rpnx::querygraph::result< T >::result_status ( ) const
inline

Return the status used when serializing this result.

Definition at line 671 of file querygraph.hpp.

Referenced by rpnx::querygraph::debug_abi::graph::register_binary_descriptors().

◆ set_error() [1/2]

template<typename T>
void rpnx::querygraph::result< T >::set_error ( error_result< T > error)
inline

Replace any prior state with error.

Definition at line 604 of file querygraph.hpp.

Referenced by set_error(), rpnx::querygraph::result< void >::set_error(), set_exception(), and rpnx::querygraph::result< void >::set_exception().

◆ set_error() [2/2]

template<typename T>
void rpnx::querygraph::result< T >::set_error ( std::exception_ptr exception)
inline

Replace any prior state with an unexpected exception.

Definition at line 611 of file querygraph.hpp.

References set_error(), and rpnx::querygraph::error_result::unexpected().

◆ set_exception()

template<typename T>
void rpnx::querygraph::result< T >::set_exception ( std::exception_ptr exception)
inline

Compatibility spelling for set_error(exception).

Definition at line 617 of file querygraph.hpp.

References set_error().

◆ set_value()

template<typename T>
void rpnx::querygraph::result< T >::set_value ( T value)
inline

Replace any prior state with a completed value.

Definition at line 597 of file querygraph.hpp.

References value().

◆ test()

template<typename T>
void rpnx::querygraph::result< T >::test ( ) const
inline

Rethrow the stored error, if one exists.

Definition at line 532 of file querygraph.hpp.

Referenced by get(), get(), get(), get(), and rpnx::querygraph::result< void >::get().

◆ value() [1/4]

template<typename T>
T & rpnx::querygraph::result< T >::value ( ) &
inline

Alias for get() preserving the value category.

Definition at line 573 of file querygraph.hpp.

References get().

Referenced by result(), rpnx::querygraph::debug_abi::graph::register_binary_descriptors(), and set_value().

◆ value() [2/4]

template<typename T>
T && rpnx::querygraph::result< T >::value ( ) &&
inline

Alias for get() preserving the value category.

Definition at line 585 of file querygraph.hpp.

◆ value() [3/4]

template<typename T>
T const & rpnx::querygraph::result< T >::value ( ) const &
inline

Alias for get() preserving the value category.

Definition at line 579 of file querygraph.hpp.

References get().

◆ value() [4/4]

template<typename T>
T const && rpnx::querygraph::result< T >::value ( ) const &&
inline

Alias for get() preserving the value category.

Definition at line 591 of file querygraph.hpp.


The documentation for this class was generated from the following file: