eswitch-v5
Advanced counterpart for switch statement in C++
eswitch_v5::predicate_condition< TPred, Is > Class Template Reference

Description

template<typename TPred, std::size_t ... Is>
class eswitch_v5::predicate_condition< TPred, Is >

Definition at line 57 of file eswitch_v5.hpp.

Public Member Functions

template<StdTuple TSrcTuple>
constexpr bool operator() (const TSrcTuple &src_tuple) const
 
template<typename T >
constexpr predicate_condition (T &&pred)
 

Static Public Member Functions

template<std::size_t MaxIndex>
static constexpr bool is_out_of_range ()
 

Public Attributes

TPred pred_
 

Member Function Documentation

◆ is_out_of_range()

template<typename TPred , std::size_t ... Is>
template<std::size_t MaxIndex>
static constexpr bool eswitch_v5::predicate_condition< TPred, Is >::is_out_of_range ( )
staticconstexpr

Definition at line 932 of file eswitch_v5.hpp.

933  {
934  constexpr std::array< bool, sizeof...( Is ) > list{ ( Is >= MaxIndex )... };
935 
936  return std::find( std::begin( list ), std::end( list ), true ) != std::end( list );
937  }

◆ operator()()

template<typename TPred , std::size_t ... Is>
template<StdTuple TSrcTuple>
constexpr bool eswitch_v5::predicate_condition< TPred, Is >::operator() ( const TSrcTuple &  src_tuple) const
constexpr

Definition at line 923 of file eswitch_v5.hpp.

924  {
925  static_assert( !is_out_of_range< std::tuple_size_v< TSrcTuple > >(),
926  "Case Index is OUT OF RANGE" );
927 
928  return pred_( std::get< Is >( src_tuple )... );
929  }

Member Data Documentation

◆ pred_

template<typename TPred , std::size_t ... Is>
TPred eswitch_v5::predicate_condition< TPred, Is >::pred_

Definition at line 914 of file eswitch_v5.hpp.

Constructor & Destructor Documentation

◆ predicate_condition()

template<typename TPred , std::size_t ... Is>
template<typename T >
constexpr eswitch_v5::predicate_condition< TPred, Is >::predicate_condition ( T &&  pred)
constexpr

Definition at line 917 of file eswitch_v5.hpp.

918  : pred_( std::forward< T >( pred ) )
919  {
920  }
eswitch_v5::predicate_condition::is_out_of_range
static constexpr bool is_out_of_range()
Definition: eswitch_v5.hpp:932
std::find
T find(T... args)
eswitch_v5::predicate_condition::pred_
TPred pred_
Definition: eswitch_v5.hpp:914
std::array
STL class.
std::begin
T begin(T... args)
std::end
T end(T... args)