【发布时间】:2022-01-14 15:03:25
【问题描述】:
如果函数模板被标记为已删除,是否允许像示例中那样显式实例化它:
template<class T>
int foo(T) = delete;
template int foo(int);
Clang 和 GCC 允许它,而 MSVC 打印错误:
error C2280: 'int foo<int>(int)': attempting to reference a deleted function
演示:https://gcc.godbolt.org/z/49hfqnr4f
哪个编译器在这里?
【问题讨论】:
标签: c++ templates language-lawyer explicit-instantiation deleted-functions