feat!: 💥 dimensionless quantities refactored

Dimensionless quantities are now represented by quantity types rather
than by plain representation types. Only dimensionless quantities with
`unitless` unit are implicitly convertible from representation types.

`units::exp()` now is a function doing std::exp() on a representation
type (previous `units::exp` class template was renamed to
`units::exponent`).

BREAKING_CHANGE: gcc-9.3 support removed
BREAKING_CHANGE: `exp` and `Exp` renamed to `exponent` and `Exponent`
Resolves #27
Resolves #42
This commit is contained in:
Mateusz Pusz committed 2020-09-08 11:02:16 +02:00
1 parent c8b60b80c1
commit 563b358d5e
47 files changed
+599 -422

No files matched your search

+8 -4
View File
@@ -27,8 +27,6 @@
#include <units/bits/dimension_op.h>
#include <units/bits/external/type_traits.h>
#include <units/bits/pow.h>
#include <units/quantity.h>
#include <units/quantity_point.h>
#include <cassert>
#ifdef _MSC_VER
@@ -38,6 +36,12 @@
namespace units {
template<Dimension D, UnitOf<D> U, Scalar Rep>
class quantity;
template<Dimension D, UnitOf<D> U, Scalar Rep>
class quantity_point;
namespace detail {
template<typename D, typename U, typename Rep>
@@ -284,8 +288,8 @@ struct quantity_cast_impl<To, CRatio, CRep, false, true, false> {
template<typename Q1, typename Q2>
constexpr ratio cast_ratio(const Q1& from, const Q2& to)
{
using FromU = Q1::unit;
using ToU = Q2::unit;
using FromU = TYPENAME Q1::unit;
using ToU = TYPENAME Q2::unit;
if constexpr(same_unit_reference<FromU, ToU>::value) {
return FromU::ratio / ToU::ratio;
}