Boost logo

Boost Users :

Subject: Re: [Boost-users] [Units] Units in unit tests
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2017-05-08 13:11:35


On 05/08/2017 01:11 AM, Stephan Menzel via Boost-users wrote:
> On Mon, May 8, 2017 at 4:17 AM, Gavin Lambert via Boost-users <
> boost-users_at_[hidden]> wrote:
>> Try:
>> BOOST_CHECK_CLOSE(X(v) / meters, 42.0, 0.001);
>> (You might also need an explicit static_cast<double>. If so, you might
>> want to wrap this whole thing in a helper method to reduce typing.)
> OK, this is a bit of surprise. This "X(v) / meters" obviously means "I want
> the value in meters"?
> Actually I spent quite some time trying to figure that exact thing out and
> I just couldn't find it in the docs. I have just tried it and it works.

The meaning is literally division. (1.0 * meters) / meters = 1.0
If the expression exactly cancels out all units, then the
result is dimensionless and can be implicitly converted
to a double.

> Great, that's at least a way to make things explicit and helps.

In Christ,
Steven Watanabe

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at