mp_units::derived_dimension

A dimension of a derived quantity

Synopsis

Declared in <mp-units/framework/dimension.h>
template</* implementation-defined */... Expr>
struct derived_dimension final
    : /* implementation-defined */
    , /* implementation-defined */


Base Classes

Name Description
/* implementation-defined */
/* implementation-defined */

Description

Derived dimension is an expression of the dependence of a quantity on the base quantities of a system of quantities as a product of powers of factors corresponding to the base quantities, omitting any numerical factors.

Instead of using a raw list of exponents this library decided to use symbolic expression syntax to make types more digestable for the user. The positive exponents are ordered first and all negative exponents are put as a list into the per<...> class template. If a power of exponent is different than 1 the dimension type is enclosed in power<Dim, Num, Den> class template. Otherwise, it is just put directly in the list without any wrapper. There is also one special case. In case all of the exponents are negative than the dimension_one being a dimension of a dimensionless quantity is put in the front to increase the readability.

For example:

{.cpp} using frequency = decltype(inverse(dim_time)); using speed = decltype(dim_length / dim_time); using acceleration = decltype(dim_speed / dim_time); using force = decltype(dim_mass * dim_acceleration); using energy = decltype(dim_force * dim_length); using moment_of_force = decltype(dim_length * dim_force); using torque = decltype(dim_moment_of_force);

- frequency will be derived from type derived_dimension<dimension_one, per<dim_time>> - speed will be derived from type derived_dimension<dim_length, per<dim_time>> - acceleration will be derived from type derived_dimension<dim_length, per<power<dim_time, 2>>> - force will be derived from type derived_dimension<dim_length, dim_mass, per<power<dim_time, 2>>> - energy will be derived from type derived_dimension<power<dim_length, 2>, dim_mass, per<power<dim_time, 2>>>

NOTE

A common convention in this library is to assign the same name for a type and an object of this type. Besides defining them user never works with the dimension types in the source code. All operations are done on the objects. Contrarily, the dimension types are the only one visible in the compilation errors. Having them of the same names improves user experience and somehow blurs those separate domains.

NOTE

User should not instantiate this type! It is not exported from the C++ module. The library will instantiate this type automatically based on the dimensional arithmetic equation provided by the user.

Template Parameters

Name Description
Ds a parameter pack consisting tokens allowed in the dimension specification (base dimensions, dimension_one, power<Dim, Num, Den>, per<...>)

Created with MrDocs