Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-03-16 12:32:21

From: <williamkempf_at_[hidden]>

[on implicit conversions to bool]

> This argument has come up on here before, and I'm not 100% sure that
> a consensus opinion was reached on this. Conversion to bool is more
> natural to my mind, and the implicit conversion "to umpteen different
> types" doesn't seem to dangerous to me... at least in this case.
> Changing this will be trivial, so I'll defer to the "experts"
> opinions on this, but I'm not sure that they've fully agreed with
> each other in the past. Am I wrong?

I think that you are. The consensus among the experts, AFAIK, is

* Don't provide implicit conversions;
* If you do, don't use bool, use void const * instead.

Implicit conversions to bool allow expressions like a + b, a + 4, a < b, a
<< b compile. Conversions to void const * allow comparisons only.

Peter Dimov
Multi Media Ltd.

Boost list run by bdawes at, gregod at, cpdaniel at, john at