mirror of
https://github.com/mpusz/mp-units.git
synced 2025-08-04 04:44:27 +02:00
feat: pow
, sqrt
, and cbrt
support added for reference
This commit is contained in:
@@ -106,6 +106,40 @@ struct reference {
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Computes the value of a reference raised to the `Num/Den` power
|
||||
*
|
||||
* @tparam Num Exponent numerator
|
||||
* @tparam Den Exponent denominator
|
||||
* @param r Reference being the base of the operation
|
||||
*
|
||||
* @return The result of computation
|
||||
*/
|
||||
template<std::intmax_t Num, std::intmax_t Den = 1>
|
||||
requires detail::non_zero<Den>
|
||||
[[nodiscard]] friend consteval reference<pow<Num, Den>(Q), pow<Num, Den>(U)> pow(reference)
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Computes the square root of a reference
|
||||
*
|
||||
* @param r Reference being the base of the operation
|
||||
*
|
||||
* @return The result of computation
|
||||
*/
|
||||
[[nodiscard]] friend consteval reference<sqrt(Q), sqrt(U)> sqrt(reference) { return {}; }
|
||||
|
||||
/**
|
||||
* @brief Computes the cubic root of a reference
|
||||
*
|
||||
* @param r Reference being the base of the operation
|
||||
*
|
||||
* @return The result of computation
|
||||
*/
|
||||
[[nodiscard]] friend consteval reference<cbrt(Q), cbrt(U)> cbrt(reference) { return {}; }
|
||||
|
||||
template<auto Q2, auto U2>
|
||||
[[nodiscard]] friend consteval bool convertible(reference, reference<Q2, U2>)
|
||||
{
|
||||
|
Reference in New Issue
Block a user