Document number: | N4230 |
Date: | 2014-10-10 |
Project: | Programming Language C++, Evolution Working Group |
Reply-to: | Robert Kawulak <Robert Kawulak at gmail dot com>, Andrew Tomazos <Andrew Tomazos at gmail dot com> |
The code above would be equivalent to:namespace A::B::C { //… }
The feature was already proposed by Jon Jagger in 2003 in the paper N1524 Nested Namespace Definition Proposal, but it has been listed in N2869 State of C++ Evolution (Post San Francisco 2008) undernamespace A { namespace B { namespace C { //… } } }
Not ready for C++0x, but open to resubmit in future.
(namespace\s+\w+\s*\{\s*){3,}
to find nested namespace definitions at least 3 levels deep in the include directory of Boost libraries yielded 3758 matches and the greatest nesting level found this way was 7 (4 matches).
a tool that automates many onerous C++ programming tasks, supports it – from the tool's documentation:
The name of a named namespace may be qualified.is equivalent to:namespace A::B { typedef int I; }
namespace A { namespace B { typedef int I; } }
using namespace A::B::C = X;
However, use cases for qualified namespace aliases seem to be infrequent (the author didn't find any in Boost for example) so they aren't considered by this proposal.
… namespace-name: original-namespace-name namespace-alias original-namespace-name: identifier namespace-definition: named-namespace-definition unnamed-namespace-definition nested-namespace-definition named-namespace-definition: original-namespace-definition extension-namespace-definition original-namespace-definition:inline
optnamespace
identifier{
namespace-body}
extension-namespace-definition:inline
optnamespace
original-namespace-name{
namespace-body}
unnamed-namespace-definition:inline
optnamespace
{
namespace-body}
nested-namespace-definition:namespace
enclosing-namespace-specifier::
identifier{
namespace-body}
enclosing-namespace-specifier: identifier enclosing-namespace-specifier::
identifier namespace-body: declaration-seqopt …
A nested-namespace-definition with an enclosing-namespace-specifierE
, identifierI
and namespace-bodyB
is equivalent to[Example:namespace E { namespace I { B } }
The above has the same effect as:namespace A::B::C { int i; }
—end example]namespace A { namespace B { namespace C { int i; } } }
namespace std::placeholders {
namespace placeholders {…}}
namespace std::regex_constants {
namespace regex_constants {…}}
namespace std::regex_constants {
namespace regex_constants {…}}
namespace std::regex_constants {
namespace regex_constants {…}}
namespace std::this_thread {
namespace this_thread {…}}