<!DOCTYPE html><htmllang='en'><head><title>[qty.unit]</title><metacharset='UTF-8'/><linkrel='stylesheet'type='text/css'href='14882.css'/><linkrel='stylesheet'type='text/css'href='https://fonts.googleapis.com/css2?family=Noto+Serif'/><linkrel='stylesheet'type='text/css'href='https://fonts.googleapis.com/css2?family=Noto+Sans'/><linkrel='stylesheet'type='text/css'href='https://fonts.googleapis.com/css2?family=Noto+Sans+Mono'/><linkrel='icon'href='icon.png'/><linkrel='stylesheet'type='text/css'href='expanded.css'title='Normal'/><linkrel='alternate stylesheet'type='text/css'href='colored.css'title='Notes and examples colored'/><linkrel='alternate stylesheet'type='text/css'href='normative-only.css'title='Notes and examples hidden'/></head><body><divclass='wrapper'><h1><aclass='secnum'style='min-width:50pt'>5</a> Quantities and units library <aclass='abbr_ref'href='index.html#quantities'>[quantities]</a></h1><h2><aclass='secnum'style='min-width:65pt'>5.4</a> Reference <aclass='abbr_ref'href='qty.ref.html#qty.unit'>[qty.ref]</a></h2><h3><aclass='secnum'style='min-width:80pt'>5.4.4</a> Unit <aclass='abbr_ref'>[qty.unit]</a></h3><divid='general'class='section'><h4><aclass='secnum'href='#general'style='min-width:95pt'>5.4.4.1</a> General <aclass='abbr_ref'href='qty.unit.general.html'>[qty.unit.general]</a></h4><divclass='para'id='general-1'><divclass='marginalizedparent'><aclass='marginalized'href='#general-1'>1</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2274'>#</a></div><divclass='texpara'><divid='general-1.sentence-1'class='sentence'>Subclause [qty.<spanclass='shy'></span>unit] specifies the components
for defining a unit of measurement (<ahref="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=112-01-14">IEC 60050, 112-01-14</a>)<aclass='hidden_link'href='#general-1.sentence-1'>.</a></div></div></div></div><divid='mag'class='section'><h4><aclass='secnum'href='#mag'style='min-width:95pt'>5.4.4.2</a> Magnitude <aclass='abbr_ref'href='qty.unit.mag.html'>[qty.unit.mag]</a></h4><divid='mag.general'class='section'><h4><aclass='secnum'href='#mag.general'style='min-width:110pt'>5.4.4.2.1</a> General <aclass='abbr_ref'href='qty.unit.mag.general.html'>[qty.unit.mag.general]</a></h4><divclass='para'id='mag.general-1'><divclass='marginalizedparent'><aclass='marginalized'href='#mag.general-1'>1</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2282'>#</a></div><divclass='texpara'><divid='mag.general-1.sentence-1'class='sentence'>Subclause <ahref='#mag'title='5.4.4.2 Magnitude'>[qty.<spanclass='shy'></span>unit.<spanclass='shy'></span>mag]</a> specifies the components
used to represent the numerical value (<ahref="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=112-01-29">IEC 60050, 112-01-29</a>) of a unit
with support for powers (<ahref="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=102-02-08">IEC 60050, 102-02-08</a>) of real numbers (<ahref="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=102-02-05">IEC 60050, 102-02-05</a>)<aclass='hidden_link'href='#mag.general-1.sentence-1'>.</a></div></div></div></div><divid='mag.concepts'class='section'><h4><aclass='secnum'href='#mag.concepts'style='min-width:110pt'>5.4.4.2.2</a> Concepts <aclass='abbr_ref'href='qty.unit.mag.concepts.html'>[qty.unit.mag.concepts]</a></h4><divclass='texpara'><divclass='itemdecl'id='mag.concepts-itemdecl:1'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#mag.concepts-itemdecl:1'>🔗</a></div><codeclass='itemdeclcode'><spanclass='keyword'>template</span><spanclass='anglebracket'><</span><spanclass='keyword'>typename</span> T<spanclass='anglebracket'>></span>
</span></span></div><divclass='texpara'><divid='mag.types-sentence-1'class='sentence'>A specialization of <spanclass='texttt'>mag_<spanclass='shy'></span>constant</span> represents a real number (<ahref="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=102-02-05">IEC 60050, 102-02-05</a>)<aclass='hidden_link'href='#mag.types-sentence-1'>.</a></div><divid='mag.types-sentence-2'class='sentence'><spanclass='texttt'>Symbol</span> is its symbol, and
<spanclass='texttt'>Value</span> is (an approximation of) its value<aclass='hidden_link'href='#mag.types-sentence-2'>.</a></div></div><divclass='texpara'><spanid='lib:unit-magnitude'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#lib:unit-magnitude'>🔗</a></div><spanclass='codeblock'><spanclass='keyword'>namespace</span> mp_units <spanclass='curlybracket'>{</span>
<spanclass='keyword'>friend</span><spanclass='keyword'>consteval</span><ahref='#concept:UnitMagnitude'title='5.4.4.2.2 Concepts [qty.unit.mag.concepts]'><spanid='conceptref:UnitMagnitude_'><spanclass='tcode_in_codeblock'>UnitMagnitude</span></span></a><spanclass='keyword'>auto</span><spanclass='keyword'>operator</span><spanclass='operator'>*</span><spanclass='parenthesis'>(</span><i>unit-magnitude</i> lhs, M rhs<spanclass='parenthesis'>)</span>;
<spanclass='keyword'>template</span><spanclass='anglebracket'><</span><spanclass='keyword'>int</span> Num, <spanclass='keyword'>int</span> Den <spanclass='operator'>=</span><spanclass='literal'>1</span><spanclass='anglebracket'>></span>
</span></span></div><divclass='para'id='mag.types-1'><divclass='marginalizedparent'><aclass='marginalized'href='#mag.types-1'>1</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2351'>#</a></div><divclass='texpara'><divid='mag.types-1.sentence-1'class='sentence'>A specialization of <spanclass='texttt'><i>unit-magnitude</i></span>
represents the product of its template arguments<aclass='hidden_link'href='#mag.types-1.sentence-1'>.</a></div></div></div><divclass='para'id='mag.types-2'><divclass='marginalizedparent'><aclass='marginalized'href='#mag.types-2'>2</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2355'>#</a></div><divclass='texpara'><divid='mag.types-2.sentence-1'class='sentence'>For the purposes of specifying the implementation-defined limits,
representing the number <spanclass="mjx-chtml"><spanclass="mjx-math"><spanclass="mjx-mrow"aria-hidden="true"><spanclass="mjx-msubsup"><spanclass="mjx-base"><spanclass="mjx-texatom"><spanclass="mjx-mrow"><spanclass="mjx-mtext"><spanclass="mjx-char MJXc-TeX-type-R"style="padding-top: 0.372em; padding-bottom: 0.298em;">base</span></span></span></span></span><spanclass="mjx-sup"style="font-size: 70.7%; vertical-align: 0.513em; padding-left: 0px; padding-right: 0.071em;"><spanclass="mjx-texatom"><spanclass="mjx-mrow"><spanclass="mjx-mtext"><spanclass="mjx-char MJXc-TeX-type-R"style="padding-top: 0.225em; padding-bottom: 0.519em;">exp</span></span></span></span></span></span></span></span></span>,
where <spanclass='texttt'><i>base-type</i></span> is a model of <ahref='#concept:MagArg'title='5.4.4.2.2 Concepts [qty.unit.mag.concepts]'><spanid='conceptref:MagArg'><spanclass='texttt'><i>MagArg</i></span></span></a><aclass='hidden_link'href='#mag.types-2.sentence-1'>.</a></div><ulclass='itemize'><liid='mag.types-2.1'><divclass='marginalizedparent'style='left:-27mm'><aclass='marginalized'href='#mag.types-2.1'>(2.1)</a></div><divclass='texpara'><divid='mag.types-2.1.sentence-1'class='sentence'>There is a single term for each <spanclass='texttt'><i>base-type</i></span><aclass='hidden_link'href='#mag.types-2.1.sentence-1'>.</a></div></div></li><liid='mag.types-2.2'><divclass='marginalizedparent'style='left:-27mm'><aclass='marginalized'href='#mag.types-2.2'>(2.2)</a></div><divclass='texpara'><divid='mag.types-2.2.sentence-1'class='sentence'><spanclass='texttt'>exp<spanclass='operator'>.</span>num</span> is not expanded into base<aclass='hidden_link'href='#mag.types-2.2.sentence-1'>.</a></div><divid='mag.types-note-1'class='note'><divclass='texpara'>[<i>Note <ahref='#mag.types-note-1'>1</a></i>: <divid='mag.types-2.2.sentence-2'class='sentence'><spanclass="mjx-chtml"><spanclass="mjx-math"><spanclass="mjx-mrow"aria-hidden="true"><spanclass="mjx-msubsup"><spanclass="mjx-base"><spanclass="mjx-mn"><spanclass="mjx-char MJXc-TeX-main-R"style="padding-top: 0.372em; padding-bottom: 0.372em;">2</span></span></span><spanclass="mjx-sup"style="font-size: 70.7%; vertical-align: 0.591em; padding-left: 0px; padding-right: 0.071em;"><spanclass="mjx-mn"><spanclass="mjx-char MJXc-TeX-main-R"style="padding-top: 0.372em; padding-bottom: 0.372em;">3</span></span></span></span><spanclass="mjx-mo MJXc-space3"><spanclass="mjx-char MJXc-TeX-main-R"style="padding-top: 0.077em; padding-bottom: 0.298em;">=</span></span><spanclass="mjx-mn MJXc-space3"><spanclass="mjx-char MJXc-TeX-main-R"style="padding-top: 0.372em; padding-bottom: 0.372em;">8</span></span></span></span></span> is not permitted<aclass='hidden_link'href='#mag.types-2.2.sentence-2'>.</a></div> — <i>end note</i>]</div></div></div></li><liid='mag.types-2.3'><divclass='marginalizedparent'style='left:-27mm'><aclass='marginalized'href='#mag.types-2.3'>(2.3)</a></div><divclass='texpara'><divid='mag.types-2.3.sentence-1'class='sentence'><spanclass='texttt'>exp<spanclass='operator'>.</span>den</span> can reduce the base<aclass='hidden_link'href='#mag.types-2.3.sentence-1'>.</a></div><divid='mag.types-note-2'class='note'><divclass='texpara'>[<i>Note <ahref='#mag.types-note-2'>2</a></i>: <divid='mag.types-2.3.sentence-2'class='sentence'><spanclass="mjx-chtml"><spanclass="mjx-math"><spanclass="mjx-mrow"aria-hidden="true"><spanclass="mjx-msubsup"><spanclass="mjx-base"><spanclass="mjx-mn"><spanclass="mjx-char MJXc-TeX-main-R"style="padding-top: 0.372em; padding-bottom: 0.372em;">4</span></span></span><spanclass="mjx-sup"style="font-size: 70.7%; vertical-align: 0.607em; padding-left: 0px; padding-right: 0.071em;"><spanclass="mjx-texatom"><spanclass="mjx-mrow"><spanclass="mjx-mn"><spanclass="mjx-char MJXc-TeX-main-R"style="padding-top: 0.372em; padding-bottom: 0.372em;">1</span></span><spanclass="mjx-texatom"><spanclass="mjx-mrow"><spanclass="mjx-mo"><spanclass="mjx-char MJXc-TeX-main-R"style="padding-top: 0.446em; padding-bottom: 0.593em;">/</span></span></span></span><spanclass="mjx-mn"><spanclass="mjx-char MJXc-TeX-main-R"style="padding-top: 0.372em; padding-bottom: 0.372em;">2</span></span></span></span></span></span><spanclass="mjx-mo MJXc-space3"><spanclass="mjx-char MJXc-TeX-main-R"style="padding-top: 0.077em; padding-bottom: 0.298em;">=</span></span><spanclass="mjx-mn MJXc-space3"><spanclass="mjx-char MJXc-TeX-main-R"style="padding-top: 0.372em; padding-bottom: 0.372em;">2</span></span></span></span></span> is permitted<aclass='hidden_link'href='#mag.types-2.3.sentence-2'>.</a></div> — <i>end note</i>]</div></div></div></li><liid='mag.t
<spanclass='keyword'>friend</span><spanclass='keyword'>consteval</span><ahref='#concept:UnitMagnitude'title='5.4.4.2.2 Concepts [qty.unit.mag.concepts]'><spanid='conceptref:UnitMagnitude_____'><spanclass='texttt'>UnitMagnitude</span></span></a><spanclass='keyword'>auto</span><spanclass='keyword'>operator</span><spanclass='operator'>*</span><spanclass='parenthesis'>(</span><spanclass='texttt'><i>unit-magnitude</i></span> lhs, M rhs<spanclass='parenthesis'>)</span>;
</code></div></div></div></div><divclass='para'id='mag.ops-1'><divclass='marginalizedparent'><aclass='marginalized'href='#mag.ops-1'>1</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2394'>#</a></div><divclass='texpara'><divid='mag.ops-1.sentence-1'class='sentence'><i>Returns</i>: <ulclass='itemize'><liid='mag.ops-1.1'><divclass='marginalizedparent'style='left:-39mm'><aclass='marginalized'href='#mag.ops-1.1'>(1.1)</a></div><divclass='texpara'><divid='mag.ops-1.1.sentence-1'class='sentence'>If <spanclass='texttt'><spanclass='keyword'>sizeof</span><spanclass='operator'>.</span><spanclass='operator'>.</span><spanclass='operator'>.</span><spanclass='parenthesis'>(</span>Ms<spanclass='parenthesis'>)</span><spanclass='operator'>=</span><spanclass='operator'>=</span><spanclass='literal'>0</span></span> is <spanclass='texttt'><spanclass='literal'>true</span></span>, returns <spanclass='texttt'>rhs</span><aclass='hidden_link'href='#mag.ops-1.1.sentence-1'>.</a></div></div></li><liid='mag.ops-1.2'><divclass='marginalizedparent'style='left:-39mm'><aclass='marginalized'href='#mag.ops-1.2'>(1.2)</a></div><divclass='texpara'><divid='mag.ops-1.2.sentence-1'class='sentence'>Otherwise, if <spanclass='texttt'>std<spanclass='operator'>​::​</span>is_<spanclass='shy'></span>same_<spanclass='shy'></span>v<spanclass='anglebracket'><</span>M, <spanclass='texttt'><i>unit-magnitude</i></span><spanclass='anglebracket'><</span><spanclass='anglebracket'>></span><spanclass='anglebracket'>></span></span>, returns <spanclass='texttt'>lhs</span><aclass='hidden_link'href='#mag.ops-1.2.sentence-1'>.</a></div></div></li><liid='mag.ops-1.3'><divclass='marginalizedparent'style='left:-39mm'><aclass='marginalized'href='#mag.ops-1.3'>(1.3)</a></div><divclass='texpara'><divid='mag.ops-1.3.sentence-1'class='sentence'>Otherwise, returns an unspecified value equal to <spanclass='math'><spanclass='texttt'>lhs</span>×<spanclass='texttt'>rhs</span></span><aclass='hidden_link'href='#mag.ops-1.3.sentence-1'>.</a></div></div></li></ul></div></div></div></div><divclass='texpara'><divid='lib:UnitMagnitude,operator/'><divid='lib:operator/,UnitMagnitude'><divclass='itemdecl'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#lib:operator/,UnitMagnitude'>🔗</a></div><codeclass='itemdeclcode'><spanclass='keyword'>friend</span><spanclass='keyword'>consteval</span><spanclass='keyword'>auto</span><spanclass='keyword'>operator</span><spanclass='operator'>/</span><spanclass='parenthesis'>(</span><spanclass='texttt'><i>unit-magnitude</i></span> lhs, <ahref='#concept:UnitMagnitude'title='5.4.4.2.2 Concepts [qty.unit.mag.concepts]'><spanid='conceptref:UnitMagnitude______'><spanclass='texttt'>UnitMagnitude</span></span></a><spanclass='keyword'>auto</span> rhs<spanclass='parenthesis'>)</span>;
</code></div></div></div><divclass='para'id='mag.ops-5'><divclass='marginalizedparent'><aclass='marginalized'href='#mag.ops-5'>5</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2453'>#</a></div><divclass='texpara'><divid='mag.ops-5.sentence-1'class='sentence'><i>Constraints</i>: <spanclass='texttt'>V</span> is greater than <spanclass='math'>0</span><aclass='hidden_link'href='#mag.ops-5.sentence-1'>.</a></div></div></div></div><divclass='para'id='mag.ops-6'><divclass='marginalizedparent'><aclass='marginalized'href='#mag.ops-6'>6</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2457'>#</a></div><divclass='texpara'><divid='mag.ops-6.sentence-1'class='sentence'><i>Effects</i>: If <spanclass='texttt'><ahref='#concept:MagConstant'title='5.4.4.2.2 Concepts [qty.unit.mag.concepts]'><spanid='conceptref:MagConstant_'><spanclass='texttt'>MagConstant</span></span></a><spanclass='anglebracket'><</span><spanclass='keyword'>decltype</span><spanclass='parenthesis'>(</span>V<spanclass='parenthesis'>)</span><spanclass='anglebracket'>></span></span> is satisfied,
initializes <spanclass='texttt'>mag</span> with <spanclass='texttt'><spanclass='texttt'><i>unit-magnitude</i></span><spanclass='anglebracket'><</span>V<spanclass='anglebracket'>></span><spanclass='curlybracket'>{</span><spanclass='curlybracket'>}</span></span><aclass='hidden_link'href='#mag.ops-6.sentence-1'>.</a></div><divid='mag.ops-6.sentence-2'class='sentence'>Otherwise, initializes <spanclass='texttt'>mag</span> with
an unspecified value equal to <spanclass='texttt'>V</span><aclass='hidden_link'href='#mag.ops-6.sentence-2'>.</a></div></div></div></div><divclass='texpara'><divid='lib:mag_ratio'><divclass='itemdecl'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#lib:mag_ratio'>🔗</a></div><codeclass='itemdeclcode'><spanclass='keyword'>template</span><spanclass='anglebracket'><</span>std<spanclass='operator'>::</span>intmax_t N, std<spanclass='operator'>::</span>intmax_t D<spanclass='anglebracket'>></span>
</code></div></div></div><divclass='para'id='mag.ops-7'><divclass='marginalizedparent'><aclass='marginalized'href='#mag.ops-7'>7</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2473'>#</a></div><divclass='texpara'><divid='mag.ops-7.sentence-1'class='sentence'><i>Effects</i>: Initializes <spanclass='texttt'>mag_<spanclass='shy'></span>ratio</span> with
</code></div></div></div><divclass='para'id='mag.ops-8'><divclass='marginalizedparent'><aclass='marginalized'href='#mag.ops-8'>8</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2486'>#</a></div><divclass='texpara'><divid='mag.ops-8.sentence-1'class='sentence'><i>Constraints</i>: <spanclass='texttt'>Base</span> is greater than <spanclass='math'>0</span><aclass='hidden_link'href='#mag.ops-8.sentence-1'>.</a></div></div></div></div></div><divid='mag.utils'class='section'><h4><aclass='secnum'href='#mag.utils'style='min-width:110pt'>5.4.4.2.5</a> Utilities <aclass='abbr_ref'href='qty.unit.mag.utils.html'>[qty.unit.mag.utils]</a></h4><divclass='texpara'><divid='lib:is-positive-integral-power,UnitMagnitude'><divid='lib:UnitMagnitude,is-positive-integral-power'><divclass='itemdecl'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#lib:UnitMagnitude,is-positive-integral-power'>🔗</a></div><codeclass='itemdeclcode'><spanclass='keyword'>friend</span><spanclass='keyword'>consteval</span><spanclass='keyword'>bool</span><spanclass='texttt'><i>is-positive-integral-power</i></span><spanclass='parenthesis'>(</span><spanclass='texttt'><i>unit-magnitude</i></span> x<spanclass='parenthesis'>)</span>; <spanclass='comment'>// <i>exposition only</i></span>
</code></div></div></div></div><divclass='para'id='mag.utils-1'><divclass='marginalizedparent'><aclass='marginalized'href='#mag.utils-1'>1</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2499'>#</a></div><divclass='texpara'><divid='mag.utils-1.sentence-1'class='sentence'><i>Returns</i>: <spanclass='texttt'><spanclass='literal'>false</span></span> if <spanclass='texttt'>x</span> has a negative or rational exponent, and
</code></div></div></div></div><divclass='para'id='mag.utils-2'><divclass='marginalizedparent'><aclass='marginalized'href='#mag.utils-2'>2</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2512'>#</a></div><divclass='texpara'><divid='mag.utils-2.sentence-1'class='sentence'><i>Returns</i>: The largest magnitude <spanclass='texttt'>C</span>
by only positive powers relative to <spanclass='texttt'>C</span><aclass='hidden_link'href='#mag.utils-2.sentence-1'>.</a></div></div></div></div></div></div><divid='traits'class='section'><h4><aclass='secnum'href='#traits'style='min-width:95pt'>5.4.4.3</a> Traits <aclass='abbr_ref'href='qty.unit.traits.html'>[qty.unit.traits]</a></h4><divclass='texpara'><divid='lib:space_before_unit_symbol'><divclass='itemdecl'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#lib:space_before_unit_symbol'>🔗</a></div><codeclass='itemdeclcode'><spanclass='keyword'>template</span><spanclass='anglebracket'><</span><ahref='#concept:Unit'title='5.4.4.4 Concepts [qty.unit.concepts]'><spanid='conceptref:Unit'><spanclass='texttt'>Unit</span></span></a><spanclass='keyword'>auto</span> U<spanclass='anglebracket'>></span>
between the numerical value and the unit symbol<aclass='hidden_link'href='#traits-1.sentence-1'>.</a></div></div></div></div><divclass='para'id='traits-2'><divclass='marginalizedparent'><aclass='marginalized'href='#traits-2'>2</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2533'>#</a></div><divclass='texpara'><divid='traits-2.sentence-1'class='sentence'><i>Remarks</i>: Pursuant to <ahref="https://wg21.link/namespace.std">N4971, [namespace.std]</a> (<ahref='spec.ext.html'title='4.1 External'>[spec.<spanclass='shy'></span>ext]</a>),
users may specialize <spanclass='texttt'>space_<spanclass='shy'></span>before_<spanclass='shy'></span>unit_<spanclass='shy'></span>symbol</span>
for cv-unqualified program-defined types<aclass='hidden_link'href='#traits-2.sentence-1'>.</a></div><divid='traits-2.sentence-2'class='sentence'>Such specializations shall be usable in constant expressions (<ahref="https://wg21.link/expr.const">N4971, [expr.const]</a>)
and have type <spanclass='texttt'><spanclass='keyword'>const</span><spanclass='keyword'>bool</span></span><aclass='hidden_link'href='#traits-2.sentence-2'>.</a></div></div></div></div></div><divid='concepts'class='section'><h4><aclass='secnum'href='#concepts'style='min-width:95pt'>5.4.4.4</a> Concepts <aclass='abbr_ref'href='qty.unit.concepts.html'>[qty.unit.concepts]</a></h4><divclass='texpara'><divclass='itemdecl'id='concepts-itemdecl:1'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#concepts-itemdecl:1'>🔗</a></div><codeclass='itemdeclcode'><spanclass='keyword'>template</span><spanclass='anglebracket'><</span><spanclass='keyword'>typename</span> T<spanclass='anglebracket'>></span>
<spanclass='keyword'>template</span><spanclass='anglebracket'><</span><spanclass='keyword'>typename</span> U, <spanclass='keyword'>auto</span> QS<spanclass='anglebracket'>></span>
<spanclass='keyword'>template</span><spanclass='anglebracket'><</span><ahref='#concept:UnitMagnitude'title='5.4.4.2.2 Concepts [qty.unit.mag.concepts]'><spanid='conceptref:UnitMagnitude___________'><spanclass='tcode_in_codeblock'>UnitMagnitude</span></span></a> M, <ahref='#concept:Unit'title='5.4.4.4 Concepts [qty.unit.concepts]'><spanid='conceptref:Unit__________'><spanclass='tcode_in_codeblock'>Unit</span></span></a> U<spanclass='anglebracket'>></span>
</span></span></div><divclass='para'id='qty.canon.unit-1'><divclass='marginalizedparent'><aclass='marginalized'href='#qty.canon.unit-1'>1</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2597'>#</a></div><divclass='texpara'><divid='qty.canon.unit-1.sentence-1'class='sentence'><spanclass='texttt'><i>canonical-unit</i></span> represents a unit expressed in terms of base units (<ahref="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=112-01-18">IEC 60050, 112-01-18</a>)<aclass='hidden_link'href='#qty.canon.unit-1.sentence-1'>.</a></div><divid='qty.canon.unit-note-1'class='note'><divclass='texpara'>[<i>Note <ahref='#qty.canon.unit-note-1'>1</a></i>: <divid='qty.canon.unit-1.sentence-2'class='sentence'>Other types representing units are equal only if they have the same type<aclass='hidden_link'href='#qty.canon.unit-1.sentence-2'>.</a></div><divid='qty.canon.unit-1.sentence-3'class='sentence'><spanclass='texttt'><i>canonical-unit</i></span> is used to implement binary relations other than equality<aclass='hidden_link'href='#qty.canon.unit-1.sentence-3'>.</a></div> — <i>end note</i>]</div></div><divid='qty.canon.unit-1.sentence-4'class='sentence'><spanclass='texttt'>reference_<spanclass='shy'></span>unit</span> is simplified (<ahref='qty.sym.expr.algos.html'title='5.3.4.4 Algorithms'>[qty.<spanclass='shy'></span>sym.<spanclass='shy'></span>expr.<spanclass='shy'></span>algos]</a>)<aclass='hidden_link'href='#qty.canon.unit-1.sentence-4'>.</a></div></div></div><divclass='texpara'><divid='lib:get-canonical-unit,Unit'><divid='lib:Unit,get-canonical-unit'><divclass='itemdecl'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#lib:Unit,get-canonical-unit'>🔗</a></div><codeclass='itemdeclcode'><spanclass='keyword'>consteval</span><spanclass='keyword'>auto</span><spanclass='texttt'><i>get-canonical-unit</i></span><spanclass='parenthesis'>(</span><ahref='#concept:Unit'title='5.4.4.4 Concepts [qty.unit.concepts]'><spanid='conceptref:Unit___________'><spanclass='texttt'>Unit</span></span></a><spanclass='keyword'>auto</span> u<spanclass='parenthesis'>)</span>; <spanclass='comment'>// <i>exposition only</i></span>
</code></div></div></div></div><divclass='para'id='qty.canon.unit-2'><divclass='marginalizedparent'><aclass='marginalized'href='#qty.canon.unit-2'>2</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2611'>#</a></div><divclass='texpara'><divid='qty.canon.unit-2.sentence-1'class='sentence'><i>Returns</i>: The instantiation of <spanclass='texttt'><i>canonical-unit</i></span> for <spanclass='texttt'>u</span><aclass='hidden_link'href='#qty.canon.unit-2.sentence-1'>.</a></div></div></div></div></div><divid='qty.scaled.unit'class='section'><h4><aclass='secnum'href='#qty.scaled.unit'style='min-width:110pt'>5.4.4.5.2</a> Scaled <aclass='abbr_ref'href='qty.scaled.unit.html'>[qty.scaled.unit]</a></h4><divclass='texpara'><spanid='lib:scaled_unit'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#lib:scaled_unit'>🔗</a></div><spanclass='codeblock'><spanclass='keyword'>namespace</span> mp_units <spanclass='curlybracket'>{</span>
<spanclass='keyword'>template</span><spanclass='anglebracket'><</span><ahref='#concept:UnitMagnitude'title='5.4.4.2.2 Concepts [qty.unit.mag.concepts]'><spanid='conceptref:UnitMagnitude____________'><spanclass='tcode_in_codeblock'>UnitMagnitude</span></span></a><spanclass='keyword'>auto</span> M, <ahref='#concept:Unit'title='5.4.4.4 Concepts [qty.unit.concepts]'><spanid='conceptref:Unit____________'><spanclass='tcode_in_codeblock'>Unit</span></span></a> U<spanclass='anglebracket'>></span>
<spanclass='keyword'>requires</span><spanclass='parenthesis'>(</span>M <spanclass='operator'>!</span><spanclass='operator'>=</span><i>unit-magnitude</i><spanclass='anglebracket'><</span><spanclass='anglebracket'>></span><spanclass='curlybracket'>{</span><spanclass='curlybracket'>}</span><spanclass='operator'>&</span><spanclass='operator'>&</span> M <spanclass='operator'>!</span><spanclass='operator'>=</span> mag<spanclass='anglebracket'><</span><spanclass='literal'>1</span><spanclass='anglebracket'>></span><spanclass='parenthesis'>)</span>
<spanclass='keyword'>static</span><spanclass='keyword'>constexpr</span><ahref='#concept:UnitMagnitude'title='5.4.4.2.2 Concepts [qty.unit.mag.concepts]'><spanid='conceptref:UnitMagnitude_____________'><spanclass='tcode_in_codeblock'>UnitMagnitude</span></span></a><spanclass='keyword'>auto</span><i>mag</i><spanclass='operator'>=</span> M; <spanclass='comment'>// <i>exposition only</i></span>
<spanclass='keyword'>static</span><spanclass='keyword'>constexpr</span> U <i>reference-unit</i><spanclass='curlybracket'>{</span><spanclass='curlybracket'>}</span>; <spanclass='comment'>// <i>exposition only</i></span>
<spanclass='comment'>// if the <spanclass='textsf'><i>qualified-id</i></span><spanclass='tcode_in_codeblock'>U​::​point_<spanclass='shy'></span>origin</span> is valid and denotes an object</span>
</span></span></div><divclass='para'id='qty.scaled.unit-1'><divclass='marginalizedparent'><aclass='marginalized'href='#qty.scaled.unit-1'>1</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2635'>#</a></div><divclass='texpara'><divid='qty.scaled.unit-1.sentence-1'class='sentence'><spanclass='texttt'>scaled_<spanclass='shy'></span>unit<spanclass='anglebracket'><</span>M, U<spanclass='anglebracket'>></span></span> is used by the library
to represent the unit <spanclass='math'><spanclass='texttt'>M</span>×<spanclass='texttt'>U</span></span><aclass='hidden_link'href='#qty.scaled.unit-1.sentence-1'>.</a></div></div></div></div><divid='qty.named.unit'class='section'><h4><aclass='secnum'href='#qty.named.unit'style='min-width:110pt'>5.4.4.5.3</a> Named <aclass='abbr_ref'href='qty.named.unit.html'>[qty.named.unit]</a></h4><divclass='texpara'><spanid='lib:named_unit'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#lib:named_unit'>🔗</a></div><spanclass='codeblock'><spanclass='keyword'>namespace</span> mp_units <spanclass='curlybracket'>{</span>
<spanclass='keyword'>struct</span> named_unit<spanclass='anglebracket'><</span>Symbol, U, PO<spanclass='anglebracket'>></span><spanclass='operator'>:</span><spanclass='keyword'>decltype</span><spanclass='parenthesis'>(</span>U<spanclass='parenthesis'>)</span><spanclass='operator'>::</span><i>base-type</i><spanclass='curlybracket'>{</span>
<spanclass='keyword'>struct</span> named_unit<spanclass='anglebracket'><</span>Symbol, U, QS<spanclass='anglebracket'>></span><spanclass='operator'>:</span><spanclass='keyword'>decltype</span><spanclass='parenthesis'>(</span>U<spanclass='parenthesis'>)</span><spanclass='operator'>::</span><i>base-type</i><spanclass='curlybracket'>{</span>
<spanclass='keyword'>struct</span> named_unit<spanclass='anglebracket'><</span>Symbol, U, QS, PO<spanclass='anglebracket'>></span><spanclass='operator'>:</span><spanclass='keyword'>decltype</span><spanclass='parenthesis'>(</span>U<spanclass='parenthesis'>)</span><spanclass='operator'>::</span><i>base-type</i><spanclass='curlybracket'>{</span>
</span></span></div><divclass='para'id='qty.named.unit-1'><divclass='marginalizedparent'><aclass='marginalized'href='#qty.named.unit-1'>1</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2705'>#</a></div><divclass='texpara'><divid='qty.named.unit-1.sentence-1'class='sentence'>A <aclass='hidden_link'href='#def:unit,named'title='5.4.4.5.3 Named [qty.named.unit]'><spanid='def:unit,named'><i>named unit</i></span></a> is a type that models <ahref='#concept:PrefixableUnit'title='5.4.4.4 Concepts [qty.unit.concepts]'><spanid='conceptref:PrefixableUnit'><spanclass='texttt'>PrefixableUnit</span></span></a><aclass='hidden_link'href='#qty.named.unit-1.sentence-1'>.</a></div><divid='qty.named.unit-1.sentence-2'class='sentence'>A specialization of <spanclass='texttt'>named_<spanclass='shy'></span>unit</span> is used as a base type when defining a named unit<aclass='hidden_link'href='#qty.named.unit-1.sentence-2'>.</a></div></div></div><divclass='para'id='qty.named.unit-2'><divclass='marginalizedparent'><aclass='marginalized'href='#qty.named.unit-2'>2</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2709'>#</a></div><divclass='texpara'><divid='qty.named.unit-2.sentence-1'class='sentence'>In the following descriptions, let <spanclass='texttt'>U</span> be a named unit defined with an alluded signature<aclass='hidden_link'href='#qty.named.unit-2.sentence-1'>.</a></div><divid='qty.named.unit-2.sentence-2'class='sentence'>The identifier of <spanclass='texttt'>U</span> represents
or special unit name (<ahref="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=112-01-16">IEC 60050, 112-01-16</a>)<aclass='hidden_link'href='#qty.named.unit-2.sentence-2'>.</a></div><divid='qty.named.unit-2.sentence-3'class='sentence'><spanclass='texttt'>Symbol</span> is its unit symbol (<ahref="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=112-01-17">IEC 60050, 112-01-17</a>)<aclass='hidden_link'href='#qty.named.unit-2.sentence-3'>.</a></div></div></div><divclass='para'id='qty.named.unit-3'><divclass='marginalizedparent'><aclass='marginalized'href='#qty.named.unit-3'>3</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2716'>#</a></div><divclass='texpara'><divid='qty.named.unit-3.sentence-1'class='sentence'>The possible arguments to <spanclass='texttt'>named_<spanclass='shy'></span>unit</span> are
without a unit prefix (<a href="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=112-01-26">IEC 60050, 112-01-26</a>)<aclass='hidden_link'href='#qty.named.unit-4.sentence-1'>.</a></div><divid='qty.named.unit-4.sentence-2'class='sentence'>The second signature defines a unit
that can be reused by several base quantities<aclass='hidden_link'href='#qty.named.unit-4.sentence-2'>.</a></div><divid='qty.named.unit-4.sentence-3'class='sentence'>The third and fourth signatures with a unit expression argument <i>E</i>
define <spanclass='texttt'>U</span> as implicitly convertible from <i>E</i><aclass='hidden_link'href='#qty.named.unit-4.sentence-3'>.</a></div><divid='qty.named.unit-4.sentence-4'class='sentence'>The first and fourth signatures with a kind of quantity (<ahref="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=112-01-04">IEC 60050, 112-01-04</a>) <i>Q</i>
also restrict <spanclass='texttt'>U</span> to <i>Q</i><aclass='hidden_link'href='#qty.named.unit-4.sentence-4'>.</a></div></div></div><divclass='para'id='qty.named.unit-5'><divclass='marginalizedparent'><aclass='marginalized'href='#qty.named.unit-5'>5</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2739'>#</a></div><divclass='texpara'><divid='qty.named.unit-5.sentence-1'class='sentence'>A point origin argument specifies the default point origin of <spanclass='texttt'>U</span> (<ahref='qty.pt.syn.html'title='5.7.4 Class template quantity_­point'>[qty.<spanclass='shy'></span>pt.<spanclass='shy'></span>syn]</a>)<aclass='hidden_link'href='#qty.named.unit-5.sentence-1'>.</a></div></div></div><divclass='para nonNormativeOnly'id='qty.named.unit-6'><divclass='marginalizedparent'><aclass='marginalized'href='#qty.named.unit-6'>6</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2742'>#</a></div><divclass='texpara'><divid='qty.named.unit-example-1'class='example'><divclass='texpara'>[<i>Example <ahref='#qty.named.unit-example-1'>1</a></i>: <spanclass='codeblock'><spanclass='comment'>// The first signature defines a base unit restricted to a kind of base quantity.</span>
<spanclass='keyword'>inline</span><spanclass='keyword'>constexpr</span><spanclass='keyword'>struct</span> second <spanclass='keyword'>final</span><spanclass='operator'>:</span> named_unit<spanclass='anglebracket'><</span><spanclass='literal'>"s"</span>, kind_of<spanclass='anglebracket'><</span>time<spanclass='anglebracket'>></span><spanclass='anglebracket'>></span><spanclass='curlybracket'>{</span>
<spanclass='curlybracket'>}</span> second;
<spanclass='comment'>// The third and fourth signatures give a name to the unit argument.</span>
</span></span></div><divclass='para'id='qty.prefixed.unit-1'><divclass='marginalizedparent'><aclass='marginalized'href='#qty.prefixed.unit-1'>1</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2777'>#</a></div><divclass='texpara'><divid='qty.prefixed.unit-1.sentence-1'class='sentence'><spanclass='texttt'>prefixed_<spanclass='shy'></span>unit<spanclass='anglebracket'><</span>Symbol, M, U<spanclass='anglebracket'>></span></span> represents the unit <spanclass='texttt'>U</span> with a unit prefix (<ahref="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=112-01-26">IEC 60050, 112-01-26</a>)<aclass='hidden_link'href='#qty.prefixed.unit-1.sentence-1'>.</a></div><divid='qty.prefixed.unit-1.sentence-2'class='sentence'><spanclass='texttt'>Symbol</span> is the symbol of the unit prefix<aclass='hidden_link'href='#qty.prefixed.unit-1.sentence-2'>.</a></div><divid='qty.prefixed.unit-1.sentence-3'class='sentence'><spanclass='texttt'>M</span> is the factor of the unit prefix<aclass='hidden_link'href='#qty.prefixed.unit-1.sentence-3'>.</a></div><divid='qty.prefixed.unit-1.sentence-4'class='sentence'>A specialization of <spanclass='texttt'>prefixed_<spanclass='shy'></span>unit</span> is used as a base type when defining a unit prefix<aclass='hidden_link'href='#qty.prefixed.unit-1.sentence-4'>.</a></div><divid='qty.prefixed.unit-example-1'class='example'><divclass='texpara'>[<i>Example <ahref='#qty.prefixed.unit-example-1'>1</a></i>: <spanclass='codeblock'><spanclass='keyword'>template</span><spanclass='anglebracket'><</span><ahref='#concept:PrefixableUnit'title='5.4.4.4 Concepts [qty.unit.concepts]'><spanid='conceptref:PrefixableUnit__'><spanclass='tcode_in_codeblock'>PrefixableUnit</span></span></a><spanclass='keyword'>auto</span> U<spanclass='anglebracket'>></span>
</span></span></div><divclass='para'id='qty.common.unit-1'><divclass='marginalizedparent'><aclass='marginalized'href='#qty.common.unit-1'>1</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2811'>#</a></div><divclass='texpara'><divid='qty.common.unit-1.sentence-1'class='sentence'><spanclass='texttt'>common_<spanclass='shy'></span>unit</span> is used by the library
to encapsulate a conversion factor between units (<ahref="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=112-01-33">IEC 60050, 112-01-33</a>)
common to the operands of quantity addition<aclass='hidden_link'href='#qty.common.unit-1.sentence-1'>.</a></div><divid='qty.common.unit-example-1'class='example'><divclass='texpara'>[<i>Example <ahref='#qty.common.unit-example-1'>1</a></i>: <divid='qty.common.unit-1.sentence-2'class='sentence'>The result of <spanclass='texttt'><spanclass='literal'>1</span><spanclass='operator'>*</span> km <spanclass='operator'>+</span><spanclass='literal'>1</span><spanclass='operator'>*</span> mi</span>
has a common unit <spanclass="mjx-chtml"><spanclass="mjx-math"><spanclass="mjx-mrow"aria-hidden="true"><spanclass="mjx-mo"><spanclass="mjx-char MJXc-TeX-main-R"style="padding-top: 0.446em; padding-bottom: 0.593em;">[</span></span><spanclass="mjx-mn"><spanclass="mjx-char MJXc-TeX-main-R"style="padding-top: 0.372em; padding-bottom: 0.372em;">8</span></span><spanclass="mjx-texatom"><spanclass="mjx-mrow"><spanclass="mjx-mo"><spanclass="mjx-char MJXc-TeX-main-R"style="padding-top: 0.446em; padding-bottom: 0.593em;">/</span></span></span></span><spanclass="mjx-mn"><spanclass="mjx-char MJXc-TeX-main-R"style="padding-top: 0.372em; padding-bottom: 0.372em;">125</span></span><spanclass="mjx-mo"><spanclass="mjx-char MJXc-TeX-main-R"style="padding-top: 0.446em; padding-bottom: 0.593em;">]</span></span><spanclass="mjx-texatom"><spanclass="mjx-mrow"><spanclass="mjx-mtext"><spanclass="mjx-char MJXc-TeX-main-R"style="padding-top: 0.151em; padding-bottom: 0.372em;">m</span></span></span></span></span></span></span>
encapsulated by <spanclass='texttt'>common_<spanclass='shy'></span>unit<spanclass='anglebracket'><</span>mi, km<spanclass='anglebracket'>></span></span><aclass='hidden_link'href='#qty.common.unit-1.sentence-2'>.</a></div> — <i>end example</i>]</div></div><divid='qty.common.unit-1.sentence-3'class='sentence'>
A program that instantiates a specialization of <spanclass='texttt'>common_<spanclass='shy'></span>unit</span>
that is not a possible result of the library specifications
is ill-formed, no diagnostic required<aclass='hidden_link'href='#qty.common.unit-1.sentence-3'>.</a></div></div></div><divclass='texpara'><divclass='itemdecl'id='qty.common.unit-itemdecl:1'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#qty.common.unit-itemdecl:1'>🔗</a></div><codeclass='itemdeclcode'><spanclass='keyword'>template</span><spanclass='anglebracket'><</span><ahref='#concept:Unit'title='5.4.4.4 Concepts [qty.unit.concepts]'><spanid='conceptref:Unit__________________'><spanclass='texttt'>Unit</span></span></a> U1, <ahref='#concept:Unit'title='5.4.4.4 Concepts [qty.unit.concepts]'><spanid='conceptref:Unit___________________'><spanclass='texttt'>Unit</span></span></a> U2, <ahref='#concept:Unit'title='5.4.4.4 Concepts [qty.unit.concepts]'><spanid='conceptref:Unit____________________'><spanclass='texttt'>Unit</span></span></a><spanclass='operator'>.</span><spanclass='operator'>.</span><spanclass='operator'>.</span> Rest<spanclass='anglebracket'>></span>
</code></div></div><divclass='para'id='qty.common.unit-2'><divclass='marginalizedparent'><aclass='marginalized'href='#qty.common.unit-2'>2</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2831'>#</a></div><divclass='texpara'><divid='qty.common.unit-2.sentence-1'class='sentence'><i>Effects</i>: Equivalent to:
<spanclass='codeblock'><spanclass='keyword'>constexpr</span><spanclass='keyword'>auto</span> res <spanclass='operator'>=</span><spanclass='squarebracket'>[</span><spanclass='squarebracket'>]</span><spanclass='curlybracket'>{</span>
</span></div></div></div></div><divclass='para'id='qty.common.unit-3'><divclass='marginalizedparent'><aclass='marginalized'href='#qty.common.unit-3'>3</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2850'>#</a></div><divclass='texpara'><divid='qty.common.unit-3.sentence-1'class='sentence'><i>Remarks</i>: The expression in the <spanclass='textsf'><i>requires-clause</i></span> is equivalent to:
</span></span></div><divclass='para'id='qty.derived.unit-1'><divclass='marginalizedparent'><aclass='marginalized'href='#qty.derived.unit-1'>1</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2879'>#</a></div><divclass='texpara'><divid='qty.derived.unit-1.sentence-1'class='sentence'><spanclass='texttt'>derived_<spanclass='shy'></span>unit</span> is used by the library
to represent a derived unit (<ahref="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=112-01-19">IEC 60050, 112-01-19</a>)<aclass='hidden_link'href='#qty.derived.unit-1.sentence-1'>.</a></div><divid='qty.derived.unit-example-1'class='example'><divclass='texpara'>[<i>Example <ahref='#qty.derived.unit-example-1'>1</a></i>: <spanclass='codeblock'><spanclass='keyword'>using</span><spanclass='keyword'>namespace</span> si<spanclass='operator'>::</span>unit_symbols;
<spanclass='keyword'>int</span> x <spanclass='operator'>=</span> m <spanclass='operator'>*</span> m; <spanclass='comment'>// error: cannot construct from <spanclass='tcode_in_codeblock'>derived_<spanclass='shy'></span>unit<power<si​::​metre, 2>></span></span>
<spanclass='keyword'>int</span> y <spanclass='operator'>=</span> m <spanclass='operator'>*</span> s; <spanclass='comment'>// error: cannot construct from <spanclass='tcode_in_codeblock'>derived_<spanclass='shy'></span>unit<si​::​metre, si​::​second></span></span>
<spanclass='keyword'>int</span> z <spanclass='operator'>=</span> m <spanclass='operator'>/</span> s; <spanclass='comment'>// error: cannot construct from <spanclass='tcode_in_codeblock'>derived_<spanclass='shy'></span>unit<si​::​metre, per<si​::​second>></span></span>
A program that instantiates a specialization of <spanclass='texttt'>derived_<spanclass='shy'></span>unit</span>
that is not a possible result of the library specifications
is ill-formed, no diagnostic required<aclass='hidden_link'href='#qty.derived.unit-1.sentence-2'>.</a></div></div></div></div><divid='one'class='section'><h4><aclass='secnum'href='#one'style='min-width:110pt'>5.4.4.5.7</a> One <aclass='abbr_ref'href='qty.unit.one.html'>[qty.unit.one]</a></h4><divclass='texpara'><spanid='lib:one'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#lib:one'>🔗</a></div><spanclass='codeblock'><spanclass='keyword'>namespace</span> mp_units <spanclass='curlybracket'>{</span>
<spanclass='keyword'>struct</span> one <spanclass='keyword'>final</span><spanclass='operator'>:</span><i>derived-unit-impl</i><spanclass='anglebracket'><</span><spanclass='anglebracket'>></span><spanclass='curlybracket'>{</span><spanclass='curlybracket'>}</span>;
</span></span></div><divclass='para'id='one-1'><divclass='marginalizedparent'><aclass='marginalized'href='#one-1'>1</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2905'>#</a></div><divclass='texpara'><divid='one-1.sentence-1'class='sentence'><spanclass='texttt'>one</span> represents the base unit (<ahref="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=112-01-18">IEC 60050, 112-01-18</a>) of a quantity of dimension one (<ahref="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=112-01-13">IEC 60050, 112-01-13</a>)<aclass='hidden_link'href='#one-1.sentence-1'>.</a></div></div></div></div></div><divid='ops'class='section'><h4><aclass='secnum'href='#ops'style='min-width:95pt'>5.4.4.6</a> Operations <aclass='abbr_ref'href='qty.unit.ops.html'>[qty.unit.ops]</a></h4><divclass='texpara'><spanid='lib:unit-interface'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#lib:unit-interface'>🔗</a></div><spanclass='codeblock'><spanclass='keyword'>namespace</span> mp_units <spanclass='curlybracket'>{</span>
<spanclass='keyword'>template</span><spanclass='anglebracket'><</span><ahref='#concept:UnitMagnitude'title='5.4.4.2.2 Concepts [qty.unit.mag.concepts]'><spanid='conceptref:UnitMagnitude_______________'><spanclass='tcode_in_codeblock'>UnitMagnitude</span></span></a> M, <ahref='#concept:Unit'title='5.4.4.4 Concepts [qty.unit.concepts]'><spanid='conceptref:Unit______________________'><spanclass='tcode_in_codeblock'>Unit</span></span></a> U<spanclass='anglebracket'>></span>
<spanclass='keyword'>friend</span><spanclass='keyword'>consteval</span><ahref='#concept:Unit'title='5.4.4.4 Concepts [qty.unit.concepts]'><spanid='conceptref:Unit_______________________'><spanclass='tcode_in_codeblock'>Unit</span></span></a><spanclass='keyword'>auto</span><spanclass='keyword'>operator</span><spanclass='operator'>*</span><spanclass='parenthesis'>(</span>M, U u<spanclass='parenthesis'>)</span>;
<spanclass='keyword'>template</span><spanclass='anglebracket'><</span><ahref='#concept:UnitMagnitude'title='5.4.4.2.2 Concepts [qty.unit.mag.concepts]'><spanid='conceptref:UnitMagnitude_________________'><spanclass='tcode_in_codeblock'>UnitMagnitude</span></span></a> M, <ahref='#concept:Unit'title='5.4.4.4 Concepts [qty.unit.concepts]'><spanid='conceptref:Unit__________________________'><spanclass='tcode_in_codeblock'>Unit</span></span></a> U<spanclass='anglebracket'>></span>
<spanclass='keyword'>friend</span><spanclass='keyword'>consteval</span><ahref='#concept:Unit'title='5.4.4.4 Concepts [qty.unit.concepts]'><spanid='conceptref:Unit___________________________'><spanclass='tcode_in_codeblock'>Unit</span></span></a><spanclass='keyword'>auto</span><spanclass='keyword'>operator</span><spanclass='operator'>/</span><spanclass='parenthesis'>(</span>M mag, U u<spanclass='parenthesis'>)</span>;
</span></span></div><divclass='texpara'><divid='lib:Unit,operator*'><divid='lib:operator*,Unit'><divid='lib:UnitMagnitude,operator*_'><divid='lib:operator*,UnitMagnitude_'><divclass='itemdecl'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#lib:operator*,UnitMagnitude_'>🔗</a></div><codeclass='itemdeclcode'><spanclass='keyword'>template</span><spanclass='anglebracket'><</span><ahref='#concept:UnitMagnitude'title='5.4.4.2.2 Concepts [qty.unit.mag.concepts]'><spanid='conceptref:UnitMagnitude__________________'><spanclass='texttt'>UnitMagnitude</span></span></a> M, <ahref='#concept:Unit'title='5.4.4.4 Concepts [qty.unit.concepts]'><spanid='conceptref:Unit______________________________________'><spanclass='texttt'>Unit</span></span></a> U<spanclass='anglebracket'>></span>
<spanclass='keyword'>friend</span><spanclass='keyword'>consteval</span><ahref='#concept:Unit'title='5.4.4.4 Concepts [qty.unit.concepts]'><spanid='conceptref:Unit_______________________________________'><spanclass='texttt'>Unit</span></span></a><spanclass='keyword'>auto</span><spanclass='keyword'>operator</span><spanclass='operator'>*</span><spanclass='parenthesis'>(</span>M, U u<spanclass='parenthesis'>)</span>;
</code></div></div></div></div></div></div><divclass='para'id='ops-1'><divclass='marginalizedparent'><aclass='marginalized'href='#ops-1'>1</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2949'>#</a></div><divclass='texpara'><divid='ops-1.sentence-1'class='sentence'><i>Effects</i>: Equivalent to:
</code></div></div><divclass='para'id='ops-2'><divclass='marginalizedparent'><aclass='marginalized'href='#ops-2'>2</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2970'>#</a></div><divclass='texpara'><divid='ops-2.sentence-1'class='sentence'><i>Recommended practice</i>: Suggest swapping the operands<aclass='hidden_link'href='#ops-2.sentence-1'>.</a></div></div></div></div><divclass='texpara'><divid='lib:Unit,operator/'><divid='lib:operator/,Unit'><divid='lib:UnitMagnitude,operator/_'><divid='lib:operator/,UnitMagnitude_'><divclass='itemdecl'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#lib:operator/,UnitMagnitude_'>🔗</a></div><codeclass='itemdeclcode'><spanclass='keyword'>template</span><spanclass='anglebracket'><</span><ahref='#concept:UnitMagnitude'title='5.4.4.2.2 Concepts [qty.unit.mag.concepts]'><spanid='conceptref:UnitMagnitude____________________'><spanclass='texttt'>UnitMagnitude</span></span></a> M, <ahref='#concept:Unit'title='5.4.4.4 Concepts [qty.unit.concepts]'><spanid='conceptref:Unit__________________________________________'><spanclass='texttt'>Unit</span></span></a> U<spanclass='anglebracket'>></span>
<spanclass='keyword'>friend</span><spanclass='keyword'>consteval</span><ahref='#concept:Unit'title='5.4.4.4 Concepts [qty.unit.concepts]'><spanid='conceptref:Unit___________________________________________'><spanclass='texttt'>Unit</span></span></a><spanclass='keyword'>auto</span><spanclass='keyword'>operator</span><spanclass='operator'>/</span><spanclass='parenthesis'>(</span>M mag, U u<spanclass='parenthesis'>)</span>;
</code></div></div></div></div><divclass='para'id='cmp-2'><divclass='marginalizedparent'><aclass='marginalized'href='#cmp-2'>2</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L3101'>#</a></div><divclass='texpara'><divid='cmp-2.sentence-1'class='sentence'><i>Effects</i>: Equivalent to:
<spanclass='keyword'>consteval</span><spanclass='keyword'>bool</span> convertible<spanclass='parenthesis'>(</span>From from, To to<spanclass='parenthesis'>)</span>;
</code></div></div></div></div><divclass='para'id='cmp-3'><divclass='marginalizedparent'><aclass='marginalized'href='#cmp-3'>3</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L3119'>#</a></div><divclass='texpara'><divid='cmp-3.sentence-1'class='sentence'><i>Effects</i>: Equivalent to:
<ulclass='itemize'><liid='obs-3.1'><divclass='marginalizedparent'style='left:-39mm'><aclass='marginalized'href='#obs-3.1'>(3.1)</a></div><spanclass='texttt'>u1</span> be <spanclass='texttt'>us<spanclass='operator'>.</span><spanclass='operator'>.</span><spanclass='operator'>.</span><spanclass='squarebracket'>[</span><spanclass='literal'>0</span><spanclass='squarebracket'>]</span></span>,</li><liid='obs-3.2'><divclass='marginalizedparent'style='left:-39mm'><aclass='marginalized'href='#obs-3.2'>(3.2)</a></div><spanclass='texttt'>u2</span> be <spanclass='texttt'>us<spanclass='operator'>.</span><spanclass='operator'>.</span><spanclass='operator'>.</span><spanclass='squarebracket'>[</span><spanclass='literal'>1</span><spanclass='squarebracket'>]</span></span>,</li><liid='obs-3.3'><divclass='marginalizedparent'style='left:-39mm'><aclass='marginalized'href='#obs-3.3'>(3.3)</a></div><spanclass='texttt'>U1</span> be <spanclass='texttt'><spanclass='keyword'>decltype</span><spanclass='parenthesis'>(</span>u1<spanclass='parenthesis'>)</span></span>,</li><liid='obs-3.4'><divclass='marginalizedparent'style='left:-39mm'><aclass='marginalized'href='#obs-3.4'>(3.4)</a></div><spanclass='texttt'>U2</span> be <spanclass='texttt'><spanclass='keyword'>decltype</span><spanclass='parenthesis'>(</span>u2<spanclass='parenthesis'>)</span></span>, and</li><liid='obs-3.5'><divclass='marginalizedparent'style='left:-39mm'><aclass='marginalized'href='#obs-3.5'>(3.5)</a></div><spanclass='texttt'>rest</span> be a pack denoting the elements of <spanclass='texttt'>us</span> without <spanclass='texttt'>u1</span> and <spanclass='texttt'>u2</span><aclass='hidden_link'href='#obs-3.sentence-1'>.</a></li></ul></div></div></div></div><divclass='para'id='obs-4'><divclass='marginalizedparent'><aclass='marginalized'href='#obs-4'>4</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L3179'>#</a></div><divclass='texpara'><divid='obs-4.sentence-1'class='sentence'><i>Effects</i>: Equivalent to:
</span></div></div></div></div><divclass='para'id='obs-5'><divclass='marginalizedparent'><aclass='marginalized'href='#obs-5'>5</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L3218'>#</a></div><divclass='texpara'><divid='obs-5.sentence-1'class='sentence'><i>Remarks</i>: The expression in the <spanclass='textsf'><i>requires-clause</i></span> is equivalent to:
</code></div></div></div></div><divclass='para'id='assoc.qty-1'><divclass='marginalizedparent'><aclass='marginalized'href='#assoc.qty-1'>1</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L3237'>#</a></div><divclass='texpara'><divid='assoc.qty-1.sentence-1'class='sentence'><i>Returns</i>: <ulclass='itemize'><liid='assoc.qty-1.1'><divclass='marginalizedparent'style='left:-39mm'><aclass='marginalized'href='#assoc.qty-1.1'>(1.1)</a></div><divclass='texpara'><divid='assoc.qty-1.1.sentence-1'class='sentence'>If <spanclass='texttt'>U<spanclass='operator'>​::​</span><spanclass='texttt'><i>quantity-spec</i></span></span> is a valid expression,
returns <spanclass='texttt'><spanclass='literal'>true</span></span><aclass='hidden_link'href='#assoc.qty-1.1.sentence-1'>.</a></div></div></li><liid='assoc.qty-1.2'><divclass='marginalizedparent'style='left:-39mm'><aclass='marginalized'href='#assoc.qty-1.2'>(1.2)</a></div><divclass='texpara'><divid='assoc.qty-1.2.sentence-1'class='sentence'>Otherwise, if <spanclass='texttt'>U<spanclass='operator'>​::​</span><spanclass='texttt'><i>reference-unit</i></span></span> is a valid expression,
</span></div></div></li><liid='assoc.qty-1.3'><divclass='marginalizedparent'style='left:-39mm'><aclass='marginalized'href='#assoc.qty-1.3'>(1.3)</a></div><divclass='texpara'><divid='assoc.qty-1.3.sentence-1'class='sentence'>Otherwise, if
is <spanclass='texttt'><spanclass='literal'>true</span></span>,
let <spanclass='texttt'>Nums</span> and <spanclass='texttt'>Dens</span>
be packs denoting the template arguments of
<spanclass='texttt'>U<spanclass='operator'>​::​</span><spanclass='texttt'><i>nums</i></span></span> and <spanclass='texttt'>U<spanclass='operator'>​::​</span><spanclass='texttt'><i>dens</i></span></span>, respectively<aclass='hidden_link'href='#assoc.qty-1.3.sentence-1'>.</a></div><divid='assoc.qty-1.3.sentence-2'class='sentence'>Returns
</code></div></div></div></div><divclass='para'id='assoc.qty-2'><divclass='marginalizedparent'><aclass='marginalized'href='#assoc.qty-2'>2</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L3273'>#</a></div><divclass='texpara'><divid='assoc.qty-2.sentence-1'class='sentence'><i>Returns</i>: <ulclass='itemize'><liid='assoc.qty-2.1'><divclass='marginalizedparent'style='left:-39mm'><aclass='marginalized'href='#assoc.qty-2.1'>(2.1)</a></div>If <spanclass='texttt'>U</span> is of the form <spanclass='texttt'>common_<spanclass='shy'></span>unit<spanclass='anglebracket'><</span>Us<spanclass='operator'>.</span><spanclass='operator'>.</span><spanclass='operator'>.</span><spanclass='anglebracket'>></span></span>,
</span></li><liid='assoc.qty-2.2'><divclass='marginalizedparent'style='left:-39mm'><aclass='marginalized'href='#assoc.qty-2.2'>(2.2)</a></div>Otherwise, if <spanclass='texttt'>U<spanclass='operator'>​::​</span><spanclass='texttt'><i>quantity-spec</i></span></span> is a valid expression,
</span></li><liid='assoc.qty-2.3'><divclass='marginalizedparent'style='left:-39mm'><aclass='marginalized'href='#assoc.qty-2.3'>(2.3)</a></div>Otherwise, if <spanclass='texttt'>U<spanclass='operator'>​::​</span><spanclass='texttt'><i>reference-unit</i></span></span> is a valid expression,
</span></li><liid='assoc.qty-2.4'><divclass='marginalizedparent'style='left:-39mm'><aclass='marginalized'href='#assoc.qty-2.4'>(2.4)</a></div>Otherwise, if
</span></li></ul></div></div></div></div></div><divid='sym.fmt'class='section'><h4><aclass='secnum'href='#sym.fmt'style='min-width:95pt'>5.4.4.10</a> Symbol formatting <aclass='abbr_ref'href='qty.unit.sym.fmt.html'>[qty.unit.sym.fmt]</a></h4><divclass='texpara'><divid='lib:Unit,unit_symbol_to'><divid='lib:unit_symbol_to,Unit'><divclass='itemdecl'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#lib:unit_symbol_to,Unit'>🔗</a></div><codeclass='itemdeclcode'><spanclass='keyword'>template</span><spanclass='anglebracket'><</span><spanclass='keyword'>typename</span> CharT <spanclass='operator'>=</span><spanclass='keyword'>char</span>, std<spanclass='operator'>::</span>output_iterator<spanclass='anglebracket'><</span>CharT<spanclass='anglebracket'>></span> Out, <ahref='#concept:Unit'title='5.4.4.4 Concepts [qty.unit.concepts]'><spanid='conceptref:Unit________________________________________________________________________'><spanclass='texttt'>Unit</span></span></a> U<spanclass='anglebracket'>></span>
<spanclass='keyword'>constexpr</span> Out unit_symbol_to<spanclass='parenthesis'>(</span>Out out, U u, <spanclass='keyword'>const</span> unit_symbol_formatting<spanclass='operator'>&</span> fmt <spanclass='operator'>=</span><spanclass='curlybracket'>{</span><spanclass='curlybracket'>}</span><spanclass='parenthesis'>)</span>;
</code></div></div></div></div><divclass='para'id='sym.fmt-3'><divclass='marginalizedparent'><aclass='marginalized'href='#sym.fmt-3'>3</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L3335'>#</a></div><divclass='texpara'><divid='sym.fmt-3.sentence-1'class='sentence'><i>Effects</i>: Equivalent to: