Boost logo

Boost :

From: Douglas Gregor (gregod_at_[hidden])
Date: 2002-10-08 10:20:21


On Tuesday 08 October 2002 10:21 am, Peter Dimov wrote:
> So one might argue that comparisons to zero aren't necessary, esp. since
> you can't compare function instances for equality.

The flip side of the coin is that if '= 0' is a special case for assigning an
empty function, '== 0' is a reasonable special case for checking for an empty
function. I'm not overly attached to the comparisons (since we already have
those checks in boolean contexts, as you said).

> On the other hand, you can initialize function pointers with zero, so you
> might want to add
>
> function<void ()> f(0);
>
> and
>
> function<void ()> f = 0;
>
> support. Now should that constructor be implicit? Decisions...

I'd love to add that support, but I'm not sure how. We can't just have a
'const int' constructor, because that allows any integer to be used (only
detectable at run-time). And I don't see a way to rely on the 0->null pointer
conversion because this constructor will always be a better match:

  template<typename F> function(F f); // with F = int

        Doug


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk