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

MKo picture MKo · Aug 16, 2011 · Viewed 12.4k times · Source

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?

Answer

Eric Z picture Eric Z · Aug 16, 2011

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.".