feat: quantity_values are now defined on top of std::chrono::duration_values

This commit is contained in:
Mateusz Pusz
2024-10-28 16:08:56 +01:00
parent 4651c61be4
commit 08f90ba474

View File

@ -115,6 +115,9 @@ constexpr bool is_tensor = false;
* @tparam Rep a representation type for which a type trait is defined * @tparam Rep a representation type for which a type trait is defined
*/ */
template<typename Rep> template<typename Rep>
#if MP_UNITS_HOSTED
struct quantity_values : std::chrono::duration_values<Rep> {
#else
struct quantity_values { struct quantity_values {
static constexpr Rep zero() noexcept static constexpr Rep zero() noexcept
requires std::constructible_from<Rep, int> requires std::constructible_from<Rep, int>
@ -122,12 +125,6 @@ struct quantity_values {
return Rep(0); return Rep(0);
} }
static constexpr Rep one() noexcept
requires std::constructible_from<Rep, int>
{
return Rep(1);
}
static constexpr Rep min() noexcept static constexpr Rep min() noexcept
requires requires { requires requires {
{ std::numeric_limits<Rep>::lowest() } -> std::same_as<Rep>; { std::numeric_limits<Rep>::lowest() } -> std::same_as<Rep>;
@ -143,6 +140,13 @@ struct quantity_values {
{ {
return std::numeric_limits<Rep>::max(); return std::numeric_limits<Rep>::max();
} }
#endif
static constexpr Rep one() noexcept
requires std::constructible_from<Rep, int>
{
return Rep(1);
}
}; };
template<typename T> template<typename T>