c++ - usage of namespaces in libraries -


i'd know if qualifying names in library necessary.

for example (i indent namespaces here readability):

namespace {     namespace b {         namespace c {             class foo { ... };         } // namespace c          ::a::b::c::foo foo;         // or         c::foo foo     } // namespace b     namespace d {         ::a::b::c::foo foo;         // or         b::c::foo foo     } // namespace d } // namespace 

i didn't understand 3.4 chapter of c++ standard, , saw can't explain in stl vector header (simplified readability):

namespace std {     template<..     class reverse_iterator     { ... };      template<..     class vector {         typedef _std reverse_iterator<const_iterator> const_reverse_iterator;         ...     } } 

the thing _std expanded ::std:: .. according understanding of name up, reverse_iterator have been looked in vector first in parent namespace std. how collision possible ?

subsidiary question : name lookup rules names in template functions arguments ? think qualified-id directly names declared without adl unqualified name adl, right ?

thank in advance answers.

you're right, qualification appears unnecessary there.

don't try learn c++ standard library code, has written in peculiar style various reasons don't apply you, including backwards compatibility, portability, alternative configurations (e.g. disabling namespaces historical compilers). it's possible in configurations _std expands different, or it's possible it's redundant (but harmless.)

what name lookup rules names in template functions arguments ? think qualified-id directly names declared without adl unqualified name adl, right ?

yes, adl applies unqualified names.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -