Fix Traits::IsSpecializationOf for references

This check is also supposed to work for references so use the same approach
as for ignoring cv qualifiers.
This commit is contained in:
Martchus 2020-06-17 21:41:00 +02:00
parent 74b010cbb9
commit 9d59ab5c29
2 changed files with 6 additions and 2 deletions

View File

@ -65,9 +65,10 @@ template <template <typename...> class Template, typename... Args> struct IsSpec
};
} // namespace Detail
/// \endcond
/// \brief Evaluates to Bool<true> if the specified type is based on the specified \tparam Template; otherwise evaluates to Bool<false>.
/// \brief Evaluates to Bool<true> if the specified type is based on the specified template; otherwise evaluates to Bool<false>.
template <typename Type, template <typename...> class... TemplateTypes>
struct IsSpecializationOf : Detail::IsSpecializationOfHelper<typename std::remove_cv<Type>::type, TemplateTypes...> {
struct IsSpecializationOf
: Detail::IsSpecializationOfHelper<typename std::remove_cv<typename std::remove_reference<Type>::type>::type, TemplateTypes...> {
};
/// \brief Evaluates to Bool<true> if the specified type is based on one of the specified templates; otherwise evaluates to Bool<false>.
template <typename Type, template <typename...> class... TemplateTypes> struct IsSpecializingAnyOf : Bool<false> {

View File

@ -43,6 +43,9 @@ 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(IsSpecializationOf<string &, basic_string>::value, "IsSpecializationOf: positive case");
static_assert(IsSpecializationOf<const string &, basic_string>::value, "IsSpecializationOf: positive case");
static_assert(IsSpecializationOf<volatile 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");