mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 20:54:28 +02:00
feat: magnitude
now uses treat_as_floating_point
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
#include <units/bits/external/type_traits.h>
|
#include <units/bits/external/type_traits.h>
|
||||||
#include <units/bits/math_concepts.h>
|
#include <units/bits/math_concepts.h>
|
||||||
#include <units/bits/prime.h>
|
#include <units/bits/prime.h>
|
||||||
|
#include <units/customization_points.h>
|
||||||
#include <units/ratio.h>
|
#include <units/ratio.h>
|
||||||
#include <units/symbol_text.h>
|
#include <units/symbol_text.h>
|
||||||
#include <concepts>
|
#include <concepts>
|
||||||
@@ -488,8 +489,7 @@ inline constexpr bool is_specialization_of_magnitude<magnitude<Ms...>> = true;
|
|||||||
* @brief The value of a Magnitude in a desired type T.
|
* @brief The value of a Magnitude in a desired type T.
|
||||||
*/
|
*/
|
||||||
template<typename T, auto... Ms>
|
template<typename T, auto... Ms>
|
||||||
// TODO(chogg): Migrate this to use `treat_as_floating_point`.
|
requires(is_integral(magnitude<Ms...>{})) || treat_as_floating_point<T>
|
||||||
requires(!std::integral<T> || is_integral(magnitude<Ms...>{}))
|
|
||||||
constexpr T get_value(const magnitude<Ms...>&)
|
constexpr T get_value(const magnitude<Ms...>&)
|
||||||
{
|
{
|
||||||
// Force the expression to be evaluated in a constexpr context, to catch, e.g., overflow.
|
// Force the expression to be evaluated in a constexpr context, to catch, e.g., overflow.
|
||||||
|
Reference in New Issue
Block a user