C++ Actor Framework 0.18
Loading...
Searching...
No Matches
Typedefs | Functions
Sum Types

Opt-in sum type concept for variant-style types. More...

Typedefs

template<class F , class... Ts>
using caf::sum_type_visit_result_t = typename sum_type_visit_result< detail::decay_t< F >, detail::decay_t< Ts >... >::type
 

Functions

template<class T >
constexpr bool caf::SumType ()
 Concept for checking whether T supports the sum type API by specializing sum_type_access.
 
template<class... Ts>
constexpr bool caf::SumTypes ()
 Concept for checking whether all Ts support the sum type API by specializing sum_type_access.
 
template<class Trait , class T >
constexpr sum_type_token< T, sum_type_index< Trait, T >::value > caf::make_sum_type_token ()
 
template<class T , class U , class Trait = sum_type_access<U>>
auto caf::get (U &x) -> decltype(Trait::get(x, make_sum_type_token< Trait, T >()))
 Returns a reference to the value of a sum type.
 
template<class T , class U , class Trait = sum_type_access<U>>
auto caf::get (const U &x) -> decltype(Trait::get(x, make_sum_type_token< Trait, T >()))
 Returns a reference to the value of a sum type.
 
template<class T , class U , class Trait = sum_type_access<U>>
auto caf::get_if (U *x) -> decltype(Trait::get_if(x, make_sum_type_token< Trait, T >()))
 Returns a pointer to the value of a sum type if it is of type T, nullptr otherwise.
 
template<class T , class U , class Trait = sum_type_access<U>>
auto caf::get_if (const U *x) -> decltype(Trait::get_if(x, make_sum_type_token< Trait, T >()))
 Returns a pointer to the value of a sum type if it is of type T, nullptr otherwise.
 
template<class T , class U >
bool caf::holds_alternative (const U &x)
 Returns whether a sum type has a value of type T.
 
template<class Visitor , class T , class... Ts, class Result = sum_type_visit_result_t<Visitor, T, Ts...>>
detail::enable_if_t< SumTypes< T, Ts... >(), Result > caf::visit (Visitor &&f, T &&x, Ts &&... xs)
 Applies the values of any number of sum types to the visitor.
 

Detailed Description

Opt-in sum type concept for variant-style types.

Function Documentation

◆ get() [1/2]

template<class T , class U , class Trait = sum_type_access<U>>
auto caf::get ( const U &  x) -> decltype(Trait::get(x, make_sum_type_token<Trait, T>()))

Returns a reference to the value of a sum type.

Precondition
holds_alternative<T>(x)

◆ get() [2/2]

template<class T , class U , class Trait = sum_type_access<U>>
auto caf::get ( U &  x) -> decltype(Trait::get(x, make_sum_type_token<Trait, T>()))

Returns a reference to the value of a sum type.

Precondition
holds_alternative<T>(x)