On Wed, Jun 07, 2006 at 12:39:04AM +0200, Peter Kümmel wrote:
> Lars Gullik Bjønnes wrote:
> 
> > | Obviously, I'm in a pedantic mood. These two are casts:
> > |    (bool)1;
> > |    static_cast<bool>(1);
> > | This one isn't:
> > |    bool(1);
> > 
> > I think I still prefere this last one.
> 
> When we compile with a C++ compiler then it casts with
> a static_cast<bool> a int to bool, therefore the warning.

That translates to 'nothing' in the binary.

No exactly a loss of performance.

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

bool(..) is just fine - if anything is needed at all.

> I'm not sure if the bool constructor -bool::bool(int)-
> is really as fast as the casts.

It is equivalent to the static_cast.  (and also not visible in the
binary).

> enum type{...}
> bool match(type a, type b) { return (a & b); }
> 
> Does this not mean a==b? So why not write it down?

Not for  enum { a = 2, b = 6 }

Andre'

Reply via email to