[#mp_units-common_unit]
= xref:mp_units.adoc[mp&lowbar;units]::common&lowbar;unit
:relfileprefix: ../
:mrdocs:

Measurement unit for an accumulation of two quantities of different units

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    xref:mp_units/Unit.adoc[Unit] U1,
    xref:mp_units/Unit.adoc[Unit] U2,
    xref:mp_units/Unit.adoc[Unit]&period;&period;&period; Rest&gt;
struct common&lowbar;unit final
    : ::&lowbar;base&lowbar;type&lowbar;
----

== Base Classes

[cols=2]
|===
| Name
| Description
| `::&lowbar;base&lowbar;type&lowbar;`
| 
|===

== Types

[cols=1]
|===
| Name
| xref:mp_units/common_unit/_base_type_.adoc[`&lowbar;base&lowbar;type&lowbar;`] 
|===

== Static Data Members

[cols=1]
|===
| Name
| xref:mp_units/common_unit/_common_unit_.adoc[`&lowbar;common&lowbar;unit&lowbar;`] 
|===

== Description

While adding two quantities of different units we can often identify which of those unit should be used to prevent data truncation&period; For example, adding `1 &ast; m &plus; 1 &ast; mm` will end up in a quantity expressed in millimeters&period; However, for some cases this is not possible&period; Choosing any of the units from the arguments of the addition would result in a data truncation&period; For example, a common unit for `1 &ast; km &plus; 1 &ast; mi` is `&lsqb;8&sol;125&rsqb; m`&period; Instead of returning such a complex unit type the library will return a `common&lowbar;unit&lt;mi, km&gt;`&period; This type is convertible to both `mi` and `km` without risking data truncation, but is not equal to any of them&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 unit arithmetic equation provided by the user&period;

====


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