Adding specializations of template functions later

南笙酒味 提交于 2019-12-06 01:01:11

If you turn your standard (C++98 anyway) to 14.6.4.2/1 you read:

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.

In this case template-id means a <template-params> qualified template-name. This pretty much clearly states exactly what you observed in your program, that only functions visible in the context of the template definition are considered. And when you think about it, if this weren't the case it would be ridiculously easy to change meanings of a template based on what followed it, leading to a violation of the one definition rule.

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