meta: when_all added and minor changes to selection.h
This commit is contained in:
parent
bb35115359
commit
8fef779a91
@ -67,6 +67,24 @@ namespace meta{
|
|||||||
using if_ = if_c<If::type::value, Args...>;
|
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;
|
||||||
|
};
|
||||||
|
|
||||||
|
//! @}
|
||||||
}}
|
}}
|
||||||
|
|
||||||
//! @}
|
//! @}
|
||||||
|
@ -34,13 +34,21 @@ namespace meta {
|
|||||||
//! Tool to enable a partial specialization only if a boolean condition is true.
|
//! Tool to enable a partial specialization only if a boolean condition is true.
|
||||||
//! @{
|
//! @{
|
||||||
namespace detail {
|
namespace detail {
|
||||||
template <bool If>
|
template <typename... T>
|
||||||
struct when_ { };
|
struct dev_null { using type = dev_null; }; //< Same as typelist
|
||||||
template <> struct when_<true> { using type = void; };
|
|
||||||
|
template <bool If> struct when_ { };
|
||||||
|
template <> struct when_<true> { using type = void; };
|
||||||
}
|
}
|
||||||
//! Well formed only if \p If is true
|
//! Well formed only if \p If is true
|
||||||
template <bool If>
|
template <bool If>
|
||||||
using when = type_<detail::when_<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
|
//! select _Tp if \p If is true, else SFINAE
|
||||||
@ -59,11 +67,15 @@ namespace meta {
|
|||||||
|
|
||||||
//! Publicly recognized alias template for enable_if
|
//! Publicly recognized alias template for enable_if
|
||||||
template<bool If, typename _Tp = void>
|
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
|
//! Uniform alias template for use_if
|
||||||
template<bool If, typename _Tp = void>
|
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…
x
Reference in New Issue
Block a user