如果我们考虑函数模板重载,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/