Boost logo

Boost Users :

Subject: Re: [Boost-users] [Units] implicit conversion of quantities
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-03-03 16:15:28


AMDG

Christopher Bruns wrote:
> Kudos on the excellent implementation of the Boost.Units library. I
> am also very grateful for the extremely timely help I have got in the
> past from the principal authors Matthias Schabel and Steven Watanabe.
>
> Is there any way to force implicit conversion of Angstrom quantities
> to nanometer quantities in assignment and method calls using
> Boost.Units? I would appreciate any suggestions on how to get the
> final three method calls in the attached program to compile.
>

It can be done, but I don't advise it.

> I suppose I could overload the showBondLength() method in this example
> to take both types. I think I would prefer implicit conversion, if
> that is possible.
>

In this particular case, I would suggest writing the function as a template
and casting. In general you can write a forwarding overload that casts as
appropriate.

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net