AMDG 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@lists.boost.org> 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