mp_units::get_common_unit

get_common_unit overloads

Synopses

Declared in <mp-units/framework/reference.h>

Returns the common unit of a single unit

[[nodiscard]]
consteval
Unit auto
get_common_unit(auto u);
» more...

Computes the common unit of a single new unit and a common_unit compound

template<
    Unit... Us,
    /* implementation-defined */ NewUnit>
[[nodiscard]]
consteval
Unit auto
get_common_unit(
    NewUnit nu,
    common_unit<Us...> cu);
» more...

Computes the common unit of two convertible units

template<
    Unit U1,
    /* implementation-defined */ U2>
[[nodiscard]]
consteval
Unit auto
get_common_unit(
    U1 u1,
    U2 u2);
» more...

Computes the common unit of a common_unit compound and a single new unit

template<
    Unit... Us,
    /* implementation-defined */ NewUnit>
[[nodiscard]]
consteval
Unit auto
get_common_unit(
    common_unit<Us...> cu,
    NewUnit new_unit);
» more...

Computes the common unit of two common_unit compounds by merging their unit lists

template<
    Unit Front,
    Unit... Rest,
    Unit... Us>
requires (detail::UnitConvertibleTo<common_unit<Front, Rest...>, common_unit<Us...>{}>)
[[nodiscard]]
consteval
Unit auto
get_common_unit(
    common_unit<Front, Rest...> cu1,
    common_unit<Us...> cu2);
» more...

Computes the common unit of three or more units

[[nodiscard]]
consteval
Unit auto
get_common_unit(
    auto u1,
    auto u2,
    auto u3,
    auto... rest)
requires requires { mp_units::get_common_unit(mp_units::get_common_unit(u1, u2), u3, rest...); };
» more...

Return Value

  • u unchanged
  • the common unit obtained by merging nu into cu's unit list
  • the common unit of u1 and u2
  • the common unit obtained by merging the new unit into the compound's unit list
  • the common unit obtained by merging the unit lists of cu1 and cu2
  • the common unit obtained by folding get_common_unit over u1, u2, u3, and rest

NOTE

The return value should not be discarded.

Parameters

NameDescription
uthe unit
nuthe single unit
cuthe common_unit compound
u1first unit
u2second unit
new_unitthe new unit to merge into the compound's unit list
cu1first common_unit compound
cu2second common_unit compound
u3third unit
restremaining units, if any