19#define R(...) reduce<__VA_ARGS__>
29 template<
typename U,
typename T>
37 return value * U::template factor<T>::numerator / U::template factor<T>::denominator;
66 bool operator<(
const T1& rhl)
const {
67 return this->
value < rhl;
72 bool operator==(
const T1& rhl)
const {
73 return this->
value == rhl;
91 return {this->
value / rhl};
100 template<
typename U1>
106 template<
typename T1>
109 return {this->
value * rhl};
112 template<
typename U1,
typename T1>
118 template<
typename U1,
typename T1>
125 template<
typename U1,
typename T1>
131 template<
typename U1,
typename T1>
139 return {-(this->
value)};
148 template <
typename T1>
154 template <
typename U1,
typename T1>
156 not std::same_as<
R(U),
R(U1)> &&
165 template <
typename T1>
172 template <
typename U1,
typename T1>
174 not std::same_as<
R(U),
R(U1)> &&
184 template <
typename T1>
186 this->
value = other.value;
190 template <
typename U1,
typename T1>
192 not std::same_as<
R(U),
R(U1)> &&
201 template <
typename T1>
203 this->
value = rhl.value;
208 template <
typename U1,
typename T1>
210 not std::same_as<
R(U),
R(U1)> &&
220 template<
typename U1>
224 if constexpr (std::is_same_v<U, U1>) {
229 * (U1::template factor<T>::denominator
230 * U::template factor<T>::numerator)
231 / (U1::template factor<T>::numerator
232 * U::template factor<T>::denominator)
247 static_assert(
false,
"No conversion factor available between these units.");
255 str.append(std::to_string(
value));
257 str.append(U::symbol());
259 str.append(
typeid(T).name());
265 template <QuantityConcept Q,
typename T1>
266 requires(not QuantityConcept<T1>)
267 Q operator/(
const T1& lhs,
const Q& rhs) {
268 return {lhs / rhs->
value};
271 template <QuantityConcept Q,
typename T1>
272 requires(not QuantityConcept<T1>)
273 Q operator*(
const T1& lhs,
const Q& rhs) {
277 template<
typename U,
typename T>
281export template<
typename U,
typename T>
Predicate that checks if a type is a quantity regardless of its unit.
Core components of the Quantify library.
#define R(...)
Syntax sugar - Apply reduce.
std::ostream & operator<<(std::ostream &o, const quantify::quantity< U, T > &quantity)
quantity< R(U), T > operator/(const T1 &rhl) const
quantity(quantity< U1, T1 > &&other)
Move.
quantity & operator=(quantity< U1, T1 > &&rhl)
Move.
quantity< R(mul< R(U), R(U1)>), T > operator*(const quantity< U1, T > &rhl) const
quantity(const quantity< U, T1 > &other)
Copy.
quantity & operator=(const quantity< U, T1 > &rhl)
Copy.
bool operator==(const quantity< U1, T > &rhl) const
quantity< R(frac< R(U), R(U)>), T > operator/(const quantity< U1, T > &rhl) const
quantity< R(U), T1 > operator-(const quantity< U1, T1 > &rhl) const
quantity(const quantity< U1, T1 > &other)
Copy.
quantity & operator=(const quantity< U1, T1 > &rhl)
Copy.
std::string to_string() const noexcept
quantity< R(U), T > operator*(const T1 &rhl) const
quantity< R(mul< R(U), R(U)>), T > operator*(const quantity< U1, T > &rhl) const
auto operator<=>(const quantity< U1, T > &rhl) const
quantity< R(frac< R(U), R(U1)>), T > operator/(const quantity< U1, T > &rhl) const
constexpr quantity(T value_)
quantity< R(U), T1 > operator+(const quantity< U1, T1 > &rhl) const
constexpr quantity()=default
quantity & operator=(quantity< U, T1 > &&rhl) noexcept
Move.
quantity< R(U), T1 > & operator-=(const quantity< U1, T1 > &rhl)
quantity(quantity< U, T1 > &&other) noexcept
Move.
bool operator<(const quantity< U1, T > &rhl) const
T value_as_base_unit() const
constexpr quantity< U1, T > as() const
quantity< U, T > operator-() const
quantity< R(U), T1 > & operator+=(const quantity< U1, T1 > &rhl)