Boost logo

Boost :

From: William Kempf (sirwillard_at_[hidden])
Date: 2000-11-18 10:51:57


--- In boost_at_[hidden], Jesse Jones <jejones_at_a...> wrote:
> >On Fri, 17 Nov 2000 15:31:35 -0800
> >Jesse Jones <jejones_at_a...> wrote:
> But we know that we want to have some sort of empty test. If we do
this
> with a bool or const void* conversion operator users will be able to
> compare any two callback objects, but in all probability this will
return
> false unless you're dealing with the exact same callback on the
left and
> right.

Actually, with the conversions in place comparisons will usually
return true. cb1 converts to a bool (likely true) and cb2 converts
to a bool (likely true) and hence comparison likely returns true
regardless if the callbacks are exactly the same. (Actually, I'm
quite tired while writing this and I'm not sure that the implicit
conversions should occur in this case. I'm fairly sure that if the
callbacks are of the same type the conversion will not occur.)

> We can document that comparisons don't work as expected, but it
> seems better to arrange for a compile error if the user does
something
> wrong.

That's simple. You eliminate the comparison operations from the
public interface (explicitly make them private). It's then a
compiler error to try and use them, which is the best idea
considering we can't make them return useful information.

Bill Kempf


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