Does a C++ namespace alias defined inside a function definition have a block, function, file, or other scope (duration of validity)?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
As far as I know, it's in the scope it's declared. So, if you alias in a method, then it's valid in that method, but not in another.
I'm fairly certain that a namespace alias only has scope within the block it's created in, like most other sorts of identifiers. I can't check for sure at the moment, but this page doesn't seem to go against it.
It's a block duration of validity. E.g If you define a namespace alias as below, the namespace alias abc would be invalid outside {...} block.
It would have the scope of the block in which it was defined - likely to be the same as function scope unless you declare the alias inside a block within a function.
Take a look at http://en.wikibooks.org/wiki/C++_Programming/Scope/Namespaces
The scope is the declarative region in which the alias is defined.