mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-05 21:24:27 +02:00
fix: Added constraints for quantity_values
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <units/bits/external/hacks.h>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
@@ -54,10 +55,21 @@ inline constexpr bool treat_as_floating_point<T> = treat_as_floating_point<typen
|
|||||||
*/
|
*/
|
||||||
template<typename Rep>
|
template<typename Rep>
|
||||||
struct quantity_values {
|
struct quantity_values {
|
||||||
static constexpr Rep zero() noexcept { return Rep(0); }
|
static constexpr Rep zero() noexcept
|
||||||
static constexpr Rep one() noexcept { return Rep(1); }
|
requires std::constructible_from<Rep, int>
|
||||||
static constexpr Rep min() noexcept { return std::numeric_limits<Rep>::lowest(); }
|
{ return Rep(0); }
|
||||||
static constexpr Rep max() noexcept { return std::numeric_limits<Rep>::max(); }
|
|
||||||
|
static constexpr Rep one() noexcept
|
||||||
|
requires std::constructible_from<Rep, int>
|
||||||
|
{ return Rep(1); }
|
||||||
|
|
||||||
|
static constexpr Rep min() noexcept
|
||||||
|
requires requires { { std::numeric_limits<Rep>::lowest() } -> std::same_as<Rep>; }
|
||||||
|
{ return std::numeric_limits<Rep>::lowest(); }
|
||||||
|
|
||||||
|
static constexpr Rep max() noexcept
|
||||||
|
requires requires { { std::numeric_limits<Rep>::max() } -> std::same_as<Rep>; }
|
||||||
|
{ return std::numeric_limits<Rep>::max(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user