Skip to content

mp_units::named_unit

A named unit

Synopsis

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

template<symbol_text Symbol, auto...>
struct named_unit;

Description

Defines a unit with a special name. It may be used to provide a base unit in the system of units (e.g. metre) or a name assigned to another scaled or derived unit (e.g. hour, joule). Most of the named units may be composed with a prefix to create a prefixed_unit.

For example:


inline constexpr struct second : named_unit<"s", kind_of<time>> {} second;
inline constexpr struct metre : named_unit<"m", kind_of<length> {} metre;
inline constexpr struct hertz : named_unit<"Hz", inverse(second), kind_of<frequency>> {} hertz;
inline constexpr struct newton : named_unit<"N", kilogram * metre / square(second)> {} newton;
inline constexpr struct degree_Celsius : named_unit<{u8"℃", "`C"}, kelvin, zeroth_degree_Celsius> {}
degree_Celsius; inline constexpr struct minute : named_unit<"min", mag<60> * second> {} minute;

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 unit types in the source code. All operations are done on the objects. Contrarily, the unit 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.

Specializations

NameDescription
named_unit<Symbol, U> Specialization for unit of a specified base quantity
named_unit<Symbol, U, QS> Specialization for a unit with special name valid only for a specific quantity
named_unit<Symbol, U, QS, PO>

Derived Classes

NameDescription
Julian_year
acre
acre
ampere
ampere
angstrom
arcminute
arcsecond
are
astronomical_unit
astronomical_unit
atmosphere
bar
barleycorn
barn
barrel
barye
baud
becquerel
becquerel
bit
bushel
byte
cable
cable
candela
candela_
century
chain
chain
chain
cicero
coulomb
coulomb
cup
curie
dalton
day
day
degree
degree
degree_Celsius
degree_Fahrenheit
didot_point
dram
dry_barrel
dry_gallon
dry_pint
dry_quart
dyne
electronvolt
electronvolt
electronvolt
eplus
erg
erlang
farad
farad
fathom
fluid_dram
fluid_ounce
fluid_ounce
foot
furlong
furlong
furlong
gal
gallon
gallon
gauss
gaussian_gravitational_constant
gill
gill
gradian
grain
gram
gram
gray
gray
h
hand
henry
henry
hertz
hertz
hogshead
hour
inch
inch_of_mercury
jansky
joule
joule
jovian_mass
katal
kayser
kelvin
kelvin
knot
league
league
light_year
link
link
link
liter
litre
long_hundredweight
lumen
lumen_
lunar_distance
lux
lux_
mechanical_horsepower
meter
metre
mil
mile
millennium
minim
minute
mole
mole
nautical_mile
newton
newton
octet
ohm
ohm
oil_barrel
ounce
parsec
parsec
parts_per_million
pascal
pascal
peck
pennyweight
per_mille
percent
perch
pica
pica_dtp
pica_us
pint
pint
point
point_dtp
point_us
poise
pottle
pound
pound_force
poundal
psi
q
quart
quart
quarter
quarter
radian
radian
rankine
revolution
rod
rod
rod
rood
second
second
section
short_hundredweight
shot
sidereal_day
siemens
sievert
solar_mass
steradian
steradian
stokes
stone
tablespoon
teaspoon
terrestrial_mass
tesla
tesla
tex_point
thou
ton
ton
tonne
tropical_year
troy_once
troy_pound
twip
us_survey_foot
us_survey_foot
us_survey_mile
us_survey_mile
volt
volt
volt_ampere_reactive_power
watt
watt
weber
weber
yard

Template Parameters

NameDescription
Symbola short text representation of the unit