Title
Can a using-declaration name a namespace?
Status
cd1
Section
9.9 [namespace.udecl]
Submitter
John Spicer

Created on 2004-02-12.00:00:00 last changed 189 months ago

Messages

Date: 2005-04-15.00:00:00

[Voted into WP at April 2005 meeting.]

Date: 2004-10-15.00:00:00

Proposed resolution (October, 2004):

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

A using-declaration shall not name a namespace;
Date: 2004-03-15.00:00:00

Notes from the March 2004 meeting:

We agree that it should be an error.

Date: 2004-02-12.00:00:00

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.9 [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;
History
Date User Action Args
2008-10-05 00:00:00adminsetstatus: wp -> cd1
2005-10-22 00:00:00adminsetstatus: dr -> wp
2005-05-01 00:00:00adminsetmessages: + msg1190
2005-05-01 00:00:00adminsetstatus: ready -> dr
2004-11-07 00:00:00adminsetmessages: + msg1047
2004-11-07 00:00:00adminsetstatus: drafting -> ready
2004-04-09 00:00:00adminsetmessages: + msg977
2004-04-09 00:00:00adminsetstatus: open -> drafting
2004-02-12 00:00:00admincreate