eswitch-v5
Advanced counterpart for switch statement in C++
Utilities

Description

Classes

struct  eswitch_v5::details::Always_false< Ts >
 
struct  eswitch_v5::details::amount_args< T, typename >
 
struct  eswitch_v5::details::amount_args< T, std::void_t< decltype(&T::operator()) > >
 
struct  eswitch_v5::details::amount_args_function_has< T >
 
struct  eswitch_v5::details::amount_args_function_has< R(C::*)(Args...) >
 
struct  eswitch_v5::details::amount_args_function_has< R(C::*)(Args...) const >
 
struct  eswitch_v5::details::invoke_result< T, typename >
 
struct  eswitch_v5::details::invoke_result< T, std::void_t< decltype(&T::operator()) > >
 
struct  eswitch_v5::details::is_callable_impl< T >
 
struct  eswitch_v5::details::is_callable_impl< R(C::*)(Args...) >
 
struct  eswitch_v5::details::is_callable_impl< R(C::*)(Args...) const >
 
struct  eswitch_v5::details::is_default_case< T >
 
struct  eswitch_v5::details::is_default_case< condition< Op, I, extension::any > >
 
struct  eswitch_v5::details::is_predicate< T >
 
struct  eswitch_v5::details::is_predicate< C< T, Is... > >
 
struct  eswitch_v5::details::is_std_pair< T >
 
struct  eswitch_v5::details::is_std_pair< Pair< T1, T2 > >
 
struct  eswitch_v5::details::is_std_tuple< T >
 
struct  eswitch_v5::details::is_std_tuple< Tuple< Ts... > >
 

Typedefs

template<typename T >
using eswitch_v5::details::invoke_result_t = typename invoke_result< T >::type
 

Functions

template<std::size_t ... Is, typename Tup >
static constexpr auto eswitch_v5::details::create_indexed_condition (Tup &&values)
 
template<typename ... Ts>
constexpr std::true_type eswitch_v5::details::is_std_variant (std::variant< Ts... > &&)
 
template<typename T >
constexpr std::false_type eswitch_v5::details::is_std_variant (T &&)
 
template<typename ... Cnds>
constexpr auto eswitch_v5::details::move_default_case_to_the_end (Cnds &&... cnds)
 
template<typename ... TupleCnds, typename Cnd , typename ... Cnds>
constexpr auto eswitch_v5::details::move_default_case_to_the_end_impl (std::tuple< TupleCnds... > &&tup, Cnd &&cnd, Cnds &&...cnds)
 
static constexpr bool eswitch_v5::details::unreachable ()
 

Variables

template<typename T >
constexpr std::size_t eswitch_v5::details::amount_args_v = amount_args< T >::value
 
template<typename T >
constexpr bool eswitch_v5::details::is_callable_v = is_callable_impl< decltype( &T::operator() ) >::value
 
template<typename T >
constexpr bool eswitch_v5::details::is_default_case_v = is_default_case< T >::value
 
template<typename T >
constexpr bool eswitch_v5::details::is_predicate_v = is_predicate< T >::value
 
template<typename T >
constexpr bool eswitch_v5::details::is_std_any_v = std::is_same_v< std::decay_t< T >, std::any >
 
template<typename T >
constexpr bool eswitch_v5::details::is_std_pair_v = is_std_pair< std::decay_t< T > >::value
 
template<typename T >
constexpr bool eswitch_v5::details::is_std_tuple_v = is_std_tuple< std::decay_t< T > >::value
 
template<typename T >
constexpr bool eswitch_v5::details::is_std_variant_v = decltype( is_std_variant( std::declval< std::decay_t< T > >() ) )()
 

Typedef Documentation

◆ invoke_result_t

template<typename T >
using eswitch_v5::details::invoke_result_t = typedef typename invoke_result< T >::type

#include <eswitch_v5.hpp>

Definition at line 310 of file eswitch_v5.hpp.

Function Documentation

◆ create_indexed_condition()

template<std::size_t ... Is, typename Tup >
static constexpr auto eswitch_v5::details::create_indexed_condition ( Tup &&  values)
staticconstexpr

#include <eswitch_v5.hpp>

Definition at line 348 of file eswitch_v5.hpp.

349  {
350  auto combine = []< typename T1, typename T2 >( T1 && t1, T2 && t2 )
351  {
352  if constexpr( Condition< T2 > && Index< T1 > )
353  {
354  static_assert( T1::eswitch_index == T2::idx::eswitch_index, "Wrong Index!" );
355  return std::forward< T2 >( t2 );
356  }
357  else
358  return std::forward< T1 >( t1 ) == std::forward< T2 >( t2 );
359  };
360 
361  return ( combine( Index_< Is >{}, std::get< Is >( std::move( values ) ) ) && ... );
362  }

◆ is_std_variant() [1/2]

template<typename ... Ts>
constexpr std::true_type eswitch_v5::details::is_std_variant ( std::variant< Ts... > &&  )
constexpr

#include <eswitch_v5.hpp>

◆ is_std_variant() [2/2]

template<typename T >
constexpr std::false_type eswitch_v5::details::is_std_variant ( T &&  )
constexpr

#include <eswitch_v5.hpp>

◆ move_default_case_to_the_end()

template<typename ... Cnds>
constexpr auto eswitch_v5::details::move_default_case_to_the_end ( Cnds &&...  cnds)
constexpr

#include <eswitch_v5.hpp>

Definition at line 341 of file eswitch_v5.hpp.

342  {
344  std::forward< Cnds >( cnds )... );
345  }

◆ move_default_case_to_the_end_impl()

template<typename ... TupleCnds, typename Cnd , typename ... Cnds>
constexpr auto eswitch_v5::details::move_default_case_to_the_end_impl ( std::tuple< TupleCnds... > &&  tup,
Cnd &&  cnd,
Cnds &&...  cnds 
)
constexpr

#include <eswitch_v5.hpp>

Definition at line 319 of file eswitch_v5.hpp.

320  {
321  if constexpr( is_default_case_v< decltype( std::declval< Cnd >().cnd ) > )
322  {
323  return std::tuple_cat( std::move( tup ),
325  std::forward< Cnds >( cnds )...,
326  std::forward< Cnd >( cnd ) ) );
327  }
328  else if constexpr( sizeof...( Cnds ) > 0 )
329  {
331  std::tuple_cat( std::move( tup ), std::make_tuple( std::forward< Cnd >( cnd ) ) ),
332  std::forward< Cnds >( cnds )... );
333  }
334  else
335  {
336  return std::tuple_cat( std::move( tup ), std::make_tuple( std::forward< Cnd >( cnd ) ) );
337  }
338  }

◆ unreachable()

static constexpr bool eswitch_v5::details::unreachable ( )
staticconstexpr

#include <eswitch_v5.hpp>

Definition at line 248 of file eswitch_v5.hpp.

249  {
250  if( !std::is_constant_evaluated() ) assert( false );
251 
252  return false;
253  }

Variable Documentation

◆ amount_args_v

template<typename T >
constexpr std::size_t eswitch_v5::details::amount_args_v = amount_args< T >::value
constexpr

#include <eswitch_v5.hpp>

Definition at line 298 of file eswitch_v5.hpp.

◆ is_callable_v

template<typename T >
constexpr bool eswitch_v5::details::is_callable_v = is_callable_impl< decltype( &T::operator() ) >::value
constexpr

#include <eswitch_v5.hpp>

Definition at line 246 of file eswitch_v5.hpp.

◆ is_default_case_v

template<typename T >
constexpr bool eswitch_v5::details::is_default_case_v = is_default_case< T >::value
constexpr

#include <eswitch_v5.hpp>

Definition at line 198 of file eswitch_v5.hpp.

◆ is_predicate_v

template<typename T >
constexpr bool eswitch_v5::details::is_predicate_v = is_predicate< T >::value
constexpr

#include <eswitch_v5.hpp>

Definition at line 267 of file eswitch_v5.hpp.

◆ is_std_any_v

template<typename T >
constexpr bool eswitch_v5::details::is_std_any_v = std::is_same_v< std::decay_t< T >, std::any >
constexpr

#include <eswitch_v5.hpp>

Definition at line 234 of file eswitch_v5.hpp.

◆ is_std_pair_v

template<typename T >
constexpr bool eswitch_v5::details::is_std_pair_v = is_std_pair< std::decay_t< T > >::value
constexpr

#include <eswitch_v5.hpp>

Definition at line 219 of file eswitch_v5.hpp.

◆ is_std_tuple_v

template<typename T >
constexpr bool eswitch_v5::details::is_std_tuple_v = is_std_tuple< std::decay_t< T > >::value
constexpr

#include <eswitch_v5.hpp>

Definition at line 231 of file eswitch_v5.hpp.

◆ is_std_variant_v

template<typename T >
constexpr bool eswitch_v5::details::is_std_variant_v = decltype( is_std_variant( std::declval< std::decay_t< T > >() ) )()
constexpr

#include <eswitch_v5.hpp>

Definition at line 207 of file eswitch_v5.hpp.

std::make_tuple
T make_tuple(T... args)
eswitch_v5::details::move_default_case_to_the_end_impl
constexpr auto move_default_case_to_the_end_impl(std::tuple< TupleCnds... > &&tup, Cnd &&cnd, Cnds &&...cnds)
Definition: eswitch_v5.hpp:319
eswitch_v5::details::is_default_case_v
constexpr bool is_default_case_v
Definition: eswitch_v5.hpp:198
std::is_constant_evaluated
T is_constant_evaluated(T... args)
std::tuple_cat
T tuple_cat(T... args)