Lookup of dependent names in C++ template instantiation

后端 未结 3 1923
执笔经年
执笔经年 2021-02-07 05:11

When I try to compile this code

// void foobar(int); 

template 
struct Foo {
  void bar(T t) { foobar(t); };
};

void foobar(int);

template clas         


        
3条回答
  •  梦毁少年i
    2021-02-07 05:21

    Phase two lookup only includes name lookup rules that can't be applied in phase one- ADL, for example. Two-phase lookup is exactly that- some names are looked up in phase one, and some are looked up in phase two. This particular kind of name is a phase one name, as the compiler is perfectly capable of looking for foobar in the namespace(s) of the function during phase one.

    Visual C++ does not implement two-phase name lookup.

提交回复
热议问题