diff --git a/include/utl/meta/selection.h b/include/utl/meta/selection.h index 15fe781..88bfc0b 100644 --- a/include/utl/meta/selection.h +++ b/include/utl/meta/selection.h @@ -67,6 +67,24 @@ namespace meta{ using if_ = if_c; //! @} + + /*! + * Named type selectors + */ + //! @{ + + //! Select the first type of a type sequence + template + struct first_of { + using type = T1; + }; + //! Select the second type of a type sequence + template + struct second_of { + using type = T2; + }; + + //! @} }} //! @} diff --git a/include/utl/meta/sfinae.h b/include/utl/meta/sfinae.h index 27f775c..3464932 100644 --- a/include/utl/meta/sfinae.h +++ b/include/utl/meta/sfinae.h @@ -34,13 +34,21 @@ namespace meta { //! Tool to enable a partial specialization only if a boolean condition is true. //! @{ namespace detail { - template - struct when_ { }; - template <> struct when_ { using type = void; }; + template + struct dev_null { using type = dev_null; }; //< Same as typelist + + template struct when_ { }; + template <> struct when_ { using type = void; }; } //! Well formed only if \p If is true template using when = type_>; + + //! Well formed only if all of \p Ifs are \c true + template + using when_all = detail::dev_null< + when... + >; //! @} //! select _Tp if \p If is true, else SFINAE @@ -59,11 +67,15 @@ namespace meta { //! Publicly recognized alias template for enable_if template - using enable_if_t = type_>; + using enable_if_t = type_< + enable_if + >; //! Uniform alias template for use_if template - using use_if_t = type_>; + using use_if_t = type_< + enable_if + >; //! @} }}