草庐IT

c++ - 类模板特化偏序和函数综合

选择哪个类模板特化是首选的规则包括将特化重写为函数模板,并通过函数模板的排序规则[temp.class.order]确定哪个函数模板更特化。考虑这个例子,然后:#includetemplatestructvoider{usingtype=void;};templateusingvoid_t=typenamevoider::type;templatestructA{};templateintfoo(A>){return1;}templateintfoo(A){return2;}intmain(){std::cout{});}gcc和clang都打印2这里。这在前面的一些示例中是有意义的-

c++ - 类模板特化偏序和函数综合

选择哪个类模板特化是首选的规则包括将特化重写为函数模板,并通过函数模板的排序规则[temp.class.order]确定哪个函数模板更特化。考虑这个例子,然后:#includetemplatestructvoider{usingtype=void;};templateusingvoid_t=typenamevoider::type;templatestructA{};templateintfoo(A>){return1;}templateintfoo(A){return2;}intmain(){std::cout{});}gcc和clang都打印2这里。这在前面的一些示例中是有意义的-
12