Browse Source

Add Traits::IsSpecializingAnyOf

consistent_macro_prefix
Martchus 4 years ago
parent
commit
27d5041e06
  1. 6
      misc/traits.h
  2. 5
      tests/traitstests.cpp

6
misc/traits.h

@ -45,6 +45,12 @@ template <typename T, template <typename...> class Template> struct IsSpecializa
};
template <template <typename...> class Template, typename... Args> struct IsSpecializationOf<Template<Args...>, Template> : Bool<true> {
};
template <typename Type, template <typename...> class... TemplateTypes> struct IsSpecializingAnyOf : Bool<false> {
};
template <typename Type, template <typename...> class TemplateType, template <typename...> class... RemainingTemplateTypes>
struct IsSpecializingAnyOf<Type, TemplateType, RemainingTemplateTypes...>
: Conditional<IsSpecializationOf<Type, TemplateType>, Bool<true>, IsSpecializingAnyOf<Type, RemainingTemplateTypes...>> {
};
template <typename... T> struct IsAnyOf : Bool<false> {
};

5
tests/traitstests.cpp

@ -34,6 +34,11 @@ static_assert(None<Bool<false>, Bool<false>>::value, "None: positive case");
static_assert(!IsSpecializationOf<string, basic_stringbuf>::value, "IsSpecializationOf: negative case");
static_assert(IsSpecializationOf<string, basic_string>::value, "IsSpecializationOf: positive case");
static_assert(!IsSpecializingAnyOf<string, basic_stringbuf, vector>::value, "IsSpecializingAnyOf: negative case");
static_assert(!IsSpecializingAnyOf<string, basic_stringbuf, list, vector>::value, "IsSpecializingAnyOf: negative case");
static_assert(IsSpecializingAnyOf<string, basic_stringbuf, basic_string, vector>::value, "IsSpecializingAnyOf: positive case");
static_assert(IsSpecializingAnyOf<string, basic_stringbuf, vector, basic_string>::value, "IsSpecializingAnyOf: positive case");
static_assert(IsSpecializingAnyOf<string, basic_string>::value, "IsSpecializingAnyOf: positive case");
static_assert(IsAnyOf<string, string, int, bool>::value, "IsAnyOf: positive case");
static_assert(IsAnyOf<int, string, int, bool>::value, "IsAnyOf: positive case");

Loading…
Cancel
Save