c++ - 通常的非限定查找和依赖于参数的名称查找(ADL)

标签 c++ argument-dependent-lookup name-lookup

对于非限定名称查找,“通常非限定名称查找”和“参数相关名称查找”(ADL),我无法在标准中找到哪一个先发生?

再次尝试向过载候选集添加一些内容,但顺序似乎并不重要。但仍然很高兴知道哪一个先发生。

谢谢

最佳答案

谁先到并不重要,不是吗?名称查找生成一组可能的名称。

3.4 Name lookup
Name lookup may associate more than one declaration with a name if it finds the name to be a function name; the declarations are said to form a set of overloaded functions.

标准专门说“设置”。作为数学构造,集合 {1,2,3} 与 {2,3,1} 和 {3,2,1} 相同。顺序无关紧要。重要的是何时发生重载决议和应用程序访问规则。这里的标准很明确。再次引用 3.4 的介绍段落:

Overload resolution takes place after name lookup has succeeded. The access rules are considered only once name lookup and function overload resolution have succeeded.

关于c++ - 通常的非限定查找和依赖于参数的名称查找(ADL),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12956600/

相关文章:

c++ - 使用 C++20 using-enum-declaration 进行二义性名称查找

被类函数隐藏的 C++ 友元函数?

c++ - 没有用于调用 'merge(std::vector<int>&, std::vector<int>&) 的匹配函数

C++ 在嵌套命名空间内定义外部命名空间的函数

c++ - 匿名命名空间内运算符的模板重载解析

c++ - 派生模板类访问基类成员数据

c++ - 更改 .cpp、.h 文件的 Visual Studio 默认路径

c++ - C++ 中的命名空间和包装

c++ - 没有匹配的函数用于调用 std::list::remove_if( function()::predicate )

C++多重继承私有(private)成员模糊访问