Boost logo

Boost :

From: Daniel Frey (d.frey_at_[hidden])
Date: 2003-02-25 03:42:53

On Tue, 25 Feb 2003 08:34:43 +0100, Nicola Musatti wrote:

> Beman Dawes wrote:> At 07:32 PM 2/24/2003, Daniel Frey wrote:
>> >Hi,
>> >
>> >I came across the following problem:
>> >
>> >When I have a class X which lives in a namespace where there's a
>> >function 'checked_delete' declared that can take a X*, smart_ptr (and
>> >probably others)
>> >that use checked_deleter (note the 'r'!) cannot call checked_delete.
>> >It's ambiguous due to argument dependent lookup. To fix it, I had to
>> >make the call to checked_delete in checked_deleter qualified:
>> >
>> >template<class T> struct checked_deleter {
>> > typedef void result_type;
>> > typedef T * argument_type;
>> >
>> > void operator()(T * x) const
>> > {
>> > ::boost::checked_delete(x);
>> > }
>> >};
>> >
>> >(alas for checked_array_deleter)
>> >
>> >Comments?
>> Go ahead and make the change, unless someone voices an objection.
> I don't have a strong opinion in either direction, but I do feel that it
> is important that this is thought over. Overloading checked_delete() on
> purpose in a user defined namespace might be considered a way to provide
> a smart pointer with a custom deleter. Is this really something bad?

It won't work as the call is ambiguous and thus rejected by the compiler.
But the user it free to provide his own checked_deleter along with his own
checked_delete, so there is no limitation that would result from the above
fix AFAICS. If you agree, I will make the change in CVS.

And like Beman I also wondered how many other places we have where this is
the case, but you (Nicola) provided a good argument not to do it
automatically. ADL is sometimes desirable, sometimes not. I think we have
to judge every case on its own.

Regards, Daniel

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