mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
Loading...
Searching...
No Matches
mrs_lib::internal::ResultStorage< T > Class Template Reference

A variant-like class for storing the result of non-void task. More...

#include <task.hpp>

Public Member Functions

constexpr void set_value (T &&val) noexcept(std::is_nothrow_move_constructible_v< T >)
 Store result of task.
 
void set_exception (std::exception_ptr eptr) noexcept
 Store exception into the result.
 
constexpr T get_value () &&
 Get previously stored result or exception.
 

Detailed Description

template<typename T>
class mrs_lib::internal::ResultStorage< T >

A variant-like class for storing the result of non-void task.

Member Function Documentation

◆ get_value()

template<typename T >
constexpr T mrs_lib::internal::ResultStorage< T >::get_value ( ) &&
inlineconstexpr

Get previously stored result or exception.

If this result contains a value, it is returned. Otherwise, if there is an exception stored, it is thrown.

Either set_value or set_exception must be called before calling this.

◆ set_exception()

template<typename T >
void mrs_lib::internal::ResultStorage< T >::set_exception ( std::exception_ptr  eptr)
inlinenoexcept

Store exception into the result.

This can only ve called once and not if set_value was called.

◆ set_value()

template<typename T >
constexpr void mrs_lib::internal::ResultStorage< T >::set_value ( T &&  val)
inlineconstexprnoexcept

Store result of task.

This can only ve called once and not if set_exception was called.


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