[#mp_units-derived_dimension]
= xref:mp_units.adoc[mp&lowbar;units]::derived&lowbar;dimension
:relfileprefix: ../
:mrdocs:

A dimension of a derived quantity

== Synopsis

Declared in `&lt;mp&hyphen;units&sol;framework&sol;dimension&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;&sol;&ast; implementation-defined &ast;&sol;&period;&period;&period; Expr&gt;
struct derived&lowbar;dimension final
    : &sol;&ast; implementation-defined &ast;&sol;
    , &sol;&ast; implementation-defined &ast;&sol;
----

== 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&period;

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

For example&colon;

[,cpp]
----
{.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&lowbar;dimension&lt;dimension&lowbar;one, per&lt;dim&lowbar;time&gt;&gt;`
* `speed` will be derived from type `derived&lowbar;dimension&lt;dim&lowbar;length, per&lt;dim&lowbar;time&gt;&gt;`
* `acceleration` will be derived from type `derived&lowbar;dimension&lt;dim&lowbar;length, per&lt;power&lt;dim&lowbar;time, 2&gt;&gt;&gt;`
* `force` will be derived from type `derived&lowbar;dimension&lt;dim&lowbar;length, dim&lowbar;mass, per&lt;power&lt;dim&lowbar;time, 2&gt;&gt;&gt;`
* `energy` will be derived from type `derived&lowbar;dimension&lt;power&lt;dim&lowbar;length, 2&gt;, dim&lowbar;mass, per&lt;power&lt;dim&lowbar;time, 2&gt;&gt;&gt;`

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

====

[NOTE]
====
User should not instantiate this type! It is not exported from the C&plus;&plus; module&period; The library will instantiate this type automatically based on the dimensional arithmetic equation provided by the user&period;

====

== Base Classes

[cols="1,4"]
|===
| Name| Description
| `&sol;&ast; implementation-defined &ast;&sol;`
| 
| `&sol;&ast; implementation-defined &ast;&sol;`
| 
|===

== Template Parameters

[cols="1,4"]
|===
| Name| Description
| *Ds*
| a parameter pack consisting tokens allowed in the dimension specification (base dimensions, `dimension&lowbar;one`, `power&lt;Dim, Num, Den&gt;`, `per&lt;&period;&period;&period;&gt;`)
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
