File match.hpp

Parent directory (include)

Compile-time key -> type matcher (first-match wins).

Definition (include/match.hpp)

Detailed Description

Provides a tiny pattern-matching facility that selects a type based on a compile-time key. You declare alternatives with case_<K, T> and an optional default_<T>. The alias match_t<Key, Alts...> yields the selected T.

Example

usingA=structA_; usingB=structB_; usingD=structD_;

//PicksBbecauseKey==’b’matchesthesecondcase. usingR=:ref:exhale_typedef_match_8hpp_1a7e43839f4a7b91a68bb27d983e8b7ed4`<’b’, :ref:`exhale_struct_structctql_1_1case__`<’a’,A>, :ref:`exhale_struct_structctql_1_1case__`<’b’,B>, :ref:`exhale_struct_structctql_1_1default__>; static_assert(std::is_same_v<R,B>);

//Ifnocasematchesandnodefault_isprovided,resultisvoid: usingR2=:ref:exhale_typedef_match_8hpp_1a7e43839f4a7b91a68bb27d983e8b7ed4>; static_assert(std::is_void_v<R2>);

Keys are compared with == at compile time. This works for integral, enum, and other literal NTTPs that support constexpr equality.

Includes

  • type_traits

Included By

Namespaces

Classes

Typedefs