<!DOCTYPE html><htmllang='en'><head><title>[qty.common.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.common.unit'>[qty.ref]</a></h2><h3><aclass='secnum'style='min-width:80pt'>5.4.4</a> Unit <aclass='abbr_ref'href='qty.unit.html#qty.common.unit'>[qty.unit]</a></h3><h4><aclass='secnum'style='min-width:95pt'>5.4.4.5</a> Types <aclass='abbr_ref'href='qty.unit.types.html#qty.common.unit'>[qty.unit.types]</a></h4><h4><aclass='secnum'style='min-width:110pt'>5.4.4.5.5</a> Common <aclass='abbr_ref'>[qty.common.unit]</a></h4><divclass='texpara'><spanid='lib:common_unit'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#lib:common_unit'>🔗</a></div><spanclass='codeblock'><spanclass='keyword'>namespace</span> mp_units <spanclass='curlybracket'>{</span>
</span></span></div><divclass='para'id='1'><divclass='marginalizedparent'><aclass='marginalized'href='#1'>1</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L2811'>#</a></div><divclass='texpara'><divid='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='#1.sentence-1'>.</a></div><divid='example-1'class='example'><divclass='texpara'>[<i>Example <ahref='#example-1'>1</a></i>: <divid='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='#1.sentence-2'>.</a></div> — <i>end example</i>]</div></div><divid='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='#1.sentence-3'>.</a></div></div></div><divclass='texpara'><divclass='itemdecl'id='itemdecl:1'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#itemdecl:1'>🔗</a></div><codeclass='itemdeclcode'><spanclass='keyword'>template</span><spanclass='anglebracket'><</span><ahref='qty.unit.concepts.html#concept:Unit'title='5.4.4.4 Concepts [qty.unit.concepts]'><spanid='conceptref:Unit___'><spanclass='texttt'>Unit</span></span></a> U1, <ahref='qty.unit.concepts.html#concept:Unit'title='5.4.4.4 Concepts [qty.unit.concepts]'><spanid='conceptref:Unit____'><spanclass='texttt'>Unit</span></span></a> U2, <ahref='qty.unit.concepts.html#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='2'><divclass='marginalizedparent'><aclass='marginalized'href='#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='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='3'><divclass='marginalizedparent'><aclass='marginalized'href='#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='3.sentence-1'class='sentence'><i>Remarks</i>: The expression in the <spanclass='textsf'><i>requires-clause</i></span> is equivalent to: