<!DOCTYPE html><htmllang='en'><head><title>[qty.named.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.named.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.named.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.named.unit'>[qty.unit.types]</a></h4><h4><aclass='secnum'style='min-width:110pt'>5.4.4.5.3</a> Named <aclass='abbr_ref'>[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='1'><divclass='marginalizedparent'><aclass='marginalized'href='#1'>1</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L2705'>#</a></div><divclass='texpara'><divid='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='qty.unit.concepts.html#concept:PrefixableUnit'title='5.4.4.4 Concepts [qty.unit.concepts]'><spanid='conceptref:PrefixableUnit'><spanclass='texttt'>PrefixableUnit</span></span></a><aclass='hidden_link'href='#1.sentence-1'>.</a></div><divid='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='#1.sentence-2'>.</a></div></div></div><divclass='para'id='2'><divclass='marginalizedparent'><aclass='marginalized'href='#2'>2</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L2709'>#</a></div><divclass='texpara'><divid='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='#2.sentence-1'>.</a></div><divid='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='#2.sentence-2'>.</a></div><divid='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='#2.sentence-3'>.</a></div></div></div><divclass='para'id='3'><divclass='marginalizedparent'><aclass='marginalized'href='#3'>3</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L2716'>#</a></div><divclass='texpara'><divid='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='#4.sentence-1'>.</a></div><divid='4.sentence-2'class='sentence'>The second signature defines a unit
that can be reused by several base quantities<aclass='hidden_link'href='#4.sentence-2'>.</a></div><divid='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='#4.sentence-3'>.</a></div><divid='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='#4.sentence-4'>.</a></div></div></div><divclass='para'id='5'><divclass='marginalizedparent'><aclass='marginalized'href='#5'>5</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L2739'>#</a></div><divclass='texpara'><divid='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='#5.sentence-1'>.</a></div></div></div><divclass='para nonNormativeOnly'id='6'><divclass='marginalizedparent'><aclass='marginalized'href='#6'>6</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L2742'>#</a></div><divclass='texpara'><divid='example-1'class='example'><divclass='texpara'>[<i>Example <ahref='#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>