mp_units::QuantityPoint¶
A concept matching every quantity point
Synopsis¶
Declared in <mp-units/framework/quantity_point_concepts.h>
template<typename T>
concept QuantityPoint = detail::is_quantity_point<T>;
Description¶
Satisfied by every specialization of quantity_point and every type derived from one. Its counterpart for deltas is Quantity, and the two tell apart overloads that a delta and a point need to handle differently:
// one name for printing a temperature and a temperature difference
void print_temp(std::string_view title, QuantityPoint auto temp)
{
std::cout << title << ": " << temp << " (" << temp.delta_from(si::absolute_zero).in(K)
<< " above absolute zero)\n";
}
void print_temp(std::string_view title, Quantity auto temp)
{
std::cout << title << ": " << temp << " (" << temp.in(K) << ")\n";
}
void report()
{
quantity_point today = point<deg_C>(19.);
quantity_point tomorrow = point<deg_C>(21.);
print_temp("tomorrow", tomorrow); // tomorrow: 21 °C (294.15 K above absolute zero)
print_temp("change", tomorrow - today); // change: 2 °C (2 K)
}
See Also¶
- Concepts in the User's Guide