Boost logo

Boost :

Subject: Re: [boost] Boost.Fiber review January 6-15
From: Nat Goodspeed (nat_at_[hidden])
Date: 2014-01-11 11:01:15


On Fri, Jan 10, 2014 at 2:19 AM, Oliver Kowalke
<oliver.kowalke_at_[hidden]> wrote:

> 2014/1/9 Vicente J. Botet Escriba <vicente.botet_at_[hidden]>

>> you can compare X and Y

> You are surely right, but I don't see how? Could you show it?

> implicit conversion to bool through operator bool()

Vicente, the bad case is when class X and class Y provide operator
bool. A coder inadvertently writes:

if (myXinstance == myYinstance) ...

(only of course with names in the problem domain rather than names
that emphasize their respective classes). This should produce a
compile error; you don't want X and Y to be comparable; the comparison
is meaningless. Yet the compiler accepts it, converting each of
myXinstance and myYinstance to bool and then comparing those bool
values. The code runs. The product ships. Then some customer gets
badly whacked...


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