definition of class in namespace with using

Viewed 268

On class.pre there is an example class definition:

namespace N {
  template<class>
  struct A {
    struct B;
  };
}
using N::A;
template<class T> struct A<T>::B {};    // OK
template<> struct A<void> {};           // OK

And the standard states

If a class-head-name contains a nested-name-specifier, the class-specifier shall not inhabit a class scope.

The text and the example seem to differ.

Is the specialization of A<void> template, which does not contain a nested-name-specifier (but only 'relies' on using) still conformant?

clang and msvc accept it, gcc shows the error

error: explicit specialization of 'template struct N::A' outside its namespace must use a nested-name-specifier [-fpermissive]

Edit: The example seems to have been already changed (as minor editorial change) once: https://github.com/cplusplus/draft/commit/b6e0848db7a72560a7bfc84f16bd23abf6aab2d6 ([class.pre] Fix incorrect comment in example)

The paper, which introduced the original wording and example comment, is http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1787r6.html (P1787R6: Declarations and where to find them)

The line in the paper was

template<> struct A<void> {};         // error: A not nominable in ::
0 Answers
Related