/** @file quantity_ops.hpp * * Author: Roland Conybeare **/ #pragma once #include "quantity_concept.hpp" namespace xo { namespace qty { /** @defgroup quantity-dimensionless-operators **/ ///@{ /** subtract an arithmetic value from a dimensionless quantity **/ template requires (quantity_concept && Quantity::is_dimensionless() && std::is_arithmetic_v) constexpr auto operator- (const Quantity & x, Dimensionless y) { using repr_type = std::common_type_t; auto xp = static_cast(x.scale()); auto yp = static_cast(y); return xp - yp; } /** subtract a dimensionless quantity from an arithmetic value **/ template requires (std::is_arithmetic_v && quantity_concept && Quantity::is_dimensionless()) constexpr auto operator- (Dimensionless x, const Quantity & y) { using repr_type = std::common_type_t; auto xp = static_cast(x); auto yp = static_cast(y.scale()); return xp - yp; } ///@} /** note: won't have constexpr result until c++26 (when ::sqrt(), ::pow() are constexpr) **/ template requires quantity_concept && quantity_concept constexpr auto operator== (const Quantity & x, const Quantity2 & y) { return (Quantity::compare(x, y) == 0); } /** note: won't have constexpr result until c++26 (when ::sqrt(), ::pow() are constexpr) **/ template requires quantity_concept && quantity_concept constexpr auto operator<=> (const Quantity & x, const Quantity2 & y) { return Quantity::compare(x, y); } } /*namespace qty*/ } /*namespace xo*/ /** end quantity_ops.hpp **/