C++中一个名字查找的小知识
最近看C++标准中的3.4 name lookup章节,碰巧的是stackoverflow也有人提问,他们对这个问题很疑惑,回答的也并不好。
https://stackoverflow.com/questions/25672745/friend-declarations-is-this-a-bug-in-clang
其中C++标准中$3.4.1章节有一个例子:
typedef int f;
namespace N {
struct A {
friend void f(A &);
operator int();
void g(A a) {
int i = f(a);
// f is the typedef, not the f