I'd like to know if fully qualifying names in a library is necessary.
For example (I indent namespaces here for readability):
namespace A {
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 A
I didn't fully understand the 3.4 chapter of the C++ standard, and I saw something I can't explain in the STL vector header (simplified for readability):
namespace std {
template<..
class reverse_iterator
{ ... };
template<..
class vector {
typedef _STD reverse_iterator<const_iterator> const_reverse_iterator;
...
}
}
The thing is _STD is expanded to ::std:: .. but according to my understanding of the name look up, reverse_iterator would have been looked up for in vector first then in the parent namespace which is std. How could a collision would be possible ?
subsidiary question : what would be the name lookup rules for names in a template functions with arguments ? I think that a qualified-id would look directly for names already declared without ADL but an unqualified name would do an ADL, am I right ?
Thank you in advance for your answers.