Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-06-08 14:30:32


From: "Douglas Gregor" <gregod_at_[hidden]>

> Expressions such as f + 4 or f - f don't make any sense to the user,
however.

Perhaps, but it is still undesirable to allow them to compile. Such code is
most probably a bug.

> == 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.

Don't forget *f and f[5]. :-)

The if(f) syntax is very difficult to get right... If you make an implicit
conversion to an incomplete class pointer (void const * or undefined const
*) all these problems go away, but delete f; returns. [std::memcpy(buffer,
f, 4) works in either case, but could be considered rare.]

operator< is important to poison, too; otherwise users will try to put
function<>s in a std::set.

--
Peter Dimov
Multi Media Ltd.

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