It’s possible to do using namespace foo::bar; (i.e., using the inner namespace without using the outer namespace first / at all), why does the standard forbid to do the following?
namespace foo::bar {
// open nested namespace bar in foo and extend it...
}
I’m not looking for a workaround, just a possible rational on why this isn’t allowed.
I’m not sure “forbidden” is the right word – maybe it was just an oversight. It’s a fairly small nice-to-have which isn’t really a big deal.
You could also take the point of view that the namespace
fooisn’t created yet when you writefoo::bar, so allowing that syntax makes it look likefoowas already created when it was not.You could also go further and request the ability to write
class Foo::MyClass {...to defineMyClassin namespaceFoo, and the same for functions, variables, etc. But is this feature really necessary and solving any particular pressing problem?