forked from mpusz/mp-units
Template parameters constraints added for math.h
This commit is contained in:
@ -30,13 +30,16 @@
|
|||||||
namespace units {
|
namespace units {
|
||||||
|
|
||||||
template<std::intmax_t N, typename D, typename U, typename Rep>
|
template<std::intmax_t N, typename D, typename U, typename Rep>
|
||||||
requires(N == 0) inline Rep pow(const quantity<D, U, Rep>&) noexcept
|
requires(N == 0)
|
||||||
|
inline Rep pow(const quantity<D, U, Rep>&) noexcept
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<std::intmax_t N, typename D, typename U, typename Rep>
|
template<std::intmax_t N, typename D, typename U, typename Rep>
|
||||||
|
requires(N != 0)
|
||||||
inline Quantity AUTO pow(const quantity<D, U, Rep>& q) noexcept
|
inline Quantity AUTO pow(const quantity<D, U, Rep>& q) noexcept
|
||||||
|
requires requires { std::pow(q.count(), N); }
|
||||||
{
|
{
|
||||||
using dim = dimension_pow<D, N>;
|
using dim = dimension_pow<D, N>;
|
||||||
using ratio = ratio_pow<typename U::ratio, N>;
|
using ratio = ratio_pow<typename U::ratio, N>;
|
||||||
@ -46,6 +49,7 @@ inline Quantity AUTO pow(const quantity<D, U, Rep>& q) noexcept
|
|||||||
|
|
||||||
template<typename D, typename U, typename Rep>
|
template<typename D, typename U, typename Rep>
|
||||||
inline Quantity AUTO sqrt(const quantity<D, U, Rep>& q) noexcept
|
inline Quantity AUTO sqrt(const quantity<D, U, Rep>& q) noexcept
|
||||||
|
requires requires { std::sqrt(q.count()); }
|
||||||
{
|
{
|
||||||
using dim = dimension_sqrt<D>;
|
using dim = dimension_sqrt<D>;
|
||||||
using ratio = ratio_sqrt<typename U::ratio>;
|
using ratio = ratio_sqrt<typename U::ratio>;
|
||||||
@ -55,11 +59,13 @@ inline Quantity AUTO sqrt(const quantity<D, U, Rep>& q) noexcept
|
|||||||
|
|
||||||
template<typename D, typename U, typename Rep>
|
template<typename D, typename U, typename Rep>
|
||||||
constexpr Quantity AUTO abs(const quantity<D, U, Rep>& q) noexcept
|
constexpr Quantity AUTO abs(const quantity<D, U, Rep>& q) noexcept
|
||||||
|
requires requires { std::abs(q.count()); }
|
||||||
{
|
{
|
||||||
return quantity<D, U, Rep>(std::abs(q.count()));
|
return quantity<D, U, Rep>(std::abs(q.count()));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<Quantity Q>
|
template<Quantity Q>
|
||||||
|
requires requires { std::numeric_limits<typename Q::rep>::epsilon(); }
|
||||||
constexpr Quantity AUTO epsilon() noexcept
|
constexpr Quantity AUTO epsilon() noexcept
|
||||||
{
|
{
|
||||||
return Q(std::numeric_limits<typename Q::rep>::epsilon());
|
return Q(std::numeric_limits<typename Q::rep>::epsilon());
|
||||||
|
Reference in New Issue
Block a user