I
Imre
As far as I know, the using directive is transitive, and I'm not sure I
like this. So I'd like to ask if there's any workaround. Consider this:
namespace MyNameSpace
{
void
F(SomeNameSpace::SomeOtherNameSpace::YetAnotherNameSpace::SomeType a);
void
G(SomeNameSpace::SomeOtherNameSpace::YetAnotherNameSpaceSomeOtherType
a);
// ...
// Lots of such function declarations using types in
YetAnotherNameSpace
// ...
}
It's really inconvenient to always use these long qualifications, so it
would be nice to write using namespace
SomeNameSpace::SomeOtherNameSpace::YetAnotherNameSpace; at the
beginning of MyNameSpace. However, that would mean that client code
using MyNameSpace would see everything inside YetAnotherNameSpace, and
I think this is bad. Client code should be able to decide if thay want
to use the long syntax to access names inside YetAnotherNameSpace or
write their own using directive. The using at the beginning of
MyNameSpace would be an implementation detail; it's only purpose is
making the life of the implementor of MyNameSpace easier, but it
shouldn't force clients into using any other namespaces.
So, is this, or something similar possible in C++?
Thanks,
Imre
like this. So I'd like to ask if there's any workaround. Consider this:
namespace MyNameSpace
{
void
F(SomeNameSpace::SomeOtherNameSpace::YetAnotherNameSpace::SomeType a);
void
G(SomeNameSpace::SomeOtherNameSpace::YetAnotherNameSpaceSomeOtherType
a);
// ...
// Lots of such function declarations using types in
YetAnotherNameSpace
// ...
}
It's really inconvenient to always use these long qualifications, so it
would be nice to write using namespace
SomeNameSpace::SomeOtherNameSpace::YetAnotherNameSpace; at the
beginning of MyNameSpace. However, that would mean that client code
using MyNameSpace would see everything inside YetAnotherNameSpace, and
I think this is bad. Client code should be able to decide if thay want
to use the long syntax to access names inside YetAnotherNameSpace or
write their own using directive. The using at the beginning of
MyNameSpace would be an implementation detail; it's only purpose is
making the life of the implementor of MyNameSpace easier, but it
shouldn't force clients into using any other namespaces.
So, is this, or something similar possible in C++?
Thanks,
Imre