forked from OctaForge/libostd
more type traits cleanups
parent
1aeebb69a7
commit
49188f78ea
|
@ -24,8 +24,6 @@ namespace detail {
|
|||
template<typename ...> struct CommonTypeBase;
|
||||
}
|
||||
|
||||
template<typename> struct __OctaAddLr;
|
||||
template<typename> struct __OctaAddRr;
|
||||
template<typename> struct __OctaAddConst;
|
||||
template<typename> struct IsReference;
|
||||
template<typename> struct __OctaRemoveReference;
|
||||
|
@ -36,10 +34,10 @@ namespace detail {
|
|||
using RemoveCv = typename octa::detail::RemoveCv<_T>::Type;
|
||||
|
||||
template<typename _T>
|
||||
using AddLvalueReference = typename __OctaAddLr<_T>::Type;
|
||||
using AddLvalueReference = typename octa::detail::AddLr<_T>::Type;
|
||||
|
||||
template<typename _T>
|
||||
using AddRvalueReference = typename __OctaAddRr<_T>::Type;
|
||||
using AddRvalueReference = typename octa::detail::AddRr<_T>::Type;
|
||||
|
||||
template<typename _T>
|
||||
using AddConst = typename __OctaAddConst<_T>::Type;
|
||||
|
@ -56,12 +54,12 @@ namespace detail {
|
|||
|
||||
/* integral constant */
|
||||
|
||||
template<typename _T, _T __val>
|
||||
template<typename _T, _T val>
|
||||
struct IntegralConstant {
|
||||
static constexpr _T value = __val;
|
||||
static constexpr _T value = val;
|
||||
|
||||
typedef _T Value;
|
||||
typedef IntegralConstant<_T, __val> Type;
|
||||
typedef IntegralConstant<_T, val> Type;
|
||||
|
||||
constexpr operator Value() const { return value; }
|
||||
constexpr Value operator()() const { return value; }
|
||||
|
@ -74,54 +72,62 @@ namespace detail {
|
|||
|
||||
/* is void */
|
||||
|
||||
template<typename _T> struct __OctaIsVoid : False {};
|
||||
template< > struct __OctaIsVoid<void>: True {};
|
||||
namespace detail {
|
||||
template<typename _T> struct IsVoidBase : False {};
|
||||
template< > struct IsVoidBase<void>: True {};
|
||||
}
|
||||
|
||||
template<typename _T>
|
||||
struct IsVoid: __OctaIsVoid<RemoveCv<_T>> {};
|
||||
struct IsVoid: octa::detail::IsVoidBase<RemoveCv<_T>> {};
|
||||
|
||||
/* is null pointer */
|
||||
|
||||
template<typename> struct __OctaIsNullPointer : False {};
|
||||
template< > struct __OctaIsNullPointer<nullptr_t>: True {};
|
||||
namespace detail {
|
||||
template<typename> struct IsNullPointerBase : False {};
|
||||
template< > struct IsNullPointerBase<nullptr_t>: True {};
|
||||
}
|
||||
|
||||
template<typename _T> struct IsNullPointer:
|
||||
__OctaIsNullPointer<RemoveCv<_T>> {};
|
||||
octa::detail::IsNullPointerBase<RemoveCv<_T>> {};
|
||||
|
||||
/* is integer */
|
||||
|
||||
template<typename _T> struct __OctaIsIntegral: False {};
|
||||
namespace detail {
|
||||
template<typename _T> struct IsIntegralBase: False {};
|
||||
|
||||
template<> struct __OctaIsIntegral<bool >: True {};
|
||||
template<> struct __OctaIsIntegral<char >: True {};
|
||||
template<> struct __OctaIsIntegral<uchar >: True {};
|
||||
template<> struct __OctaIsIntegral<schar >: True {};
|
||||
template<> struct __OctaIsIntegral<short >: True {};
|
||||
template<> struct __OctaIsIntegral<ushort>: True {};
|
||||
template<> struct __OctaIsIntegral<int >: True {};
|
||||
template<> struct __OctaIsIntegral<uint >: True {};
|
||||
template<> struct __OctaIsIntegral<long >: True {};
|
||||
template<> struct __OctaIsIntegral<ulong >: True {};
|
||||
template<> struct __OctaIsIntegral<llong >: True {};
|
||||
template<> struct __OctaIsIntegral<ullong>: True {};
|
||||
template<> struct IsIntegralBase<bool >: True {};
|
||||
template<> struct IsIntegralBase<char >: True {};
|
||||
template<> struct IsIntegralBase<uchar >: True {};
|
||||
template<> struct IsIntegralBase<schar >: True {};
|
||||
template<> struct IsIntegralBase<short >: True {};
|
||||
template<> struct IsIntegralBase<ushort>: True {};
|
||||
template<> struct IsIntegralBase<int >: True {};
|
||||
template<> struct IsIntegralBase<uint >: True {};
|
||||
template<> struct IsIntegralBase<long >: True {};
|
||||
template<> struct IsIntegralBase<ulong >: True {};
|
||||
template<> struct IsIntegralBase<llong >: True {};
|
||||
template<> struct IsIntegralBase<ullong>: True {};
|
||||
|
||||
template<> struct __OctaIsIntegral<char16_t>: True {};
|
||||
template<> struct __OctaIsIntegral<char32_t>: True {};
|
||||
template<> struct __OctaIsIntegral< wchar_t>: True {};
|
||||
template<> struct IsIntegralBase<char16_t>: True {};
|
||||
template<> struct IsIntegralBase<char32_t>: True {};
|
||||
template<> struct IsIntegralBase< wchar_t>: True {};
|
||||
}
|
||||
|
||||
template<typename _T>
|
||||
struct IsIntegral: __OctaIsIntegral<RemoveCv<_T>> {};
|
||||
struct IsIntegral: octa::detail::IsIntegralBase<RemoveCv<_T>> {};
|
||||
|
||||
/* is floating point */
|
||||
|
||||
template<typename _T> struct __OctaIsFloatingPoint: False {};
|
||||
namespace detail {
|
||||
template<typename _T> struct IsFloatingPointBase: False {};
|
||||
|
||||
template<> struct __OctaIsFloatingPoint<float >: True {};
|
||||
template<> struct __OctaIsFloatingPoint<double >: True {};
|
||||
template<> struct __OctaIsFloatingPoint<ldouble>: True {};
|
||||
template<> struct IsFloatingPointBase<float >: True {};
|
||||
template<> struct IsFloatingPointBase<double >: True {};
|
||||
template<> struct IsFloatingPointBase<ldouble>: True {};
|
||||
}
|
||||
|
||||
template<typename _T>
|
||||
struct IsFloatingPoint: __OctaIsFloatingPoint<RemoveCv<_T>> {};
|
||||
struct IsFloatingPoint: octa::detail::IsFloatingPointBase<RemoveCv<_T>> {};
|
||||
|
||||
/* is array */
|
||||
|
||||
|
@ -131,11 +137,13 @@ namespace detail {
|
|||
|
||||
/* is pointer */
|
||||
|
||||
template<typename > struct __OctaIsPointer : False {};
|
||||
template<typename _T> struct __OctaIsPointer<_T *>: True {};
|
||||
namespace detail {
|
||||
template<typename > struct IsPointerBase : False {};
|
||||
template<typename _T> struct IsPointerBase<_T *>: True {};
|
||||
}
|
||||
|
||||
template<typename _T>
|
||||
struct IsPointer: __OctaIsPointer<RemoveCv<_T>> {};
|
||||
struct IsPointer: octa::detail::IsPointerBase<RemoveCv<_T>> {};
|
||||
|
||||
/* is lvalue reference */
|
||||
|
||||
|
@ -205,40 +213,46 @@ template<typename _T> struct IsFunction: octa::detail::IsFunctionBase<_T> {};
|
|||
|
||||
/* is pointer to member */
|
||||
|
||||
namespace detail {
|
||||
template<typename>
|
||||
struct __OctaIsMemberPointer: False {};
|
||||
struct IsMemberPointerBase: False {};
|
||||
|
||||
template<typename _T, typename _U>
|
||||
struct __OctaIsMemberPointer<_T _U::*>: True {};
|
||||
struct IsMemberPointerBase<_T _U::*>: True {};
|
||||
}
|
||||
|
||||
template<typename _T>
|
||||
struct IsMemberPointer: __OctaIsMemberPointer<RemoveCv<_T>> {};
|
||||
struct IsMemberPointer: octa::detail::IsMemberPointerBase<RemoveCv<_T>> {};
|
||||
|
||||
/* is pointer to member object */
|
||||
|
||||
namespace detail {
|
||||
template<typename>
|
||||
struct __OctaIsMemberObjectPointer: False {};
|
||||
struct IsMemberObjectPointerBase: False {};
|
||||
|
||||
template<typename _T, typename _U>
|
||||
struct __OctaIsMemberObjectPointer<_T _U::*>: IntegralConstant<bool,
|
||||
!IsFunction<_T>::value
|
||||
struct IsMemberObjectPointerBase<_T _U::*>: IntegralConstant<bool,
|
||||
!octa::IsFunction<_T>::value
|
||||
> {};
|
||||
}
|
||||
|
||||
template<typename _T> struct IsMemberObjectPointer:
|
||||
__OctaIsMemberObjectPointer<RemoveCv<_T>> {};
|
||||
octa::detail::IsMemberObjectPointerBase<RemoveCv<_T>> {};
|
||||
|
||||
/* is pointer to member function */
|
||||
|
||||
namespace detail {
|
||||
template<typename>
|
||||
struct __OctaIsMemberFunctionPointer: False {};
|
||||
struct IsMemberFunctionPointerBase: False {};
|
||||
|
||||
template<typename _T, typename _U>
|
||||
struct __OctaIsMemberFunctionPointer<_T _U::*>: IntegralConstant<bool,
|
||||
IsFunction<_T>::value
|
||||
struct IsMemberFunctionPointerBase<_T _U::*>: IntegralConstant<bool,
|
||||
octa::IsFunction<_T>::value
|
||||
> {};
|
||||
}
|
||||
|
||||
template<typename _T> struct IsMemberFunctionPointer:
|
||||
__OctaIsMemberFunctionPointer<RemoveCv<_T>> {};
|
||||
octa::detail::IsMemberFunctionPointerBase<RemoveCv<_T>> {};
|
||||
|
||||
/* is reference */
|
||||
|
||||
|
@ -753,39 +767,43 @@ namespace detail {
|
|||
|
||||
/* add lvalue reference */
|
||||
|
||||
template<typename _T> struct __OctaAddLr { typedef _T &Type; };
|
||||
template<typename _T> struct __OctaAddLr<_T &> { typedef _T &Type; };
|
||||
template<typename _T> struct __OctaAddLr<_T &&> { typedef _T &Type; };
|
||||
template<> struct __OctaAddLr<void> {
|
||||
namespace detail {
|
||||
template<typename _T> struct AddLr { typedef _T &Type; };
|
||||
template<typename _T> struct AddLr<_T &> { typedef _T &Type; };
|
||||
template<typename _T> struct AddLr<_T &&> { typedef _T &Type; };
|
||||
template<> struct AddLr<void> {
|
||||
typedef void Type;
|
||||
};
|
||||
template<> struct __OctaAddLr<const void> {
|
||||
template<> struct AddLr<const void> {
|
||||
typedef const void Type;
|
||||
};
|
||||
template<> struct __OctaAddLr<volatile void> {
|
||||
template<> struct AddLr<volatile void> {
|
||||
typedef volatile void Type;
|
||||
};
|
||||
template<> struct __OctaAddLr<const volatile void> {
|
||||
template<> struct AddLr<const volatile void> {
|
||||
typedef const volatile void Type;
|
||||
};
|
||||
}
|
||||
|
||||
/* add rvalue reference */
|
||||
|
||||
template<typename _T> struct __OctaAddRr { typedef _T &&Type; };
|
||||
template<typename _T> struct __OctaAddRr<_T &> { typedef _T &&Type; };
|
||||
template<typename _T> struct __OctaAddRr<_T &&> { typedef _T &&Type; };
|
||||
template<> struct __OctaAddRr<void> {
|
||||
namespace detail {
|
||||
template<typename _T> struct AddRr { typedef _T &&Type; };
|
||||
template<typename _T> struct AddRr<_T &> { typedef _T &&Type; };
|
||||
template<typename _T> struct AddRr<_T &&> { typedef _T &&Type; };
|
||||
template<> struct AddRr<void> {
|
||||
typedef void Type;
|
||||
};
|
||||
template<> struct __OctaAddRr<const void> {
|
||||
template<> struct AddRr<const void> {
|
||||
typedef const void Type;
|
||||
};
|
||||
template<> struct __OctaAddRr<volatile void> {
|
||||
template<> struct AddRr<volatile void> {
|
||||
typedef volatile void Type;
|
||||
};
|
||||
template<> struct __OctaAddRr<const volatile void> {
|
||||
template<> struct AddRr<const volatile void> {
|
||||
typedef const volatile void Type;
|
||||
};
|
||||
}
|
||||
|
||||
/* remove extent */
|
||||
|
||||
|
|
Loading…
Reference in New Issue