Browse Source

meta: when_all added and minor changes to selection.h

doc
Christos Houtouridis 5 years ago
parent
commit
8fef779a91
2 changed files with 35 additions and 5 deletions
  1. +18
    -0
      include/utl/meta/selection.h
  2. +17
    -5
      include/utl/meta/sfinae.h

+ 18
- 0
include/utl/meta/selection.h View File

@@ -67,6 +67,24 @@ namespace meta{
using if_ = if_c<If::type::value, Args...>;
//! @}
/*!
* Named type selectors
*/
//! @{
//! Select the first type of a type sequence
template <typename T1, typename ...>
struct first_of {
using type = T1;
};
//! Select the second type of a type sequence
template <typename T1, typename T2, typename ...>
struct second_of {
using type = T2;
};
//! @}
}}
//! @}


+ 17
- 5
include/utl/meta/sfinae.h View File

@@ -34,13 +34,21 @@ namespace meta {
//! Tool to enable a partial specialization only if a boolean condition is true.
//! @{
namespace detail {
template <bool If>
struct when_ { };
template <> struct when_<true> { using type = void; };
template <typename... T>
struct dev_null { using type = dev_null; }; //< Same as typelist
template <bool If> struct when_ { };
template <> struct when_<true> { using type = void; };
}
//! Well formed only if \p If is true
template <bool If>
using when = type_<detail::when_<If>>;
//! Well formed only if all of \p Ifs are \c true
template <bool ...Ifs>
using when_all = detail::dev_null<
when<Ifs>...
>;
//! @}
//! select _Tp if \p If is true, else SFINAE
@@ -59,11 +67,15 @@ namespace meta {
//! Publicly recognized alias template for enable_if
template<bool If, typename _Tp = void>
using enable_if_t = type_<enable_if<If, _Tp>>;
using enable_if_t = type_<
enable_if<If, _Tp>
>;
//! Uniform alias template for use_if
template<bool If, typename _Tp = void>
using use_if_t = type_<enable_if<If, _Tp>>;
using use_if_t = type_<
enable_if<If, _Tp>
>;
//! @}
}}


Loading…
Cancel
Save