From: Douglas Gregor (gregod_at_[hidden])
Date: 2001-06-08 11:44:09
On Friday 08 June 2001 12:00 pm, you wrote:
> From: "Douglas Gregor" <gregod_at_[hidden]>
> > > FWIW, I tend to agree with Darin that the if(f), f = nil, f == nil
> > > constructs, while useful, are not strictly necessary (considering the
> > > problems they introduce) - the explicit empty(), clear() methods are
> > Which problems do they introduce? Unless there are serious problems with
> > nil/null type (such that it won't be adopted), I'm not sure I see any
> > problems with the operators.
> The implicit conversion is quite dangerous. It enables code like this:
> boost::function<void> f;
> f + 4;
> f - f;
> to compile. I'd expect comparisons of the form f < f, f > f, etc to also
> work, but some compilers (Intel, MSVC) don't agree with me on this; g++
> 2.95.2 and bcc32 5.5.1 do.
> As for the f = nil syntax... I do prefer the f = 0; syntax when f is a
> smart pointer; however, f = nil and f.clear() are equal to me. Neither is
> an idiom.
> Peter Dimov
> Multi Media Ltd.
Expressions such as f + 4 or f - f don't make any sense to the user, however.
== and != are especially bad cases because users who think of 'function' as a
function pointer would expect them to exist. I can poison all of the
operators, but it hardly seems worth it.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk