C++17之前,无法在部分模板特化中使用自动模板参数。例如:
template // primary template
struct my_template {};
template // partial specialization with auto template argument (not allowed prior to C++17)
struct my_template {};
这种情况下,编译器会报错。但在C++17引入了对使用自动模板参数的部分模板特化的支持。可以这样写:
template // primary template
struct my_template {};
template
struct my_template {}; // partial specialization with auto template argument (allowed since C++17)
这样,部分模板特化中使用自动模板参数就可以被正确编译了。
上一篇:部分模板特化失败