Search code examples
c++namespacesusing

How to select a single overload of a function with using namespace::function in C++?


consider the following C++ code.

namespace A {
    void f() { // first function
    }

    void f(int) { // second function
    }
}
...
using A::f; // introduces both functions

Is there a way to introduce only one function?


Solution

  • That behavior is well-defined in the Standard.

    C++03 7.3.3 The using declaration:

    "...If the name is that of an overloaded member function, then all functions named shall be accessible.".