eswitch-v5
Advanced counterpart for switch statement in C++
eswitch_v5::conditions< LogicalOperator, Cnds > Class Template Reference

Description

template<Logical_operators LogicalOperator, Condition ... Cnds>
class eswitch_v5::conditions< LogicalOperator, Cnds >

Container which holds arbitrary number of condition.

Definition at line 587 of file eswitch_v5.hpp.

Friends

template<Logical_operators , Condition ... >
class conditions
 

Public Member Functions

constexpr conditions (Cnds &&... cnds)
 
template<Condition ... OtherCnds, Condition Cnd>
constexpr conditions (conditions< LogicalOperator, OtherCnds... > &&cnds, Cnd &&cnd)
 
template<StdTuple TSrcTuple>
constexpr bool operator() (const TSrcTuple &src_tuple) const
 

Static Public Member Functions

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

Methods

◆ conditions

template<Logical_operators LogicalOperator, Condition ... Cnds>
template<Logical_operators , Condition ... >
friend class conditions
friend

Definition at line 590 of file eswitch_v5.hpp.

Member Function Documentation

◆ is_out_of_range()

template<Logical_operators LogicalOperator, Condition ... Cnds>
template<std::size_t MaxIndex>
static constexpr bool eswitch_v5::conditions< LogicalOperator, Cnds >::is_out_of_range ( )
staticconstexpr

Definition at line 607 of file eswitch_v5.hpp.

608  {
609  return ( Cnds::template is_out_of_range< MaxIndex >() || ... );
610  }

◆ operator()()

template<Logical_operators LogicalOperator, Condition ... Cnds>
template<StdTuple TSrcTuple>
constexpr bool eswitch_v5::conditions< LogicalOperator, Cnds >::operator() ( const TSrcTuple &  src_tuple) const
constexpr

Definition at line 613 of file eswitch_v5.hpp.

614  {
615  auto lmbd = [&]< typename T, T ... ints >( std::index_sequence< ints... > && )
616  {
617  return compare( static_cast< bool >( std::get< ints >( cnds_ )( src_tuple ) )... );
618  };
619 
620  return lmbd( std::make_index_sequence< sizeof...( Cnds ) >{} );
621  }

Constructor & Destructor Documentation

◆ conditions() [1/2]

template<Logical_operators LogicalOperator, Condition ... Cnds>
template<Condition ... OtherCnds, Condition Cnd>
constexpr eswitch_v5::conditions< LogicalOperator, Cnds >::conditions ( conditions< LogicalOperator, OtherCnds... > &&  cnds,
Cnd &&  cnd 
)
constexpr

Definition at line 596 of file eswitch_v5.hpp.

597  : cnds_( std::tuple_cat( std::move( cnds.cnds_ ), std::make_tuple( std::move( cnd ) ) ) )
598  {
599  }

◆ conditions() [2/2]

template<Logical_operators LogicalOperator, Condition ... Cnds>
constexpr eswitch_v5::conditions< LogicalOperator, Cnds >::conditions ( Cnds &&...  cnds)
constexpr

Definition at line 601 of file eswitch_v5.hpp.

602  : cnds_( std::move( cnds )... )
603  {
604  }
std::make_tuple
T make_tuple(T... args)
std::index_sequence
std::tuple_cat
T tuple_cat(T... args)