20template <
typename If,
typename Then,
typename Else>
using Conditional =
typename std::conditional<If::value, Then, Else>::type;
23template <
bool B,
typename...>
struct Bool : std::integral_constant<bool, B> {};
29template <
typename... T>
struct Any :
Bool<false> {};
31template <
typename Head,
typename... Tail>
struct Any<Head, Tail...> :
Conditional<Head, Bool<true>, Any<Tail...>> {};
34template <
typename... T>
struct All :
Bool<true> {};
36template <
typename Head,
typename... Tail>
struct All<Head, Tail...> :
Conditional<Head, All<Tail...>, Bool<false>> {};
39template <
typename... T>
struct None :
Bool<true> {};
41template <
typename Head,
typename... Tail>
struct None<Head, Tail...> :
Conditional<Head, Bool<false>, None<Tail...>> {};
44template <
typename... Condition>
using EnableIf =
typename std::enable_if<
All<Condition...>::value, Detail::Enabler>::type;
46template <
typename... Condition>
using DisableIf =
typename std::enable_if<!
All<Condition...>::value, Detail::Enabler>::type;
49template <
typename... Condition>
using EnableIfAny =
typename std::enable_if<
Any<Condition...>::value, Detail::Enabler>::type;
51template <
typename... Condition>
using DisableIfAny =
typename std::enable_if<!
Any<Condition...>::value, Detail::Enabler>::type;
55template <
typename T,
template <
typename...>
class Template>
struct IsSpecializationOfHelper :
Bool<false> {};
56template <
template <
typename...>
class Template,
typename... Args>
struct IsSpecializationOfHelper<Template<Args...>, Template> :
Bool<true> {};
60template <
typename Type,
template <
typename...>
class... TemplateTypes>
62 : Detail::IsSpecializationOfHelper<typename std::remove_cv<typename std::remove_reference<Type>::type>::type, TemplateTypes...> {};
66template <
typename Type,
template <
typename...>
class TemplateType,
template <
typename...>
class... RemainingTemplateTypes>
68 :
Conditional<IsSpecializationOf<Type, TemplateType>, Bool<true>, IsSpecializingAnyOf<Type, RemainingTemplateTypes...>> {};
73template <
typename Type,
typename OtherType,
typename... RemainingTypes>
74struct IsAnyOf<Type, OtherType, RemainingTypes...> :
Conditional<std::is_same<Type, OtherType>, Bool<true>, IsAnyOf<Type, RemainingTypes...>> {};
78template <
typename Type,
typename OtherType,
typename... RemainingTypes>
79struct IsNoneOf<Type, OtherType, RemainingTypes...> :
Conditional<std::is_same<Type, OtherType>, Bool<false>, IsNoneOf<Type, RemainingTypes...>> {};
84 :
Bool<std::is_same<char const *, typename std::decay<T>::type>::value || std::is_same<char *, typename std::decay<T>::type>::value> {};
89 :
Bool<IsCString<T>::value || IsSpecializationOf<T, std::basic_string>::value || IsSpecializationOf<T, std::basic_string_view>::value> {};
94template <
typename T>
struct IsComplete<T, decltype(void(sizeof(T)))> :
Bool<true> {};
100#define CPP_UTILITIES_PP_COMMA ,
108#define CPP_UTILITIES_TRAITS_DEFINE_TYPE_CHECK(CheckName, CheckCode) \
110 template <typename T> auto CheckName(int) -> decltype(CheckCode, ::CppUtilities::Traits::Bool<true>{}); \
111 template <typename T>::CppUtilities::Traits::Bool<false> CheckName(...); \
113 template <typename T> using CheckName = decltype(Detail::CheckName<T>(0))
133 std::begin(std::declval<T &>())
140 void(*begin(std::declval<T &>())));
143template <
typename T, EnableIf<IsDereferencable<T>> * =
nullptr>
constexpr auto &
dereferenceMaybe(T &&value)
149template <
typename T, DisableIf<IsDereferencable<T>> * =
nullptr>
constexpr auto &
dereferenceMaybe(T &&value)
typename std::enable_if<!Any< Condition... >::value, Detail::Enabler >::type DisableIfAny
Shortcut for std::enable_if to apply Traits::Any, negate the condition and omit ::value and ::type.