eswitch-v5
Advanced counterpart for switch statement in C++
eswitch_v5 Namespace Reference

Namespaces

 details
 
 extension
 

Classes

class  condition
 Compares value with corresponding entry in std::tuple. More...
 
struct  condition_with_predicate
 
class  conditions
 Container which holds arbitrary number of condition. More...
 
class  eswitch_impl
 Accept arbitrary number of Case's and test each of them sequentially. If match was found then executes Case body, also based on Case falling option decides whether to execute next body or finish work. More...
 
struct  Fallthrough
 
struct  Index_
 This structure is used as a reference to a specific parameter inside eswitch. More...
 
struct  is
 Used to match for type of active entry in std::any, std::variant<...> and polymorphic types. More...
 
class  predicate_condition
 
struct  regexter
 

Enumerations

enum  Comparison_operators {
  Comparison_operators::equal, Comparison_operators::not_equal, Comparison_operators::greater, Comparison_operators::greater_or_equal,
  Comparison_operators::less, Comparison_operators::less_or_equal
}
 
enum  Logical_operators { Logical_operators::and_, Logical_operators::or_ }
 

Functions

template<typename ... Args>
static constexpr auto any_from (Args &&... args)
 Helper function which allows to find if something is within the list( passed arguments ). More...
 
template<Condition Cnd>
static constexpr auto case_ (Cnd &&cnd)
 
template<typename ... Ts>
static constexpr auto case_ (Ts &&... values)
 
template<typename P , std::size_t ... I, Index Idx>
predicate_condition< P, I..., Idx::eswitch_index > compose_new_predicate_condition_type (const predicate_condition< P, I... > &, Idx)
 
template<typename T , typename F >
 condition_with_predicate (T, F) -> condition_with_predicate< T, F >
 
template<StdPair T>
static constexpr auto eswitch (T &&pair)
 This overload expand std::pair. Simplifies following form eswitch( pair.first, pair.second ) to eswitch( pair ). Moreover there is similar overload for std::tuple. More...
 
template<typename ... Ts>
static constexpr auto eswitch (Ts &&... ts)
 This function is responsible for passing arguments for class eswitch_impl with overloaded operator(), which accepts arbitrary number of Case's. More...
 
template<typename ... Ts>
 eswitch_impl (Ts &&...) -> eswitch_impl< Ts... >
 
template<Index Idx, typename T >
constexpr auto operator!= (Idx &&, T &&rhv)
 
auto operator""_r (const char *rgx, const std::size_t sz)
 User-defined literals for std::regex. More...
 
template<Condition T, Callable Func>
static constexpr auto operator% (T &&cnd, Func &&f)
 
template<Condition Cnd1, Condition Cnd2>
static constexpr auto operator&& (Cnd1 &&cnd1, Cnd2 &&cnd2)
 
template<Condition ... Cnds, Condition Cnd>
static constexpr auto operator&& (conditions< Logical_operators::and_, Cnds... > &&cnds, Cnd &&cnd)
 
template<IsNotCndPredicate Pred, Index Idx>
static constexpr auto operator, (Pred &&pred, Idx)
 
template<typename R , typename... Args, Index Idx>
static constexpr auto operator, (R(*pred)(Args...), Idx)
 
template<Index Idx, typename T >
constexpr auto operator< (Idx &&, T &&rhv)
 
template<Index Idx, typename T >
constexpr auto operator<= (Idx &&, T &&rhv)
 
static auto operator== (const std::string &tuple_entry, const regexter &value)
 CaseModule to support for matching and withdrawing of values for and from regular expression. More...
 
template<Index Idx, typename T >
static constexpr auto operator== (Idx &&, T &&rhv)
 
template<typename TupleEntry , typename UnderlyingType >
static constexpr auto operator== (TupleEntry &&tuple_entry, const is< UnderlyingType > &) noexcept
 CaseModule to support for matching for various polymorphic types. More...
 
template<Index Idx, typename T >
constexpr auto operator> (Idx &&, T &&rhv)
 
template<Index Idx, typename T >
constexpr auto operator>= (Idx &&, T &&rhv)
 
template<typename Cnd , ReturnValueNoneVoid Func>
static constexpr auto operator^ (condition_with_predicate< Cnd, Func > &&cp, const Fallthrough &)
 
template<Condition Cnd1, Condition Cnd2>
static constexpr auto operator|| (Cnd1 &&cnd1, Cnd2 &&cnd2)
 
template<Condition ... Cnds, Condition Cnd>
static constexpr auto operator|| (conditions< Logical_operators::or_, Cnds... > &&cnds, Cnd &&cnd)
 

Variables

static constexpr extension::any _
 Used in Case to match for any input. More...
 
constexpr Index_< 0 > _1
 
constexpr Index_< 9 > _10
 
constexpr Index_< 10 > _11
 
constexpr Index_< 11 > _12
 
constexpr Index_< 12 > _13
 
constexpr Index_< 13 > _14
 
constexpr Index_< 14 > _15
 
constexpr Index_< 15 > _16
 
constexpr Index_< 16 > _17
 
constexpr Index_< 17 > _18
 
constexpr Index_< 18 > _19
 
constexpr Index_< 1 > _2
 
constexpr Index_< 19 > _20
 
constexpr Index_< 20 > _21
 
constexpr Index_< 21 > _22
 
constexpr Index_< 22 > _23
 
constexpr Index_< 23 > _24
 
constexpr Index_< 24 > _25
 
constexpr Index_< 25 > _26
 
constexpr Index_< 26 > _27
 
constexpr Index_< 27 > _28
 
constexpr Index_< 28 > _29
 
constexpr Index_< 2 > _3
 
constexpr Index_< 29 > _30
 
constexpr Index_< 3 > _4
 
constexpr Index_< 4 > _5
 
constexpr Index_< 5 > _6
 
constexpr Index_< 6 > _7
 
constexpr Index_< 7 > _8
 
constexpr Index_< 8 > _9
 
template<typename T >
concept Callable = details::is_callable_v< T >
 
template<typename T >
concept ComparableExceptAnyAndVariant
 
template<typename T >
concept Condition
 
static constexpr Fallthrough fallthrough_
 Indicates fall through from previous Case without testing condition of following Case. More...
 
template<typename T >
concept has_type = requires{ typename T::type; }
 
template<typename T >
concept has_value = requires{ T::value; }
 
template<typename T >
concept Index = requires( T ){ std::decay_t< T >::eswitch_index; }
 
template<typename T >
concept IsCndPredicate = details::is_predicate_v< std::decay_t< T > >
 
template<typename T >
concept IsNotCndPredicate = !IsCndPredicate< T >
 
template<typename T >
concept NoneIndex = ( Index< T > == false )
 
template<typename T >
concept ReturnValueNoneVoid
 
template<typename T >
concept StdPair = details::is_std_pair_v< T >
 
template<typename T >
concept StdTuple = details::is_std_tuple_v< T >