mp-units icon indicating copy to clipboard operation
mp-units copied to clipboard

fix: inconsistent construction between equivalent dimensions

Open JohelEGP opened this issue 5 years ago • 1 comments

This second assertion fails:

#include "units/physical/si/cgs/base/length.h"

using namespace units;
namespace si = physical::si;
using namespace si;
using namespace unit_constants;

constexpr auto cgs_cm = cgs::unit_constants::cm;

static_assert(length<metre, double>(1 * cgs_cm) == 1 * cm);
static_assert(length<metre, int>(1 * cgs_cm) == 1 * cm);

JohelEGP avatar Jan 19 '21 21:01 JohelEGP

The problem is that it should be a compile-time error, right? length<metre, int>(1 * cm) fails at compile-time for target types with an integral representation to avoid truncation. Whether the input value is 1 * cm or 1 * cgs_cm shouldn't change the semantics. That means these are wrong and should be moved to alongside the !constructible_or_convertible_from test cases: https://github.com/mpusz/units/blob/e1f7266b517c04644b666af6aef3e65216b28c56/test/unit_test/static/quantity_kind_test.cpp#L238 https://github.com/mpusz/units/blob/e1f7266b517c04644b666af6aef3e65216b28c56/test/unit_test/static/quantity_point_kind_test.cpp#L287

JohelEGP avatar Mar 20 '22 21:03 JohelEGP

Addressed in V2.

mpusz avatar Jun 15 '23 07:06 mpusz