mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 12:54:25 +02:00
refactor: abs
moved to constexpr_math.h
This commit is contained in:
@@ -39,6 +39,12 @@ import std;
|
||||
|
||||
namespace mp_units::detail {
|
||||
|
||||
template<typename T>
|
||||
[[nodiscard]] MP_UNITS_CONSTEVAL T abs(T v) noexcept
|
||||
{
|
||||
return v < 0 ? -v : v;
|
||||
}
|
||||
|
||||
// Raise an arbitrary arithmetic type to a positive integer power at compile time.
|
||||
template<typename T>
|
||||
[[nodiscard]] consteval T int_power(T base, std::integral auto exp)
|
||||
|
@@ -22,6 +22,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mp-units/bits/constexpr_math.h>
|
||||
#include <mp-units/bits/hacks.h>
|
||||
#include <mp-units/bits/module_macros.h>
|
||||
#include <mp-units/compat_macros.h>
|
||||
@@ -39,12 +40,6 @@ import std;
|
||||
|
||||
namespace mp_units::detail {
|
||||
|
||||
template<typename T>
|
||||
[[nodiscard]] MP_UNITS_CONSTEVAL T abs(T v) noexcept
|
||||
{
|
||||
return v < 0 ? -v : v;
|
||||
}
|
||||
|
||||
[[nodiscard]] consteval std::intmax_t safe_multiply(std::intmax_t lhs, std::intmax_t rhs)
|
||||
{
|
||||
constexpr std::intmax_t c = std::uintmax_t{1} << (sizeof(std::intmax_t) * 4);
|
||||
|
Reference in New Issue
Block a user