Skip to content

Commit

Permalink
xquantity: + (xquantity, double) overloads for operator==
Browse files Browse the repository at this point in the history
  • Loading branch information
Rconybea committed May 1, 2024
1 parent 9438456 commit 022bef0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions include/xo/unit/xquantity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,26 @@ namespace xo {
return (Quantity::compare(x, y) == 0);
}

/** note: won't have constexpr result until c++26 (when ::sqrt(), ::pow() are constexpr)
**/
template <typename Quantity>
requires quantity2_concept<Quantity>
constexpr auto
operator== (const Quantity & x, double y)
{
return (x == Quantity(y, nu::dimensionless));
}

/** note: won't have constexpr result until c++26 (when ::sqrt(), ::pow() are constexpr)
**/
template <typename Quantity>
requires quantity2_concept<Quantity>
constexpr auto
operator== (double x, const Quantity & y)
{
return (Quantity(x, nu::dimensionless) == y);
}

/** note: won't have constexpr result until c++26 (when ::sqrt(), ::pow() are constexpr)
**/
template <typename Quantity, typename Quantity2>
Expand Down

0 comments on commit 022bef0

Please sign in to comment.