c++ - typedef resolution across namespaces -


i confused way "using (namespace)" statements work in c++.

i have:

//somewhere in included headers typedef unsigned int uint;  namespace mine {     typedef unsigned int uint; } namespace other {     using namespace mine;     void foobar () {         uint offender = i;     } } 

results in (paraphrased):
reference 'uint' ambiguous. candidates are
typedef unsigned int uint
and
typedef unsigned int mine::uint

meanwhile, when do

namespace other {     using namespace mine;     using mine::uint;      void foobar () {         uint offender = i;     } } 

everything works fine. seems strange me "using identifier;" changes visibility of other typedef definition (conceals global one?). can point me kind of rules in c++ govern resolution of typedefs across namespaces?

a name made visible using-directive appears in nearest enclosing scope contains [- directly or indirectly -] both using-directive , nominated namespace. (7.3.4 [namespace.udir])

this means both uint declarations appear @ global namespace scope when looked after using-directive in other.

a using-declaration, other declaration, declares name @ scope in appears. why, in second example, using mine::uint; hides uint introduced using namespace mine; latter appears come global scope.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -