Boost logo

Boost :

Subject: Re: [boost] Boost.Operators issue: polluting namespace of caller through argument-dependent lookup
From: Daniel Frey (d.frey_at_[hidden])
Date: 2016-01-18 13:03:53

> On 17.01.2016, at 10:51, John M. Dlugosz <mpbecey7gu_at_[hidden]> wrote:
> Here's the problem I ran into
> |usingstd::tr1::shared_ptr; ||usingstd::tr1::make_shared;|
> |shared_ptr<Dog>Gamma::knockout (constHotel&target){Eggsoftboiled (target.ID);softboiled.sequence ^=0x40000000;returnmake_shared<Dog>(softboiled,target.kin,Frank::myself());} |
> The arguments to the constructor passed through make_shared are of types
> |Able::Bravo::Charlie::Egg&,constuint32_t&,constFrank&|
> The use of make_shared is finding boost::make_shared as well as std::make_shared. The program doesn't use boost::shared_ptr and shouldn't need to know about it.

This can not be simply “fixed” as it is quite an old and established interface. What about the people that actually rely on ADL to kick in to find their unqualified call of make_shared? Ideally, this should have been discussed and prevented when those interfaces were first established and I used the exact same solution that you described for a (Boost-independant) rewrite I did some years ago, but for Boost.Operators I think it is too late. (unless you can convince *everyone* that it should be changed, but I can not see how that is possible).

This leaves you only one option: Don’t use unqualified calls in your code unless it is actually required - which does not seem to be the case in your example. This is a general guideline I follow as it prevents these ADL-related problems.


Boost list run by bdawes at, gregod at, cpdaniel at, john at