Browse Source

meta: FIX sfinae idiom in use_* aliases

doc
Christos Houtouridis 6 years ago
parent
commit
7e25067468
2 changed files with 15 additions and 56 deletions
  1. +0
    -4
      include/utl/meta/if.h
  2. +15
    -52
      include/utl/meta/sfinae.h

+ 0
- 4
include/utl/meta/if.h View File

@@ -53,10 +53,6 @@ namespace utl {
template<typename _Tp> // Partial specialization for false.
struct if_ <false, _Tp> { };
//! Alias template for if_
template<bool _C, typename _Tp = void>
using if_t = typename if_<_C, _Tp>::type;
//! @}
}
//! @}


+ 15
- 52
include/utl/meta/sfinae.h View File

@@ -54,71 +54,34 @@ namespace utl {
using void_t = typename void_t_impl<_Ts...>::type;
//! @}
//! Alias template for if_
template<bool _C, typename _Tp = void>
using if_t = typename if_<_C, _Tp>::type;
//! Publicly recognized alias template for if_
template<bool _C, typename _Tp = void>
using enable_if_t = typename if_<_C, _Tp>::type;
//! Uniform alias template for if_
template<bool _C, typename _Tp = void>
using use_if_t = typename if_<_C, _Tp>::type;
//! If same type resolves to _Ret, else SFINAE
//! @{
template <typename _T1, typename _T2, typename _Ret =_T1>
struct use_if_same_ {
using type = if_t <
same_<_T1, _T2>::value,
_Ret
>;
};
template <typename _T1, typename _T2, typename _Ret =_T1>
using use_if_same_t = typename use_if_same_<_T1, _T2, _Ret>::type;
//! @}
using use_if_same_t = typename if_<same_<_T1, _T2>::value, _Ret>::type;
//! If not same type resolves to _Ret, else SFINAE
//! @{
template <typename _T1, typename _T2, typename _Ret =_T1>
struct use_if_not_same_ {
using type = if_t <
!same_<_T1, _T2>::value,
_Ret
>;
};
template <typename _T1, typename _T2, typename _Ret =_T1>
using use_if_not_same_t = typename use_if_not_same_<_T1, _T2, _Ret>::type;
//! @}
using use_if_not_same_t = typename if_<!same_<_T1, _T2>::value, _Ret>::type;
//! If any type (_T1 or _T2) type resolves to _Ret, else to SFINAE
//! @{
template <typename _T1, typename _T2, typename _Ret =_T1>
struct use_if_any_ {
using type = if_t <
or_<_T1, _T2>::value,
_Ret
>;
};
template <typename _T1, typename _T2, typename _Ret =_T1>
using use_if_any_t = typename use_if_any_<_T1, _T2, _Ret>::type;
//! @}
using use_if_any_t = typename if_<or_<_T1, _T2>::value, _Ret>::type;
//! If both type (_T1 and _T2) type resolves to _Ret, else to SFINAE
//! @{
template <typename _T1, typename _T2, typename _Ret =_T1>
struct use_if_both_ {
using type = if_t <
and_<_T1, _T2>::value,
_Ret
>;
};
template <typename _T1, typename _T2, typename _Ret =_T1>
using use_if_both_t = typename use_if_both_<_T1, _T2, _Ret>::type;
//! @}
using use_if_both_t = typename if_<and_<_T1, _T2>::value, _Ret>::type;
//! Publicly recognized alias template for if_t
template<bool _C, typename _Tp = void>
using enable_if_t = typename if_<_C, _Tp>::type;
//! Uniform use_ style alias template for if_t
//!@{
template<bool _C, typename _Tp = void>
using use_if_t = typename if_<_C, _Tp>::type;
//!@{
}
//! @}


Loading…
Cancel
Save