Boost logo

Boost :

From: Doug Gregor (gregod_at_[hidden])
Date: 2001-04-10 08:00:48


On Tuesday 10 April 2001 12:44, you wrote:
> 9 Apr 2001 16:42:23 +0400 Doug Gregor wrote:
> > any_function& operator=(const int); // assignment to zero clears
> > target
>
> Why such a trickery? How about assignment to 1, to 5, to 314159?
> Why not just to
>
> > void clear(); // clear out the target
> >
> >
> >
> > bool empty() const; // true if no target
> > operator const void*() const; // evaluates true if non-empty
>
> This operator is redundant too.

Both make any_function "act like" a normal function pointer. My argument is
that it is more natural for a C++ program to write:

any_function<...> foo;

if (foo) { /* use foo */ }
// ...
foo = 0;

because this is no different from a function pointer, aside from the
declaration. However, I don't see that I user would ever write:

foo = 12;

because it does not make sense.

        Doug


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