eswitch-v5
Advanced counterpart for switch statement in C++
eswitch_v5::condition< CmpOperator, TIndex, CaseEntry > Class Template Reference

Description

template<Comparison_operators CmpOperator, Index TIndex, typename CaseEntry>
class eswitch_v5::condition< CmpOperator, TIndex, CaseEntry >

Compares value with corresponding entry in std::tuple.

Definition at line 54 of file eswitch_v5.hpp.

Friends

template<Comparison_operators , Index , typename >
class condition
 

Public Types

using idx = TIndex
 
using value_type = CaseEntry
 

Public Member Functions

template<typename Arg >
constexpr condition (Arg &&value)
 
template<StdTuple TSrcTuple>
constexpr auto operator() (const TSrcTuple &src_tuple) const
 
template<StdTuple TSrcTuple>
constexpr bool operator() (const TSrcTuple &src_tuple) const requires(std
 

Static Public Member Functions

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

Methods

◆ condition

template<Comparison_operators CmpOperator, Index TIndex, typename CaseEntry >
template<Comparison_operators , Index , typename >
friend class condition
friend

Definition at line 505 of file eswitch_v5.hpp.

Member Function Documentation

◆ is_out_of_range()

template<Comparison_operators CmpOperator, Index TIndex, typename CaseEntry >
template<std::size_t MaxIndex>
static constexpr bool eswitch_v5::condition< CmpOperator, TIndex, CaseEntry >::is_out_of_range ( )
staticconstexpr

Definition at line 536 of file eswitch_v5.hpp.

537  {
538  return TIndex::eswitch_index >= MaxIndex;
539  }

◆ operator()() [1/2]

template<Comparison_operators CmpOperator, Index TIndex, typename CaseEntry >
template<StdTuple TSrcTuple>
constexpr auto eswitch_v5::condition< CmpOperator, TIndex, CaseEntry >::operator() ( const TSrcTuple &  src_tuple) const
constexpr

Definition at line 520 of file eswitch_v5.hpp.

521  {
522  static_assert( !is_out_of_range< std::tuple_size_v< TSrcTuple > >(),
523  "Case Index is OUT OF RANGE" );
524 
525  return compare( std::get< TIndex::eswitch_index >( src_tuple ), value_ );
526  }

◆ operator()() [2/2]

template<Comparison_operators CmpOperator, Index TIndex, typename CaseEntry >
template<StdTuple TSrcTuple>
constexpr bool eswitch_v5::condition< CmpOperator, TIndex, CaseEntry >::operator() ( const TSrcTuple &  src_tuple) const
constexpr

Definition at line 529 of file eswitch_v5.hpp.

531  {
532  return false;
533  }

Member Typedef Documentation

◆ idx

template<Comparison_operators CmpOperator, Index TIndex, typename CaseEntry >
using eswitch_v5::condition< CmpOperator, TIndex, CaseEntry >::idx = TIndex

Definition at line 511 of file eswitch_v5.hpp.

◆ value_type

template<Comparison_operators CmpOperator, Index TIndex, typename CaseEntry >
using eswitch_v5::condition< CmpOperator, TIndex, CaseEntry >::value_type = CaseEntry

Definition at line 510 of file eswitch_v5.hpp.

Constructor & Destructor Documentation

◆ condition()

template<Comparison_operators CmpOperator, Index TIndex, typename CaseEntry >
template<typename Arg >
constexpr eswitch_v5::condition< CmpOperator, TIndex, CaseEntry >::condition ( Arg &&  value)
constexpr

Definition at line 514 of file eswitch_v5.hpp.

515  : value_( std::forward< Arg >( value ) )
516  {
517  }
eswitch_v5::condition::is_out_of_range
static constexpr bool is_out_of_range()
Definition: eswitch_v5.hpp:536