Browse Source

Add trait to detect template specialization

Useful to check for std::tuple
feature/exec_app
Martchus 5 years ago
parent
commit
df1605c9b1
  1. 9
      misc/traits.h

9
misc/traits.h

@ -20,28 +20,29 @@ using Not = Bool<!T::value>;
template <typename... T>
struct Any : Bool<false> {};
template <typename Head, typename... Tail>
struct Any<Head, Tail...> : Conditional<Head, Bool<true>, Any<Tail...> > {};
template <typename... T>
struct All : Bool<true> {};
template <typename Head, typename... Tail>
struct All<Head, Tail...> : Conditional<Head, All<Tail...>, Bool<false> > {};
template <typename... Condition>
using EnableIf = typename std::enable_if<All<Condition...>::value, Detail::Enabler>::type;
template <typename... Condition>
using DisableIf = typename std::enable_if<!All<Condition...>::value, Detail::Enabler>::type;
template <typename... Condition>
using EnableIfAny = typename std::enable_if<Any<Condition...>::value, Detail::Enabler>::type;
template <typename... Condition>
using DisableIfAny = typename std::enable_if<!Any<Condition...>::value, Detail::Enabler>::type;
template <typename T, template <typename...> class Template>
struct IsSpecializationOf : Bool<false> {};
template <template <typename...> class Template, typename... Args>
struct IsSpecializationOf<Template<Args...>, Template> : Bool<true> {};
}
#endif // CPP_UTILITIES_TRAITS_H

Loading…
Cancel
Save