From: Beman Dawes (bdawes_at_[hidden])
Date: 2008-07-17 17:30:27
Robert Ramey wrote:
> vicente.botet wrote:
>>>> I would probably consider this a user error in that it violates
>>>> the intention of name spaces to avoid just this problem.
>> Is there a way the user can write their code to avoid this possible
>> Is there a way the developper can add a new interface avoiding this
>> possible ambiguity on the user code?
>> How the C++ standard library does to avoid this kind of ambiguity in
>> user code?
> This is easy, just don't put any of your own stuff into the the namespace
> that the library uses.
>> Does this banish the use of using in user code if he/she wants to
>> avoid incompatibilities with newer releases?
> If you never put any of your own stuff in to the boost:: or std::
> namespaces, you shouldn't have this problem.
> If you use "using <namespace>" you could still have aproblem
> if one of your names accidently matches something this the
> namespace being used. For this reason, I don't particularly
> like using "using <namespace>" myself but rather just
> spell out the whole thing like boost::filesystem:: ...
Yep, I think that is generally considered better programming practice.
If the length is bothersome, use a namespace alias:
namespace fs = boost::filesystem;
and then fs:: ...
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk