Boost logo

Boost :

From: Ed Brey (brey_at_[hidden])
Date: 2000-12-07 15:34:21


From: "David Abrahams" <abrahams_at_[hidden]>

> I think we may just be poking at semantics in the worst way by
trying to
> distinguish casting from conversions. Does the C++ language make a
clear
> distinction?

I've always had the impression a cast is an expression that takes a
value of one type and evaluated to another type. Using this
definition, a function that returns bool isn't a cast, since it
doesn't evaluate to the destination type.

Clearly, what lead me to this impression are the C-style cast and the
C++ casts, all of which fit the above definition. Even more so, since
the C-style casts shows up on the operator precedence table as "type
cast", I've been imbued with the idea that a cast acts like an
operator; hence it evaluates to the destination type.

Really, I suppose this is narrow-minded, though. A cast can simply be
thought of as a type converter, and just because casts have followed a
more specific pattern in the past doesn't mean they have to.

So, I think you are right, that we can take cast to mean type convert
in general. (Ironically "convert" happens to not show up among the 45
widely varied meanings of "cast" listed in my dictionary.) :-)


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