eswitch-v5
Advanced counterpart for switch statement in C++
eswitch_v5.hpp File Reference

implementation which enhance switch statement More...

Go to the source code of this file.

Classes

class  eswitch_v5::condition< CmpOperator, TIndex, CaseEntry >
 Compares value with corresponding entry in std::tuple. More...
 
class  eswitch_v5::condition< CmpOperator, TIndex, CaseEntry >
 Compares value with corresponding entry in std::tuple. More...
 
struct  eswitch_v5::condition_with_predicate< Cnd, Func >
 
class  eswitch_v5::conditions< LogicalOperator, Cnds >
 Container which holds arbitrary number of condition. More...
 
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... > >
 
class  eswitch_v5::eswitch_impl< Args >
 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  eswitch_v5::eswitch_impl< Args >::Padding
 
struct  eswitch_v5::extension::any
 
struct  eswitch_v5::extension::Any_from_impl< T, Sz >
 
class  eswitch_v5::extension::Range< RangeType >
 
struct  eswitch_v5::Fallthrough
 
struct  eswitch_v5::Index_< Idx >
 This structure is used as a reference to a specific parameter inside eswitch. More...
 
struct  eswitch_v5::is< T >
 Used to match for type of active entry in std::any, std::variant<...> and polymorphic types. More...
 
struct  eswitch_v5::is< T >
 Used to match for type of active entry in std::any, std::variant<...> and polymorphic types. More...
 
class  eswitch_v5::predicate_condition< TPred, Is >
 
class  eswitch_v5::predicate_condition< TPred, Is >
 
struct  eswitch_v5::regexter
 

Namespaces

 eswitch_v5
 
 eswitch_v5::details
 
 eswitch_v5::extension
 

Macros

#define Case(...)   case_( __VA_ARGS__ ) % [&]
 Accepts conditions of various forms. More...
 
#define Default   ( _1 == extension::any{} ) % [&]
 Declares body which will be executed in case of no other matches. More...
 

Typedefs

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

Enumerations

enum  eswitch_v5::Comparison_operators {
  eswitch_v5::Comparison_operators::equal, eswitch_v5::Comparison_operators::not_equal, eswitch_v5::Comparison_operators::greater, eswitch_v5::Comparison_operators::greater_or_equal,
  eswitch_v5::Comparison_operators::less, eswitch_v5::Comparison_operators::less_or_equal
}
 
enum  eswitch_v5::Logical_operators { eswitch_v5::Logical_operators::and_, eswitch_v5::Logical_operators::or_ }
 
enum  eswitch_v5::extension::range { eswitch_v5::extension::range::open, eswitch_v5::extension::range::close }
 

Functions

template<typename ... Args>
static constexpr auto eswitch_v5::any_from (Args &&... args)
 Helper function which allows to find if something is within the list( passed arguments ). More...
 
template<typename ... Args>
 eswitch_v5::extension::Any_from_impl (Args &&...) -> Any_from_impl< std::common_type_t< std::decay_t< Args >... >, sizeof...(Args) >
 
template<Condition Cnd>
static constexpr auto eswitch_v5::case_ (Cnd &&cnd)
 
template<typename ... Ts>
static constexpr auto eswitch_v5::case_ (Ts &&... values)
 
template<typename P , std::size_t ... I, Index Idx>
predicate_condition< P, I..., Idx::eswitch_index > eswitch_v5::compose_new_predicate_condition_type (const predicate_condition< P, I... > &, Idx)
 
template<typename T , typename F >
 eswitch_v5::condition_with_predicate (T, F) -> condition_with_predicate< T, F >
 
template<std::size_t ... Is, typename Tup >
static constexpr auto eswitch_v5::details::create_indexed_condition (Tup &&values)
 
template<StdPair T>
static constexpr auto eswitch_v5::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_v5::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_v5::eswitch_impl (Ts &&...) -> eswitch_impl< Ts... >
 
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)
 
template<Index Idx, typename T >
constexpr auto eswitch_v5::operator!= (Idx &&, T &&rhv)
 
auto eswitch_v5::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 eswitch_v5::operator% (T &&cnd, Func &&f)
 
template<Condition Cnd1, Condition Cnd2>
static constexpr auto eswitch_v5::operator&& (Cnd1 &&cnd1, Cnd2 &&cnd2)
 
template<Condition ... Cnds, Condition Cnd>
static constexpr auto eswitch_v5::operator&& (conditions< Logical_operators::and_, Cnds... > &&cnds, Cnd &&cnd)
 
template<IsNotCndPredicate Pred, Index Idx>
static constexpr auto eswitch_v5::operator, (Pred &&pred, Idx)
 
template<typename R , typename... Args, Index Idx>
static constexpr auto eswitch_v5::operator, (R(*pred)(Args...), Idx)
 
template<Index Idx, typename T >
constexpr auto eswitch_v5::operator< (Idx &&, T &&rhv)
 
template<Index Idx, typename T >
constexpr auto eswitch_v5::operator<= (Idx &&, T &&rhv)
 
static auto eswitch_v5::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 eswitch_v5::operator== (Idx &&, T &&rhv)
 
template<typename TupleEntry , typename UnderlyingType >
static constexpr auto eswitch_v5::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 eswitch_v5::operator> (Idx &&, T &&rhv)
 
template<Index Idx, typename T >
constexpr auto eswitch_v5::operator>= (Idx &&, T &&rhv)
 
template<typename Cnd , ReturnValueNoneVoid Func>
static constexpr auto eswitch_v5::operator^ (condition_with_predicate< Cnd, Func > &&cp, const Fallthrough &)
 
template<Condition Cnd1, Condition Cnd2>
static constexpr auto eswitch_v5::operator|| (Cnd1 &&cnd1, Cnd2 &&cnd2)
 
template<Condition ... Cnds, Condition Cnd>
static constexpr auto eswitch_v5::operator|| (conditions< Logical_operators::or_, Cnds... > &&cnds, Cnd &&cnd)
 
static constexpr bool eswitch_v5::details::unreachable ()
 

Variables

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

Detailed Description

implementation which enhance switch statement

Definition in file eswitch_v5.hpp.