.. _file_include_match.hpp: File match.hpp ============== |exhale_lsh| :ref:`Parent directory ` (``include``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS Compile-time key -> type matcher (first-match wins). .. contents:: Contents :local: :backlinks: none Definition (``include/match.hpp``) ---------------------------------- .. toctree:: :maxdepth: 1 program_listing_file_include_match.hpp.rst Detailed Description -------------------- Provides a tiny pattern-matching facility that selects a type based on a compile-time key. You declare alternatives with ``case_`` and an optional ``default_``. The alias ``match_t`` 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); //Ifnocasematchesandnodefault_isprovided,resultisvoid: usingR2=:ref:`exhale_typedef_match_8hpp_1a7e43839f4a7b91a68bb27d983e8b7ed4`>; static_assert(std::is_void_v); 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 ----------- - :ref:`file_include_predicates.hpp` Namespaces ---------- - :ref:`namespace_ctql` Classes ------- - :ref:`exhale_struct_structctql_1_1case__` - :ref:`exhale_struct_structctql_1_1default__` Typedefs -------- - :ref:`exhale_typedef_match_8hpp_1a7e43839f4a7b91a68bb27d983e8b7ed4`