static function lookup from a template function issue with xlC

╄→гoц情女王★ 提交于 2019-11-30 19:28:32

Prior to C++11 this was the correct behavior: unqualified name resolution of names used in templates was defined to only find functions with external linkage.

C++03 section 14.6.4.2 Candidate Functions [temp.dep.candidate] paragraph 1:

For a function call that depends on a template parameter, if the function name is an unqualified-id but not a template-id, the candidate functions are found using the usual lookup rules (3.4.1, 3.4.2) except that:

  • For the part of the lookup using unqualified name lookup (3.4.1), only function declarations with external linkage from the template definition context are found.

  • For the part of the lookup using associated namespaces (3.4.2), only function declarations with external linkage found in either the template definition context or the template instantiation context are found.

which changes in C++11 to:

For a function call that depends on a template parameter, the candidate functions are found using the usual lookup rules (3.4.1, 3.4.2, 3.4.3) except that:

  • For the part of the lookup using unqualified name lookup (3.4.1) or qualified name lookup (3.4.3), only function declarations from the template definition context are found.

  • For the part of the lookup using associated namespaces (3.4.2), only function declarations found in either the template definition context or the template instantiation context are found.

Catherine Morton

V12.1 of the compiler has the new behaviour by default.

If you are using an earlier version of the xlC compiler use option -qdebug=KeepUnqualifiedStaticCandidate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!