Title
A using-declarator should bind a name
Status
open
Section
9.10 [namespace.udecl]
Submitter
Brian Bi

Created on 2025-03-24.00:00:00 last changed 3 weeks ago

Messages

Date: 2025-05-11.06:57:50

Suggested resolution:

  1. Change the grammar before 9.10 [namespace.udecl] paragraph 1 as follows:

      using-declarator:
        typenameopt nested-name-specifier unqualified-id using-declarator-id
    
      using-declarator-id:
        identifier
        operator-function-id
        conversion-function-id
        literal-operator-id
    
  2. Change in 9.10 [namespace.udecl] paragraph 1 as follows:

    The component names of a using-declarator are those of its nested-name-specifier and unqualified-id using-declarator-id. The component name of a using-declarator-id is itself. Each using-declarator in a using-declaration [ Footnote: ... ] names the set of declarations found by lookup (6.5.5 [basic.lookup.qual]) for the using-declarator, except that class and enumeration declarations that would be discarded are merely ignored when checking for ambiguity (6.5 [basic.lookup]), conversion function templates with a dependent return type are ignored, and certain functions are hidden as described below. If the terminal name of the using-declarator is dependent (13.8.3.2 [temp.dep.type]), the using-declarator is considered to name a constructor if and only if the using-declarator-id is an identifier and the nested-name-specifier has a terminal name that is the same as the unqualified-id identifier. If the lookup in any instantiation finds that a using-declarator that is not considered to name a constructor does do so, or that a using-declarator that is considered to name a constructor does not, the program is ill-formed.
  3. Change in 9.10 [namespace.udecl] paragraph 2 as follows:

    If the using-declarator names a constructor, it declares that the class inherits the named set of constructor declarations from the nominated base class. Otherwise, the using-declarator introduces its using-declarator-id. [Note 1: Otherwise, the unqualified-id in the using-declarator is bound to During name lookup, the using-declarator, which is replaced during name lookup with the declarations it names (6.5 [basic.lookup]). If such a declaration is of an enumeration, the names of its enumerators are not bound. For the keyword typename, see 13.8 [temp.res]. —end note]
  4. Change in 9.10 [namespace.udecl] paragraph 4 as follows:

    [Note 2: Since destructors do not have names, a using-declaration cannot refer to a destructor for a base class. —end note] If a constructor or assignment operator brought from a base class into a derived class ...
  5. Remove 9.10 [namespace.udecl] paragraph 5:

    A using-declaration shall not name a template-id.
      struct A {
        template <class T> void f(T);
        template <class T> struct X { };
      };
      struct B : A {
        using A::f<double>; // error
        using A::X<int>;    // error
      };
    
Date: 2025-03-24.00:00:00

(From submission #692.)

There is no normative rule that would cause a using-declarator not naming a constructor to bind its unqualified-id in the scope it inhabits.

Also, a normative prohibition for something like using X::~X; seems to be missing.

History
Date User Action Args
2025-05-11 06:57:50adminsetmessages: + msg8027
2025-03-24 00:00:00admincreate