What functions are found

suggest change

Functions are found by first collecting a set of “associated classes” and “associated namespaces” that include one or more of the following, depending on the argument type T. First, let us show the rules for classes, enumeration and class template specialization names.

Now there are a few rules for builtin types as well

Functions and function templates in the associated namespaces are found by argument dependent lookup. In addition, namespace-scope friend functions declared in associated classes are found, which are normally not visible. Using directives are ignored, however.

The calls of f below are valid without qualifying f. The call of g is not.

namespace A {
   struct Z { };
   namespace I { void g(Z); }
   using namespace I;

   struct X { struct Y { }; friend void f(Y) { } };
   void f(X p) { }
   void f(std::shared_ptr<X> p) { }
}

// example calls
f(A::X());
f(A::X::Y());
f(std::make_shared<A::X>());

g(A::Z()); // invalid: "using namespace I;" is ignored!

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents