Peter Kümmel <[EMAIL PROTECTED]> writes: | When we use a C compiler then it uses the C-style cast (bool), | so I think the correctest way is to use static_cast<bool>, | but this is so ugly that I would prefer (bool).
C-style casts are just too powerful... don't use them. | I'm not sure if the bool constructor -bool::bool(int)- | is really as fast as the casts. I am. If you are not, please provide measurements. | But sometime it would simple help to "code what you mean" :) | | Here an example: | | enum type{...} | bool match(type a, type b) { return (a & b); } | | Does this not mean a==b? So why not write it down? | So we will get a boolean without any casts. That depends.... it could very well mean ((a & b) == b) (and also if (a & b) is not b, then (a & b) is 0, so the explict comparison should not be needed.) If a is a bit-field the (a & b) is a pretty usual construct. (bit-field in the 1,2,4,8,16 sense) -- Lgb