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
Post a Comment