小编Pas*_*van的帖子

为什么通用特化特征不适用于std :: array

我觉得有趣的是这个类型特征与std :: array不匹配(它给出了编译错误),但它适用于unordered_map.这是为什么?

#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 …
Run Code Online (Sandbox Code Playgroud)

c++ templates variadic-templates c++11

2
推荐指数
1
解决办法
148
查看次数

标签 统计

c++ ×1

c++11 ×1

templates ×1

variadic-templates ×1