Limited number of places where common_type is being used on quantities

For some specific mathematical types different type might be returned from division, mulitplication, substraction, etc.
std::common_type<> does not have an information which operation is being performed. It is much better to just get
the actual result of specific operation.
This commit is contained in:
Mateusz Pusz
2019-05-07 21:03:58 -06:00
parent cdf9f929c3
commit cf2370b8fe
2 changed files with 69 additions and 54 deletions

View File

@@ -249,11 +249,11 @@ namespace {
static_assert(Quantity<length<millimeter, int>>);
// common_type
// common_quantity
static_assert(std::is_same_v<std::common_type_t<length<meter, int>, length<kilometer, int>>, length<meter, int>>);
static_assert(std::is_same_v<std::common_type_t<length<kilometer, long long>, length<meter, int>>, length<meter, long long>>);
static_assert(std::is_same_v<std::common_type_t<length<kilometer, long long>, length<millimeter, double>>, length<millimeter, double>>);
static_assert(std::is_same_v<common_quantity_t<length<meter, int>, length<kilometer, int>>, length<meter, int>>);
static_assert(std::is_same_v<common_quantity_t<length<kilometer, long long>, length<meter, int>>, length<meter, long long>>);
static_assert(std::is_same_v<common_quantity_t<length<kilometer, long long>, length<millimeter, double>>, length<millimeter, double>>);
// quantity_cast