lundi 24 août 2015

Why doesn't the generic specialization trait apply to std::vector

I find it interesting that this type trait doesn't match std::array but it works for unordered_map. Why is that?

#include <iostream>
#include <unordered_map>
#include <array>

template <typename T, template <typename...> class Ref>
struct is_specialization : std::false_type {
};

template <template <typename...> class Ref, typename... Args>
struct is_specialization<Ref<Args...>, Ref> : std::true_type {
};

int main()
{
    using T = std::unordered_map<int, int>;
    using C = std::array<int, 2>;
    auto value = is_specialization<T, std::unordered_map>::value;
    std::cout << "Is type of unorderd map specialization? : " << std::boolalpha << value << std::endl;

    auto secondValue = is_specialization<C , std::array>::value;
    std::cout << "Is type of array specialization? : " << std::boolalpha << secondValue << std::endl;
}

Aucun commentaire:

Enregistrer un commentaire