Boost logo

Boost :

From: Ben FrantzDale (benfrantzdale_at_[hidden])
Date: 2007-01-19 16:32:07


On 1/19/07, Andrey Semashev <andysem_at_[hidden]> wrote:
>
> Hello Matthias,
>
> [snip]
>
> >> For (b) the semantics really are
> >> the same as a static_cast since the only thing changing is the
> >> type, so it's
> >> dimensionally safe even if it's type-dangerous. But (a) I worry
> >> about. For
> >> something like that I'd rather see another name for the cast since
> >> it is a
> >> potential hole in the unit system – something like
> >> reinterpret_quantity_cast. (There's always reinterpret_cast for
> >> doing things
> >> that are really unsafe.)
>
> > Is it possible to overload the system reinterpret_cast, or is it not
> > really a
> > library function? If it was, that might be an option, too...
>
> It's an operator and it cannot be overloaded.
>

However, assuming that a quantity<D,T> looks like a T in memory,
reinterpret_cast should Just Work. Of course, it would let you change both D
and T. (My thought was to have a cast that can change quantity<D,T> to and
from a T.)

—Ben


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