mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-31 10:57:16 +02:00
cmcstl2 library updated to 2019.08.07
This commit is contained in:
@ -45,7 +45,7 @@ class UnitsConan(ConanFile):
|
||||
exports = ["LICENSE.md"]
|
||||
settings = "os", "compiler", "build_type", "arch"
|
||||
requires = (
|
||||
"cmcstl2/2019.04.26@mpusz/stable",
|
||||
"cmcstl2/2019.08.07@mpusz/stable",
|
||||
"gsl-lite/0.33.0@nonstd-lite/stable"
|
||||
)
|
||||
scm = {
|
||||
|
@ -58,7 +58,7 @@ There are C++ concepts provided for each such quantity type:
|
||||
|
||||
```cpp
|
||||
template<typename T>
|
||||
concept Length = Quantity<T> && std::Same<typename T::dimension, length>;
|
||||
concept Length = Quantity<T> && std::same_as<typename T::dimension, length>;
|
||||
```
|
||||
|
||||
With that we can easily write a function template like this:
|
||||
@ -139,7 +139,7 @@ However, such an approach have some challenges:
|
||||
constexpr Velocity auto v1 = 1_m / 1s;
|
||||
constexpr Velocity auto v2 = 2 / 2s * 1m;
|
||||
|
||||
static_assert(std::Same<decltype(v1), decltype(v2)>);
|
||||
static_assert(std::same_as<decltype(v1), decltype(v2)>);
|
||||
static_assert(v1 == v2);
|
||||
```
|
||||
|
||||
@ -258,12 +258,12 @@ public:
|
||||
[[nodiscard]] static constexpr quantity one() noexcept { return quantity(quantity_values<Rep>::one()); }
|
||||
|
||||
template<Unit U1, Scalar Rep1, Unit U2, Scalar Rep2>
|
||||
requires std::Same<typename U1::dimension, dim_invert_t<typename U2::dimension>>
|
||||
requires std::same_as<typename U1::dimension, dim_invert_t<typename U2::dimension>>
|
||||
[[nodiscard]] constexpr Scalar operator*(const quantity<U1, Rep1>& lhs,
|
||||
const quantity<U2, Rep2>& rhs);
|
||||
|
||||
template<Unit U1, Scalar Rep1, Unit U2, Scalar Rep2>
|
||||
requires (!std::Same<typename U1::dimension, dim_invert_t<typename U2::dimension>>) &&
|
||||
requires (!std::same_as<typename U1::dimension, dim_invert_t<typename U2::dimension>>) &&
|
||||
(treat_as_floating_point<decltype(lhs.count() * rhs.count())> ||
|
||||
(std::ratio_multiply<typename U1::ratio, typename U2::ratio>::den == 1))
|
||||
[[nodiscard]] constexpr Quantity operator*(const quantity<U1, Rep1>& lhs,
|
||||
@ -274,12 +274,12 @@ public:
|
||||
const quantity<U, Rep2>& q);
|
||||
|
||||
template<Unit U1, Scalar Rep1, Unit U2, Scalar Rep2>
|
||||
requires std::Same<typename U1::dimension, typename U2::dimension>
|
||||
requires std::same_as<typename U1::dimension, typename U2::dimension>
|
||||
[[nodiscard]] constexpr Scalar operator/(const quantity<U1, Rep1>& lhs,
|
||||
const quantity<U2, Rep2>& rhs);
|
||||
|
||||
template<Unit U1, Scalar Rep1, Unit U2, Scalar Rep2>
|
||||
requires (!std::Same<typename U1::dimension, typename U2::dimension>) &&
|
||||
requires (!std::same_as<typename U1::dimension, typename U2::dimension>) &&
|
||||
(treat_as_floating_point<decltype(lhs.count() / rhs.count())> ||
|
||||
(ratio_divide<typename U1::ratio, typename U2::ratio>::den == 1))
|
||||
[[nodiscard]] constexpr Quantity operator/(const quantity<U1, Rep1>& lhs,
|
||||
@ -323,15 +323,15 @@ could generate a following compile time error:
|
||||
^~~~
|
||||
In file included from <path>\example\example.cpp:23:
|
||||
<path>/src/include/units/si/velocity.h:41:16: note: within 'template<class T> concept const bool stde::units::Velocity<T> [with T = stde::units::quantity<units::unit<units::dimension<units::exp<units::base_dim_time, 1> >, std::ratio<1> >, long long int>]'
|
||||
concept Velocity = Quantity<T> && std::Same<typename T::dimension, velocity>;
|
||||
concept Velocity = Quantity<T> && std::same_as<typename T::dimension, velocity>;
|
||||
^~~~~~~~
|
||||
In file included from <path>/src/include/units/bits/tools.h:25,
|
||||
from <path>/src/include/units/dimension.h:25,
|
||||
from <path>/src/include/units/si/base_dimensions.h:25,
|
||||
from <path>/src/include/units/si/velocity.h:25,
|
||||
from <path>\example\example.cpp:23:
|
||||
<path>/src/include/units/bits/stdconcepts.h:33:18: note: within 'template<class T, class U> concept const bool std::Same<T, U> [with T = stde::units::dimension<units::exp<units::base_dim_time, 1> >; U = stde::units::dimension<units::exp<units::base_dim_length, 1>,stde::units::exp<units::base_dim_time, -1> >]'
|
||||
concept Same = std::is_same_v<T, U>;
|
||||
<path>/src/include/units/bits/stdconcepts.h:33:18: note: within 'template<class T, class U> concept const bool std::same_as<T, U> [with T = stde::units::dimension<units::exp<units::base_dim_time, 1> >; U = stde::units::dimension<units::exp<units::base_dim_length, 1>,stde::units::exp<units::base_dim_time, -1> >]'
|
||||
concept same_as = std::is_same_v<T, U>;
|
||||
^~~~
|
||||
<path>/src/include/units/bits/stdconcepts.h:33:18: note: 'std::is_same_v' evaluated to false
|
||||
```
|
||||
@ -360,15 +360,15 @@ same code will result with such an error:
|
||||
^~~~
|
||||
In file included from <path>\example\example.cpp:23:
|
||||
<path>/src/include/units/si/velocity.h:48:16: note: within 'template<class T> concept const bool stde::units::Velocity<T> [with T = stde::units::quantity<units::second, long long int>]'
|
||||
concept Velocity = Quantity<T> && std::Same<typename T::dimension, velocity>;
|
||||
concept Velocity = Quantity<T> && std::same_as<typename T::dimension, velocity>;
|
||||
^~~~~~~~
|
||||
In file included from <path>/src/include/units/bits/tools.h:25,
|
||||
from <path>/src/include/units/dimension.h:25,
|
||||
from <path>/src/include/units/si/base_dimensions.h:25,
|
||||
from <path>/src/include/units/si/velocity.h:25,
|
||||
from <path>\example\example.cpp:23:
|
||||
<path>/src/include/units/bits/stdconcepts.h:33:18: note: within 'template<class T, class U> concept const bool std::Same<T, U> [with T = stde::units::time; U = stde::units::velocity]'
|
||||
concept Same = std::is_same_v<T, U>;
|
||||
<path>/src/include/units/bits/stdconcepts.h:33:18: note: within 'template<class T, class U> concept const bool std::same_as<T, U> [with T = stde::units::time; U = stde::units::velocity]'
|
||||
concept same_as = std::is_same_v<T, U>;
|
||||
^~~~
|
||||
<path>/src/include/units/bits/stdconcepts.h:33:18: note: 'std::is_same_v' evaluated to false
|
||||
```
|
||||
@ -401,7 +401,7 @@ concept bool Downcastable =
|
||||
requires {
|
||||
typename T::base_type;
|
||||
} &&
|
||||
std::DerivedFrom<T, downcast_base<typename T::base_type>>;
|
||||
std::derived_from<T, downcast_base<typename T::base_type>>;
|
||||
|
||||
template<Downcastable T>
|
||||
using downcast_from = T::base_type;
|
||||
@ -444,7 +444,7 @@ template<> struct downcasting_traits<downcast_from<velocity>> : downcast_to<velo
|
||||
|
||||
```cpp
|
||||
template<typename T>
|
||||
concept Velocity = Quantity<T> && std::Same<typename T::dimension, velocity>;
|
||||
concept Velocity = Quantity<T> && std::same_as<typename T::dimension, velocity>;
|
||||
```
|
||||
|
||||
3. Define units and provide downcasting traits for them:
|
||||
|
@ -27,8 +27,8 @@
|
||||
namespace std::experimental::units {
|
||||
|
||||
template<typename T>
|
||||
concept bool Number = std::Regular<T> &&
|
||||
std::StrictTotallyOrdered<T> &&
|
||||
concept bool Number = std::regular<T> &&
|
||||
std::totally_ordered<T> &&
|
||||
requires(T a, T b) {
|
||||
{ a + b } -> T;
|
||||
{ a - b } -> T;
|
||||
@ -41,6 +41,6 @@ namespace std::experimental::units {
|
||||
{ a /= b } -> T&;
|
||||
{ T{0} };// can construct a T from a zero
|
||||
// …
|
||||
} ;
|
||||
};
|
||||
|
||||
} // namespace std::experimental::units
|
||||
|
@ -37,7 +37,7 @@ namespace std::experimental::units {
|
||||
requires {
|
||||
typename T::base_type;
|
||||
} &&
|
||||
std::DerivedFrom<T, downcast_base<typename T::base_type>>;
|
||||
std::derived_from<T, downcast_base<typename T::base_type>>;
|
||||
|
||||
template<Downcastable T>
|
||||
using downcast_from = T::base_type;
|
||||
|
@ -39,11 +39,10 @@ namespace std {
|
||||
#endif // UNITS_HAS_STD_TYPE_IDENTITY
|
||||
|
||||
// concepts
|
||||
using experimental::ranges::Same;
|
||||
using experimental::ranges::Integral;
|
||||
using experimental::ranges::DerivedFrom;
|
||||
using experimental::ranges::Regular;
|
||||
using experimental::ranges::StrictTotallyOrdered;
|
||||
using experimental::ranges::ConvertibleTo;
|
||||
using experimental::ranges::same_as;
|
||||
using experimental::ranges::derived_from;
|
||||
using experimental::ranges::regular;
|
||||
using experimental::ranges::totally_ordered;
|
||||
using experimental::ranges::convertible_to;
|
||||
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ namespace std::experimental::units {
|
||||
template<> struct downcasting_traits<downcast_from<acceleration>> : downcast_to<acceleration> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Acceleration = Quantity<T> && std::Same<typename T::dimension, acceleration>;
|
||||
concept bool Acceleration = Quantity<T> && std::same_as<typename T::dimension, acceleration>;
|
||||
|
||||
struct metre_per_second_sq : derived_unit<acceleration, metre, second> {};
|
||||
template<> struct downcasting_traits<downcast_from<metre_per_second_sq>> : downcast_to<metre_per_second_sq> {};
|
||||
|
@ -30,7 +30,7 @@ namespace std::experimental::units {
|
||||
template<> struct downcasting_traits<downcast_from<area>> : downcast_to<area> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Area = Quantity<T> && std::Same<typename T::dimension, area>;
|
||||
concept bool Area = Quantity<T> && std::same_as<typename T::dimension, area>;
|
||||
|
||||
struct square_millimetre : derived_unit<area, millimetre> {};
|
||||
template<> struct downcasting_traits<downcast_from<square_millimetre>> : downcast_to<square_millimetre> {};
|
||||
|
@ -32,7 +32,7 @@ namespace std::experimental::units {
|
||||
template<> struct downcasting_traits<downcast_from<capacitance>> : downcast_to<capacitance> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Capacitance = Quantity<T> && std::Same<typename T::dimension, capacitance>;
|
||||
concept bool Capacitance = Quantity<T> && std::same_as<typename T::dimension, capacitance>;
|
||||
|
||||
struct farad : derived_unit<capacitance, kilogram, metre, second, ampere> {};
|
||||
template<> struct downcasting_traits<downcast_from<farad>> : downcast_to<farad> {};
|
||||
|
@ -31,7 +31,7 @@ namespace std::experimental::units {
|
||||
template<> struct downcasting_traits<downcast_from<current>> : downcast_to<current> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Current = Quantity<T> && std::Same<typename T::dimension, current>;
|
||||
concept bool Current = Quantity<T> && std::same_as<typename T::dimension, current>;
|
||||
|
||||
struct ampere : unit<current> {};
|
||||
template<> struct downcasting_traits<downcast_from<ampere>> : downcast_to<ampere> {};
|
||||
|
@ -32,7 +32,7 @@ namespace std::experimental::units {
|
||||
template<> struct downcasting_traits<downcast_from<electric_charge>> : downcast_to<electric_charge> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool ElectricCharge = Quantity<T> && std::Same<typename T::dimension, electric_charge>;
|
||||
concept bool ElectricCharge = Quantity<T> && std::same_as<typename T::dimension, electric_charge>;
|
||||
|
||||
struct coulomb : derived_unit<electric_charge, second, ampere> {};
|
||||
template<> struct downcasting_traits<downcast_from<coulomb>> : downcast_to<coulomb> {};
|
||||
|
@ -32,7 +32,7 @@ namespace std::experimental::units {
|
||||
template<> struct downcasting_traits<downcast_from<energy>> : downcast_to<energy> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Energy = Quantity<T> && std::Same<typename T::dimension, energy>;
|
||||
concept bool Energy = Quantity<T> && std::same_as<typename T::dimension, energy>;
|
||||
|
||||
struct joule : derived_unit<energy, kilogram, metre, second> {};
|
||||
template<> struct downcasting_traits<downcast_from<joule>> : downcast_to<joule> {};
|
||||
|
@ -33,7 +33,7 @@ namespace std::experimental::units {
|
||||
template<> struct downcasting_traits<downcast_from<force>> : downcast_to<force> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Force = Quantity<T> && std::Same<typename T::dimension, force>;
|
||||
concept bool Force = Quantity<T> && std::same_as<typename T::dimension, force>;
|
||||
|
||||
struct newton : derived_unit<force, kilogram, metre, second> {};
|
||||
template<> struct downcasting_traits<downcast_from<newton>> : downcast_to<newton> {};
|
||||
|
@ -31,7 +31,7 @@ namespace std::experimental::units {
|
||||
template<> struct downcasting_traits<downcast_from<frequency>> : downcast_to<frequency> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Frequency = Quantity<T> && std::Same<typename T::dimension, frequency>;
|
||||
concept bool Frequency = Quantity<T> && std::same_as<typename T::dimension, frequency>;
|
||||
|
||||
struct hertz : derived_unit<frequency, second> {};
|
||||
template<> struct downcasting_traits<downcast_from<hertz>> : downcast_to<hertz> {};
|
||||
|
@ -31,7 +31,7 @@ namespace std::experimental::units {
|
||||
template<> struct downcasting_traits<downcast_from<length>> : downcast_to<length> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Length = Quantity<T> && std::Same<typename T::dimension, length>;
|
||||
concept bool Length = Quantity<T> && std::same_as<typename T::dimension, length>;
|
||||
|
||||
// SI units
|
||||
struct metre : unit<length> {};
|
||||
|
@ -31,7 +31,7 @@ namespace std::experimental::units {
|
||||
template<> struct downcasting_traits<downcast_from<luminous_intensity>> : downcast_to<luminous_intensity> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool LuminousIntensity = Quantity<T> && std::Same<typename T::dimension, luminous_intensity>;
|
||||
concept bool LuminousIntensity = Quantity<T> && std::same_as<typename T::dimension, luminous_intensity>;
|
||||
|
||||
struct candela : unit<luminous_intensity> {};
|
||||
template<> struct downcasting_traits<downcast_from<candela>> : downcast_to<candela> {};
|
||||
|
@ -31,7 +31,7 @@ namespace std::experimental::units {
|
||||
template<> struct downcasting_traits<downcast_from<mass>> : downcast_to<mass> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Mass = Quantity<T> && std::Same<typename T::dimension, mass>;
|
||||
concept bool Mass = Quantity<T> && std::same_as<typename T::dimension, mass>;
|
||||
|
||||
struct gram : unit<mass, ratio<1, 1000>> {};
|
||||
template<> struct downcasting_traits<downcast_from<gram>> : downcast_to<gram> {};
|
||||
|
@ -31,7 +31,7 @@ namespace std::experimental::units {
|
||||
template<> struct downcasting_traits<downcast_from<power>> : downcast_to<power> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Power = Quantity<T> && std::Same<typename T::dimension, power>;
|
||||
concept bool Power = Quantity<T> && std::same_as<typename T::dimension, power>;
|
||||
|
||||
struct watt : derived_unit<power, kilogram, metre, second> {};
|
||||
template<> struct downcasting_traits<downcast_from<watt>> : downcast_to<watt> {};
|
||||
|
@ -31,7 +31,7 @@ namespace std::experimental::units {
|
||||
template<> struct downcasting_traits<downcast_from<pressure>> : downcast_to<pressure> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Pressure = Quantity<T> && std::Same<typename T::dimension, pressure>;
|
||||
concept bool Pressure = Quantity<T> && std::same_as<typename T::dimension, pressure>;
|
||||
|
||||
struct pascal : derived_unit<pressure, kilogram, metre, second> {};
|
||||
template<> struct downcasting_traits<downcast_from<pascal>> : downcast_to<pascal> {};
|
||||
|
@ -31,7 +31,7 @@ namespace std::experimental::units {
|
||||
template<> struct downcasting_traits<downcast_from<substance>> : downcast_to<substance> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Substance = Quantity<T> && std::Same<typename T::dimension, substance>;
|
||||
concept bool Substance = Quantity<T> && std::same_as<typename T::dimension, substance>;
|
||||
|
||||
struct mole : unit<substance> {};
|
||||
template<> struct downcasting_traits<downcast_from<mole>> : downcast_to<mole> {};
|
||||
|
@ -31,7 +31,7 @@ namespace std::experimental::units {
|
||||
template<> struct downcasting_traits<downcast_from<temperature>> : downcast_to<temperature> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool ThermodynamicTemperature = Quantity<T> && std::Same<typename T::dimension, temperature>;
|
||||
concept bool ThermodynamicTemperature = Quantity<T> && std::same_as<typename T::dimension, temperature>;
|
||||
|
||||
struct kelvin : unit<temperature> {};
|
||||
template<> struct downcasting_traits<downcast_from<kelvin>> : downcast_to<kelvin> {};
|
||||
|
@ -31,7 +31,7 @@ namespace std::experimental::units {
|
||||
template<> struct downcasting_traits<downcast_from<time>> : downcast_to<time> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Time = Quantity<T> && std::Same<typename T::dimension, time>;
|
||||
concept bool Time = Quantity<T> && std::same_as<typename T::dimension, time>;
|
||||
|
||||
struct second : unit<time> {};
|
||||
template<> struct downcasting_traits<downcast_from<second>> : downcast_to<second> {};
|
||||
|
@ -31,7 +31,7 @@ namespace std::experimental::units {
|
||||
template<> struct downcasting_traits<downcast_from<velocity>> : downcast_to<velocity> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Velocity = Quantity<T> && std::Same<typename T::dimension, velocity>;
|
||||
concept bool Velocity = Quantity<T> && std::same_as<typename T::dimension, velocity>;
|
||||
|
||||
struct metre_per_second : derived_unit<velocity, metre, second> {};
|
||||
template<> struct downcasting_traits<downcast_from<metre_per_second>> : downcast_to<metre_per_second> {};
|
||||
|
@ -34,7 +34,7 @@ namespace std::experimental::units {
|
||||
template<> struct downcasting_traits<downcast_from<voltage>> : downcast_to<voltage> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Voltage = Quantity<T> && std::Same<typename T::dimension, voltage>;
|
||||
concept bool Voltage = Quantity<T> && std::same_as<typename T::dimension, voltage>;
|
||||
|
||||
struct volt : derived_unit<voltage, kilogram, metre, second, ampere> {};
|
||||
template<> struct downcasting_traits<downcast_from<volt>> : downcast_to<volt> {};
|
||||
|
@ -30,7 +30,7 @@ namespace std::experimental::units {
|
||||
template<> struct downcasting_traits<downcast_from<volume>> : downcast_to<volume> {};
|
||||
|
||||
template<typename T>
|
||||
concept bool Volume = Quantity<T> && std::Same<typename T::dimension, volume>;
|
||||
concept bool Volume = Quantity<T> && std::same_as<typename T::dimension, volume>;
|
||||
|
||||
struct cubic_millimetre : derived_unit<volume, millimetre> {};
|
||||
template<> struct downcasting_traits<downcast_from<cubic_millimetre>> : downcast_to<cubic_millimetre> {};
|
||||
|
@ -67,7 +67,7 @@ namespace std::experimental::units {
|
||||
};
|
||||
|
||||
template<typename U1, typename Rep1, typename U2, typename Rep2, typename Rep>
|
||||
requires std::Same<typename U1::dimension, typename U2::dimension>
|
||||
requires std::same_as<typename U1::dimension, typename U2::dimension>
|
||||
struct common_quantity<quantity<U1, Rep1>, quantity<U2, Rep2>, Rep> {
|
||||
using type = quantity<downcasting_traits_t<unit<typename U1::dimension, common_ratio<typename U1::ratio, typename U2::ratio>>>, Rep>;
|
||||
};
|
||||
@ -124,7 +124,7 @@ namespace std::experimental::units {
|
||||
} // namespace detail
|
||||
|
||||
template<Quantity To, typename U, typename Rep>
|
||||
requires std::Same<typename To::dimension, typename U::dimension>
|
||||
requires std::same_as<typename To::dimension, typename U::dimension>
|
||||
constexpr To quantity_cast(const quantity<U, Rep>& q)
|
||||
{
|
||||
using c_ratio = ratio_divide<typename U::ratio, typename To::unit::ratio>;
|
||||
@ -159,15 +159,15 @@ namespace std::experimental::units {
|
||||
quantity() = default;
|
||||
quantity(const quantity&) = default;
|
||||
|
||||
template<std::ConvertibleTo<rep> Rep2>
|
||||
template<std::convertible_to<rep> Rep2>
|
||||
requires treat_as_floating_point<rep> || (!treat_as_floating_point<Rep2>)
|
||||
constexpr explicit quantity(const Rep2& r) : value_{static_cast<rep>(r)}
|
||||
{
|
||||
}
|
||||
|
||||
template<Quantity Q2>
|
||||
requires std::Same<dimension, typename Q2::dimension> &&
|
||||
std::ConvertibleTo<typename Q2::rep, rep> &&
|
||||
requires std::same_as<dimension, typename Q2::dimension> &&
|
||||
std::convertible_to<typename Q2::rep, rep> &&
|
||||
(treat_as_floating_point<rep> ||
|
||||
(std::ratio_divide<typename Q2::unit::ratio, typename unit::ratio>::den == 1 &&
|
||||
!treat_as_floating_point<typename Q2::rep>))
|
||||
@ -242,7 +242,7 @@ namespace std::experimental::units {
|
||||
template<typename U1, typename Rep1, typename U2, typename Rep2>
|
||||
[[nodiscard]] constexpr Quantity operator+(const quantity<U1, Rep1>& lhs,
|
||||
const quantity<U2, Rep2>& rhs)
|
||||
requires std::Same<typename U1::dimension, typename U2::dimension>
|
||||
requires std::same_as<typename U1::dimension, typename U2::dimension>
|
||||
{
|
||||
using common_rep = decltype(lhs.count() + rhs.count());
|
||||
using ret = common_quantity_t<quantity<U1, Rep1>, quantity<U2, Rep2>, common_rep>;
|
||||
@ -252,7 +252,7 @@ namespace std::experimental::units {
|
||||
template<typename U1, typename Rep1, typename U2, typename Rep2>
|
||||
[[nodiscard]] constexpr Quantity operator-(const quantity<U1, Rep1>& lhs,
|
||||
const quantity<U2, Rep2>& rhs)
|
||||
requires std::Same<typename U1::dimension, typename U2::dimension>
|
||||
requires std::same_as<typename U1::dimension, typename U2::dimension>
|
||||
{
|
||||
using common_rep = decltype(lhs.count() - rhs.count());
|
||||
using ret = common_quantity_t<quantity<U1, Rep1>, quantity<U2, Rep2>, common_rep>;
|
||||
@ -282,7 +282,7 @@ namespace std::experimental::units {
|
||||
template<typename U1, typename Rep1, typename U2, typename Rep2>
|
||||
[[nodiscard]] constexpr Scalar operator*(const quantity<U1, Rep1>& lhs,
|
||||
const quantity<U2, Rep2>& rhs)
|
||||
requires std::Same<typename U1::dimension, dim_invert_t<typename U2::dimension>>
|
||||
requires std::same_as<typename U1::dimension, dim_invert_t<typename U2::dimension>>
|
||||
{
|
||||
using common_rep = decltype(lhs.count() * rhs.count());
|
||||
using ratio = ratio_multiply<typename U1::ratio, typename U2::ratio>;
|
||||
@ -292,7 +292,7 @@ namespace std::experimental::units {
|
||||
template<typename U1, typename Rep1, typename U2, typename Rep2>
|
||||
[[nodiscard]] constexpr Quantity operator*(const quantity<U1, Rep1>& lhs,
|
||||
const quantity<U2, Rep2>& rhs)
|
||||
requires (!std::Same<typename U1::dimension, dim_invert_t<typename U2::dimension>>) &&
|
||||
requires (!std::same_as<typename U1::dimension, dim_invert_t<typename U2::dimension>>) &&
|
||||
(treat_as_floating_point<decltype(lhs.count() * rhs.count())> ||
|
||||
(std::ratio_multiply<typename U1::ratio, typename U2::ratio>::den == 1))
|
||||
{
|
||||
@ -333,7 +333,7 @@ namespace std::experimental::units {
|
||||
template<typename U1, typename Rep1, typename U2, typename Rep2>
|
||||
[[nodiscard]] constexpr Scalar operator/(const quantity<U1, Rep1>& lhs,
|
||||
const quantity<U2, Rep2>& rhs)
|
||||
requires std::Same<typename U1::dimension, typename U2::dimension>
|
||||
requires std::same_as<typename U1::dimension, typename U2::dimension>
|
||||
{
|
||||
Expects(rhs != std::remove_cvref_t<decltype(rhs)>(0));
|
||||
|
||||
@ -345,7 +345,7 @@ namespace std::experimental::units {
|
||||
template<typename U1, typename Rep1, typename U2, typename Rep2>
|
||||
[[nodiscard]] constexpr Quantity operator/(const quantity<U1, Rep1>& lhs,
|
||||
const quantity<U2, Rep2>& rhs)
|
||||
requires (!std::Same<typename U1::dimension, typename U2::dimension>) &&
|
||||
requires (!std::same_as<typename U1::dimension, typename U2::dimension>) &&
|
||||
(treat_as_floating_point<decltype(lhs.count() / rhs.count())> ||
|
||||
(ratio_divide<typename U1::ratio, typename U2::ratio>::den == 1))
|
||||
{
|
||||
@ -379,7 +379,7 @@ namespace std::experimental::units {
|
||||
|
||||
template<typename U1, typename Rep1, typename U2, typename Rep2>
|
||||
[[nodiscard]] constexpr bool operator==(const quantity<U1, Rep1>& lhs, const quantity<U2, Rep2>& rhs)
|
||||
requires std::Same<typename U1::dimension, typename U2::dimension>
|
||||
requires std::same_as<typename U1::dimension, typename U2::dimension>
|
||||
{
|
||||
using ct = common_quantity_t<quantity<U1, Rep1>, quantity<U2, Rep2>>;
|
||||
return ct(lhs).count() == ct(rhs).count();
|
||||
@ -387,14 +387,14 @@ namespace std::experimental::units {
|
||||
|
||||
template<typename U1, typename Rep1, typename U2, typename Rep2>
|
||||
[[nodiscard]] constexpr bool operator!=(const quantity<U1, Rep1>& lhs, const quantity<U2, Rep2>& rhs)
|
||||
requires std::Same<typename U1::dimension, typename U2::dimension>
|
||||
requires std::same_as<typename U1::dimension, typename U2::dimension>
|
||||
{
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
template<typename U1, typename Rep1, typename U2, typename Rep2>
|
||||
[[nodiscard]] constexpr bool operator<(const quantity<U1, Rep1>& lhs, const quantity<U2, Rep2>& rhs)
|
||||
requires std::Same<typename U1::dimension, typename U2::dimension>
|
||||
requires std::same_as<typename U1::dimension, typename U2::dimension>
|
||||
{
|
||||
using ct = common_quantity_t<quantity<U1, Rep1>, quantity<U2, Rep2>>;
|
||||
return ct(lhs).count() < ct(rhs).count();
|
||||
@ -402,21 +402,21 @@ namespace std::experimental::units {
|
||||
|
||||
template<typename U1, typename Rep1, typename U2, typename Rep2>
|
||||
[[nodiscard]] constexpr bool operator<=(const quantity<U1, Rep1>& lhs, const quantity<U2, Rep2>& rhs)
|
||||
requires std::Same<typename U1::dimension, typename U2::dimension>
|
||||
requires std::same_as<typename U1::dimension, typename U2::dimension>
|
||||
{
|
||||
return !(rhs < lhs);
|
||||
}
|
||||
|
||||
template<typename U1, typename Rep1, typename U2, typename Rep2>
|
||||
[[nodiscard]] constexpr bool operator>(const quantity<U1, Rep1>& lhs, const quantity<U2, Rep2>& rhs)
|
||||
requires std::Same<typename U1::dimension, typename U2::dimension>
|
||||
requires std::same_as<typename U1::dimension, typename U2::dimension>
|
||||
{
|
||||
return rhs < lhs;
|
||||
}
|
||||
|
||||
template<typename U1, typename Rep1, typename U2, typename Rep2>
|
||||
[[nodiscard]] constexpr bool operator>=(const quantity<U1, Rep1>& lhs, const quantity<U2, Rep2>& rhs)
|
||||
requires std::Same<typename U1::dimension, typename U2::dimension>
|
||||
requires std::same_as<typename U1::dimension, typename U2::dimension>
|
||||
{
|
||||
return !(lhs < rhs);
|
||||
}
|
||||
|
Reference in New Issue
Block a user