基础后挑选的专业模板 - 为什么

时间:2015-11-22 21:08:57

标签: c++ templates

我有这段代码:

template<typename T> struct Container {};

template <int a, int b, typename T = Container<bool>>
struct temp;

template <int a, int b, typename T>
struct temp<a, b, Container<T>> {
    using type = void;
};

int main()
{

    static_assert(std::is_same<temp<0, 1>::type, void>::value, "error");

}

我的问题是:为什么要实例化更专业的模板?

我原本期待一个错误,例如&#34;无法找到temp&lt; 0,1,Container&gt;&#34;的定义。 (对于基本模板),而是选择更专业的一个......第二轮模板查找&#34;。怎么会发生这种情况?

0 个答案:

没有答案