Feat: Overloads for floor and ceil accepting quantities (#314)
* feat: overloads for floor and ceil accepting quantities * require same type for dim and rep * be specific for msvc
This commit is contained in:
1 parent
3f28b55ab1
commit
50b9050d6b
3 files changed
+48
No files matched your search
@@ -187,6 +187,23 @@ template<Unit To, typename D, typename U, typename Rep>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Overload of @c ::units::floor<Unit>() using the unit type of To
|
||||
*
|
||||
* @tparam q Quantity being the base of the operation
|
||||
* @return Quantity The rounded quantity with unit type of quantity To
|
||||
*/
|
||||
template<Quantity To, typename D, typename U, typename Rep>
|
||||
[[nodiscard]] constexpr quantity<D, typename To::unit, Rep> floor(const quantity<D, U, Rep>& q) noexcept
|
||||
requires std::same_as<typename To::dimension, D> &&
|
||||
std::same_as<typename To::rep, Rep> &&
|
||||
requires {
|
||||
::units::floor<typename To::unit>(q);
|
||||
}
|
||||
{
|
||||
return ::units::floor<typename To::unit>(q);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Computes the smallest quantity with integer representation and unit type To with its number not less than q
|
||||
*
|
||||
@@ -227,4 +244,21 @@ template<Unit To, typename D, typename U, typename Rep>
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Overload of @c ::units::ceil<Unit>() using the unit type of To
|
||||
*
|
||||
* @tparam q Quantity being the base of the operation
|
||||
* @return Quantity The rounded quantity with unit type of quantity To
|
||||
*/
|
||||
template<Quantity To, typename D, typename U, typename Rep>
|
||||
[[nodiscard]] constexpr quantity<D, typename To::unit, Rep> ceil(const quantity<D, U, Rep>& q) noexcept
|
||||
requires std::same_as<typename To::dimension, D> &&
|
||||
std::same_as<typename To::rep, Rep> &&
|
||||
requires {
|
||||
::units::ceil<typename To::unit>(q);
|
||||
}
|
||||
{
|
||||
return ::units::ceil<typename To::unit>(q);
|
||||
}
|
||||
|
||||
} // namespace units
|
||||
Reference in new issue
Block a user