c++ - How is the following passage from the standard to be interpreted? -


§3.3.6/1 (c++11)

the declarative region of namespace-definition namespace-body. potential scope denoted original-namespace-name concatenation of declarative regions established each of namespace-definitions in same declarative region original-namespace-name....

the definition of declarative region follows (§3.3.1/1):

every name introduced in portion of program text called declarative region, largest part of program in name valid, is, in name may used unqualified name refer same entity. ...

the 2 taken seem imply name of namespace can used (unqualified) inside namespace body itself. but, clearly, false. mean declarative region of namespace definition body, when name of namespace can in fact used (unqualified) outside namespace body?

also, don't understand @ (re-quoted above):

the potential scope denoted original-namespace-name concatenation of declarative regions established each of namespace-definitions in same declarative region original-namespace-name.

the standard not talking think...

i think confusion lies fact mistakingly assuming text namespace name itself, when standard talking names introduced inside namespace in question.


what quoted thing "just doesn't make sense"?

the potential scope denoted original-namespace-name concatenation of declarative regions established each of namespace-definitions in same declarative region original-namespace-name.


the above might easiest describe example:

.--- namespace definition |        .--- original-namespace-name v        v namespace n { <-------------------------------.   int x = 0;                              <---+--- declarative region (1) } <-------------------------------------------' 

.--- namespace definition of `n` |         .--- original-namespace-name v         v namespace n { <-------------------------------.   int y = x;                              <---+--- declarative region (2) } <-------------------------------------------' 

note: potential scope of int x both (1) , (2), ie. "concatenation of declarative regions" introduced.

  • in example have 2 namespace-definitions original-namespace-name n, have 2 declarative regions, "potential scope" inside namespace named n both (1), , (2).

  • as long namespace definitions in same declarative region, , share same original-namespace-name, refer same namespace.

  • introducing such namespace definition add more room potential scope (by appending declarative region) of variables declared inside it.


potential scope, , declarative region; they?

  • a declarative region part of program name can referred without being qualified.

  • the potential scope scope in name potentially valid, it's entire scope in name could refer same entity.


3.3.1p1 declarative regions , scope [basic.scope.declarative]

every name introduced in portion of program text called declarative region, largest part of program in name valid, is, in name may used unqualified name refer same entity.

in general, each particular name valid within possible discontiguous portion of program text called scope. determine scope of declaration, conventient refer potential scope of declaration.

the scope of declaration same potential scope unless potential scope contains declaration of same name. in case potential scope of declaration in inner (contained) declarative region excluded scope of declaration in outer (containing) declarative region.


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -