模板显式特化的 C++ 措辞

标签 c++ templates language-lawyer

如果我们考虑函数模板重载,C++ 中的标准行为是首先选择“最特殊”的重载(在基本模板之外)。 下一步是查看所选重载是否明确特化。如果是,将选择匹配的显式特化。

您能否指出标准中定义第二步的地方(上一段中突出显示的部分)?

谢谢。

最佳答案

如果我理解正确,那么您可能指的是来自 [temp.inst§4] 的内容:

Unless a function template specialization has been explicitly instantiated or explicitly specialized, the function template specialization is implicitly instantiated when the specialization is referenced in a context that requires a function definition to exist or if the existence of the definition affects the semantics of the program [...]

通过否定的方式,表示显式特化获得优先权。

关于模板显式特化的 C++ 措辞,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52271780/

相关文章:

c++ - 带有枚举解释的隐式非运算符(!)?

c++ - Arduino PinChangeInt.h 产生编译器错误

c++ - 使用无效方法实例化类模板

c++ - 类不能被 boost::python 包装

c++ - (不完全)constexpr 模板参数的要求

c++ - 静态成员初始化期间访问私有(private)静态函数

C++ 程序在链接期间获取对动态 C 库的 undefined reference

c++ - Apple LLVM 4.2 段错误使用基于范围的循环和引用

javascript - 如何判断属性是否存在且为假

c++ - 在单独的线程中与类型的构造函数并行运行成员函数是否是未定义的行为?