c++ - Member function overload based on namespaced typedefed primitif types -
the following code fails compile g++ 4.8, in both c++03 , c++11
namespace n {typedef int a;} namespace nn {typedef int a;} struct z { void foo(n::a){} void foo(nn::a){} };
the error
d.cpp:7:10: erreur: ‘void z::foo(nn::a)’ cannot overloaded void foo(nn::a){}}; ^ d.cpp:6:6: erreur: ‘void z::foo(n::a)’ void foo(n::a){}
i have thought types in different namespaces different types, no matter what. seems not. feel @ end compiler gets rid off namespace/typedef , focus on underlying type , clashes.
am right ? have workaround ?
types don't live in namespaces. names do. overload on types, not on names.
Comments
Post a Comment