xo-unit: quantity refactoring
This commit is contained in:
parent
b0ce5eaee9
commit
b2d7bf93d2
3 changed files with 52 additions and 46 deletions
|
|
@ -9,45 +9,6 @@
|
|||
|
||||
namespace xo {
|
||||
namespace qty {
|
||||
/** @defgroup quantity-dimensionless-operators **/
|
||||
///@{
|
||||
|
||||
/** subtract an arithmetic value from a dimensionless quantity **/
|
||||
template <typename Quantity,
|
||||
typename Dimensionless>
|
||||
requires (quantity_concept<Quantity>
|
||||
&& Quantity::is_dimensionless()
|
||||
&& std::is_arithmetic_v<Dimensionless>)
|
||||
constexpr auto
|
||||
operator- (const Quantity & x, Dimensionless y)
|
||||
{
|
||||
using repr_type = std::common_type_t<typename Quantity::repr_type, Dimensionless>;
|
||||
|
||||
auto xp = static_cast<repr_type>(x.scale());
|
||||
auto yp = static_cast<repr_type>(y);
|
||||
|
||||
return xp - yp;
|
||||
}
|
||||
|
||||
/** subtract a dimensionless quantity from an arithmetic value **/
|
||||
template <typename Dimensionless,
|
||||
typename Quantity>
|
||||
requires (std::is_arithmetic_v<Dimensionless>
|
||||
&& quantity_concept<Quantity>
|
||||
&& Quantity::is_dimensionless())
|
||||
constexpr auto
|
||||
operator- (Dimensionless x, const Quantity & y)
|
||||
{
|
||||
using repr_type = std::common_type_t<Dimensionless, typename Quantity::repr_type>;
|
||||
|
||||
auto xp = static_cast<repr_type>(x);
|
||||
auto yp = static_cast<repr_type>(y.scale());
|
||||
|
||||
return xp - yp;
|
||||
}
|
||||
|
||||
///@}
|
||||
|
||||
/** note: won't have constexpr result until c++26 (when ::sqrt(), ::pow() are constexpr)
|
||||
**/
|
||||
template <typename Quantity, typename Quantity2>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue