-
Notifications
You must be signed in to change notification settings - Fork 1
concept quantity
kwikius edited this page Sep 16, 2020
·
89 revisions
A measurable quantity 1 with a unit and a numeric_value 2.
type | model of | notes |
---|---|---|
Q, Qj, Qk, Qr | quantity | |
U | unit | |
V, Vr | dimensionless_quantity | |
Sm | measurement_system | |
D | dimension | |
Ds | simple_dimension | |
C | conversion_factor<...> |
value | type | notes |
---|---|---|
q | Q | |
qJ | Qj | |
qK | Qk | |
qR | Qr | local result |
vR | Vr | local result |
v | V | The numeric value of q |
b | bool |
concept | notes |
---|---|
scalar< Q > | A model of quantity is implicitly a model of scalar |
operation | result | requires | notes |
---|---|---|---|
qJ + qK | qR | DA and provide_operator< Qj, plus, Qk> == true | To disable, set impl::provide_operator_plus_impl<Qj,Qk> false |
qJ - qK | qR | DA and provide_operator< Qj ,minus, Qk> == true | To disable, set impl::provide_operator_minus_impl<Qj,Qk> false |
qJ * qK | qR | DA and provide_operator< Qj, times, Qk> == true | To disable, set impl::provide_operator_times_impl<Qj,Qk> false |
qJ * qK | vR | DA and provide_operator< Qj, times, Qk> == true | To disable, set impl::provide_operator_times_impl<Qj,Qk> false |
qJ / qK | qR | DA and provide_operator< Qj, divides, Qk> == true | To disable, set impl::provide_operator_divides_impl<Qj,Qk> false |
qJ / qK | vR | DA and provide_operator< Qj, divides, Qk> == true | To disable, set impl::provide_operator_divides_impl<Qj,Qk> false |
pow<N>(q) | qR | DA and provide_operator< Qj, pow, std::ratio<N,1> > == true | To disable, set impl::provide_operator_pow_impl<Qj,N,1> false |
pow<N,D>(q) | qR | DA and provide_operator< Qj, pow, std::ratio<N,D> > ==true | To disable, set impl::provide_operator_pow_impl<Qj,N,D> false |
qJ < qK | b | DA and provide_operator_cmp< Qj, Qk > == true | To disable, set impl::provide_operator_cmp_impl<Qj,Qk> false |
qJ <= qK | b | DA and provide_operator_cmp< Qj, Qk > == true | To disable, set impl::provide_operator_cmp_impl<Qj,Qk> false |
qJ != qK | b | DA and provide_operator_cmp< Qj, Qk > == true | To disable, set impl::provide_operator_cmp_impl<Qj,Qk> false |
qJ == qK | b | DA and provide_operator_cmp< Qj, Qk > == true | To disable, set impl::provide_operator_cmp_impl<Qj,Qk> false |
qJ >= qK | b | DA and provide_operator_cmp< Qj, Qk > == true | To disable, set impl::provide_operator_cmp_impl<Qj,Qk> false |
qJ > qK | b | DA and provide_operator_cmp< Qj, Qk > == true | To disable, set impl::provide_operator_cmp_impl<Qj,Qk> false |
alias_template | result | notes |
---|---|---|
get_measurement_system< Q > | Sm | The measurement_system of U |
get_dimension< Q > | D | the dimension of U |
get_conversion_factor< Q > | C | the conversion factor for U |
get_simple_dimension< Q > | Ds | the simple_dimension of U |
get_unit< Q > | U | |
get_numeric_type< Q > | V |
inline_bool_constant | value | notes |
---|---|---|
dimensionally_equivalent< Qj, Qk > | true if Qj and Qk are dimensionally equivalent else false |
applies std::remove_cvref_t to Qj,Qk before testing |
same_measurement_system< Qj, Qk > | true if units of Qj and Qk are in same measurement system else false |
applies std::remove_cvref_t to Qj,Qk before testing |
inline_bool_constant | value | notes |
---|---|---|
impl::is_quantity_impl< Q > | true | states that Q fulfills the requirements below |
typestruct | result | notes |
---|---|---|
impl::get_unit_impl< Q > | U | |
impl::get_numeric_type_impl< Q > | V |
function | result | notes |
---|---|---|
get_numeric_value( q ) | v |
For a model of quantity q, the conversion_factor is the factor by which to multiply the numeric_value of q, to convert q to a dimensionally_equivalent quantity in the same measurement system, with a conversion_factor that evaluates to 1.
Let Qb be a model of quantity where evaluate<get_conversion_factor< Qb > >() == 1
.
Let Q be a dimensionally_equivalent model of quantity in same measurement_system as Qb , where evaluate<get_conversion_factor<Q> >() != 1
.
using namespace pqs;
using Qb = si::length::m<>;
using Q = si::length::ft<>;
static_assert( same_measurement_system< Q,Qb > );
static_assert( evaluate<get_conversion_factor< Qb > >() == 1 );
static_assert( evaluate<get_conversion_factor< Q > >() != 1 );
constexpr dimensionless_quantity n = -12345.678;
constexpr Q q{n};
constexpr Qb qB = q;
static_assert(
get_numeric_value(qB) ==
get_numeric_value(q) * evaluate<get_conversion_factor<Q> >()
);