devxlogo

Koenig Lookup

Koenig Lookup

Andrew Koenig devised an algorithm for resolving namespace members’ lookup. This algorithm is used in all standard-conforming compilers to handle cases like the following:

  namespace MINE {  class C {};  void func(C);  } MINE::C c; // global object of type MINE::Cvoid main() {  func( c ); // OK, MINE::f called }

No using declaration or using directive exists in the program. Still, the compiler did the right thing by applying Koenig lookup. Koenig lookup instructs the compiler to look not just in the usual places such as the local scope, but also the namespace that contains the argument’s type.

devx-admin

Share the Post: