CWG Issue 460 (original) (raw)

This is an unofficial snapshot of the ISO/IEC JTC1 SC22 WG21 Core Issues List revision 118e. See http://www.open-std.org/jtc1/sc22/wg21/ for the official list.

2025-11-05


460. Can a using-declaration name a namespace?

Section: 9.10 [namespace.udecl]Status: CD1Submitter: John SpicerDate: 12 Feb 2004

[Voted into WP at April 2005 meeting.]

Can a using-declaration be used to import a namespace?

namespace my_namespace{ namespace my_namespace2 { int function_of_my_name_space(){ return 2;} } }

int main (){ using ::my_namespace::my_namespace2; return my_namespace2::function_of_my_name_space(); }

Several popular compilers give an error on this, but there doesn't seem to be anything in 9.10 [namespace.udecl] that prohibits it. It should be noted that the user can get the same effect by using a namespace alias:

namespace my_namespace2 = ::my_namespace::my_namespace2;

Notes from the March 2004 meeting:

We agree that it should be an error.

Proposed resolution (October, 2004):

Add the following as a new paragraph after 9.10 [namespace.udecl] paragraph 5:

A using-declaration shall not name a namespace;