Created on 2022-03-23.00:00:00 last changed 1 week ago
Proposed resolution (approved by CWG 2025-10-10):
Change in 9.10 [namespace.udecl] paragraph 11 as follows:
The set of declarations named by a using-declarator that inhabits a class C does not include member functions and member function templates of a base class that, when considered as members of C, correspond to(and thus would conflict with)a declaration of a function or function template in C.[ Example:
struct B { virtual void f(int); virtual void f(char); void g(int); void h(int); void i(); void j(); }; struct D : B { using B::f; void f(int); // OK, D::f(int) overrides B::f(int) using B::g; void g(char); // OK using B::h; void h(int); // OK, D::h(int) hides B::h(int) using B::i; void i(this B &); // OK using B::j; void j(this D &); // OK, D::j() hides B::j() }; void k(D* p) { p->f(1); // calls D::f(int) p->f('a'); // calls B::f(char) p->g(1); // calls B::g(int) p->g('a'); // calls D::g(char) p->i(); // calls B::i, because B::i as a member of D is a better match than D::i p->j(); // calls D::j } ...
Consider:
template<int I>
struct C { };
struct B
{
C<1> foo();
C<1> bar();
};
struct D : B
{
using B::foo;
C<2> foo(this B &);
using B::bar;
C<2> bar(this D &);
};
struct DD : D
{
using D::foo;
using D::bar;
};
void bar(D d, DD dd)
{
d.foo();
dd.foo();
d.bar();
dd.bar();
}
Which functions are called?
Subclause 9.10 [namespace.udecl] paragraph 11 specifies:
The set of declarations named by a using-declarator that inhabits a class C does not include member functions and member function templates of a base class that correspond to (and thus would conflict with) a declaration of a function or function template in C.
The definition of "corresponds" considers the type of the implicit object parameter, which is a deviation from the status quo ante for a simple example like this one:
struct B {
void f(); // #1
};
struct D : B {
void f();
using B::f; // should not name #1
};
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2025-11-06 23:04:52 | admin | set | status: tentatively ready -> ready |
| 2025-10-10 20:14:18 | admin | set | status: drafting -> tentatively ready |
| 2023-06-20 06:44:53 | admin | set | status: open -> drafting |
| 2022-03-24 07:45:02 | admin | set | messages: + msg6774 |
| 2022-03-23 00:00:00 | admin | create | |