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

`get&lowbar;common&lowbar;unit` overloads

== Synopses

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

Returns the common unit of a single unit


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
consteval
xref:mp_units/Unit.adoc[Unit] auto
xref:mp_units/get_common_unit-0e.adoc[get&lowbar;common&lowbar;unit](auto u);
----

[.small]#xref:mp_units/get_common_unit-0e.adoc[_» more&period;&period;&period;_]#

Computes the common unit of a single new unit and a `common&lowbar;unit` compound


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    xref:mp_units/Unit.adoc[Unit]&period;&period;&period; Us,
    &sol;&ast; implementation-defined &ast;&sol; NewUnit&gt;
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
consteval
xref:mp_units/Unit.adoc[Unit] auto
xref:mp_units/get_common_unit-08c.adoc[get&lowbar;common&lowbar;unit](
    NewUnit nu,
    xref:mp_units/common_unit.adoc[common&lowbar;unit&lt;Us&period;&period;&period;&gt;] cu);
----

[.small]#xref:mp_units/get_common_unit-08c.adoc[_» more&period;&period;&period;_]#

Computes the common unit of two convertible units


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    xref:mp_units/Unit.adoc[Unit] U1,
    &sol;&ast; implementation-defined &ast;&sol; U2&gt;
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
consteval
xref:mp_units/Unit.adoc[Unit] auto
xref:mp_units/get_common_unit-0d.adoc[get&lowbar;common&lowbar;unit](
    U1 u1,
    U2 u2);
----

[.small]#xref:mp_units/get_common_unit-0d.adoc[_» more&period;&period;&period;_]#

Computes the common unit of a `common&lowbar;unit` compound and a single new unit


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    xref:mp_units/Unit.adoc[Unit]&period;&period;&period; Us,
    &sol;&ast; implementation-defined &ast;&sol; NewUnit&gt;
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
consteval
xref:mp_units/Unit.adoc[Unit] auto
xref:mp_units/get_common_unit-08d.adoc[get&lowbar;common&lowbar;unit](
    xref:mp_units/common_unit.adoc[common&lowbar;unit&lt;Us&period;&period;&period;&gt;] cu,
    NewUnit new&lowbar;unit);
----

[.small]#xref:mp_units/get_common_unit-08d.adoc[_» more&period;&period;&period;_]#

Computes the common unit of two `common&lowbar;unit` compounds by merging their unit lists


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
template&lt;
    xref:mp_units/Unit.adoc[Unit] Front,
    xref:mp_units/Unit.adoc[Unit]&period;&period;&period; Rest,
    xref:mp_units/Unit.adoc[Unit]&period;&period;&period; Us&gt;
requires (detail&colon;&colon;UnitConvertibleTo&lt;common&lowbar;unit&lt;Front, Rest&period;&period;&period;&gt;, common&lowbar;unit&lt;Us&period;&period;&period;&gt;&lcub;&rcub;&gt;)
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
consteval
xref:mp_units/Unit.adoc[Unit] auto
xref:mp_units/get_common_unit-09.adoc[get&lowbar;common&lowbar;unit](
    xref:mp_units/common_unit.adoc[common&lowbar;unit&lt;Front, Rest&period;&period;&period;&gt;] cu1,
    xref:mp_units/common_unit.adoc[common&lowbar;unit&lt;Us&period;&period;&period;&gt;] cu2);
----

[.small]#xref:mp_units/get_common_unit-09.adoc[_» more&period;&period;&period;_]#

Computes the common unit of three or more units


[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
&lsqb;&lsqb;nodiscard&rsqb;&rsqb;
consteval
xref:mp_units/Unit.adoc[Unit] auto
xref:mp_units/get_common_unit-02.adoc[get&lowbar;common&lowbar;unit](
    auto u1,
    auto u2,
    auto u3,
    auto&period;&period;&period; rest)
requires requires &lcub; mp&lowbar;units&colon;&colon;get&lowbar;common&lowbar;unit(mp&lowbar;units&colon;&colon;get&lowbar;common&lowbar;unit(u1, u2), u3, rest&period;&period;&period;)&semi; &rcub;;
----

[.small]#xref:mp_units/get_common_unit-02.adoc[_» more&period;&period;&period;_]#

== Return Value

* `u` unchanged
* the common unit obtained by merging `nu` into `cu&apos;s` unit list
* the common unit of `u1` and `u2`
* the common unit obtained by merging the new unit into the compound&apos;s unit list
* the common unit obtained by merging the unit lists of `cu1` and `cu2`
* the common unit obtained by folding `get&lowbar;common&lowbar;unit` over `u1,` `u2,` `u3,` and `rest`

[NOTE]
====
The return value https://en.cppreference.com/cpp/language/attributes/nodiscard[should not be discarded^].
====
== Parameters

[cols="1,4"]
|===
| Name| Description
| *u*
| the unit
| *nu*
| the single unit
| *cu*
| the `common&lowbar;unit` compound
| *u1*
| first unit
| *u2*
| second unit
| *new&lowbar;unit*
| the new unit to merge into the compound&apos;s unit list
| *cu1*
| first `common&lowbar;unit` compound
| *cu2*
| second `common&lowbar;unit` compound
| *u3*
| third unit
| *rest*
| remaining units, if any
|===


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