Boost logo

Boost Users :

Subject: Re: [Boost-users] Nautical miles and boost::units
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2009-02-13 11:39:15


AMDG

Esben Mose Hansen wrote:
> What sort of magic do I have to write to get this sort of thing to work?
>
> ===
> typedef boost::units::quantity<boost::units::si::length> length_t;
>
> length_t earth_radius = 3438.461 * nautical_mile;
> ===
>
> boost::units defines a boost::units::metric::nautical_mile_base_unit in terms
> of meters, so the numbers and concepts are in the library already. Somehow.
>
> Thanks for any help :)
>

A base_unit provides a nested ::unit_type typedef.

typedef boost::units::metric::nautical_mile_base_unit::unit_type
nautical_mile;

length_t earth_radius(3438.461 * nautical_mile());

Note that converting between different units is explicit so you
can't use the copy construction syntax.

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