<!DOCTYPE html><htmllang='en'><head><title>[qty.ref.syn]</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#syn'>[qty.ref]</a></h2><h3><aclass='secnum'style='min-width:80pt'>5.4.6</a> Class template <spanclass='texttt'>reference</span><aclass='abbr_ref'>[qty.ref.syn]</a></h3><divclass='texpara'><spanid='lib:reference,cbrt'><spanid='lib:cbrt,reference'><spanid='lib:reference,sqrt'><spanid='lib:sqrt,reference'><spanid='lib:reference,pow'><spanid='lib:pow,reference'><spanid='lib:reference,inverse'><spanid='lib:inverse,reference'><spanid='lib:AssociatedUnit,operator/'><spanid='lib:operator/,AssociatedUnit'><spanid='lib:reference,operator/'><spanid='lib:operator/,reference'><spanid='lib:AssociatedUnit,operator*'><spanid='lib:operator*,AssociatedUnit'><spanid='lib:reference,operator*'><spanid='lib:operator*,reference'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#lib:operator*,reference'>🔗</a></div><spanclass='codeblock'><spanclass='keyword'>namespace</span> mp_units <spanclass='curlybracket'>{</span>
<spanclass='keyword'>template</span><spanclass='anglebracket'><</span><ahref='qty.spec.concepts.html#concept:QuantitySpec'title='5.4.3.2 Concepts [qty.spec.concepts]'><spanid='conceptref:QuantitySpec'><spanclass='tcode_in_codeblock'>QuantitySpec</span></span></a><spanclass='keyword'>auto</span> Q, <ahref='qty.unit.concepts.html#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> U<spanclass='anglebracket'>></span>
<spanclass='keyword'>template</span><spanclass='anglebracket'><</span><ahref='qty.spec.concepts.html#concept:QuantitySpec'title='5.4.3.2 Concepts [qty.spec.concepts]'><spanid='conceptref:QuantitySpec_'><spanclass='tcode_in_codeblock'>QuantitySpec</span></span></a> Q, <ahref='qty.unit.concepts.html#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'>template</span><spanclass='anglebracket'><</span>std<spanclass='operator'>::</span>intmax_t Num, std<spanclass='operator'>::</span>intmax_t Den <spanclass='operator'>=</span><spanclass='literal'>1</span><spanclass='anglebracket'>></span>
<spanclass='keyword'>friend</span><spanclass='keyword'>consteval</span><spanclass='keyword'>bool</span><spanclass='keyword'>operator</span><spanclass='operator'>=</span><spanclass='operator'>=</span><spanclass='parenthesis'>(</span>reference, U2 u2<spanclass='parenthesis'>)</span>;
<spanclass='keyword'>friend</span><spanclass='keyword'>consteval</span><spanclass='keyword'>bool</span> convertible<spanclass='parenthesis'>(</span>reference, U2 u2<spanclass='parenthesis'>)</span>;
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></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#L3431'>#</a></div><divclass='texpara'><divid='1.sentence-1'class='sentence'><spanclass='texttt'>reference<spanclass='anglebracket'><</span>Q, U<spanclass='anglebracket'>></span></span> represents the reference of a quantity (<ahref="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=112-01-01">IEC 60050, 112-01-01</a>)<aclass='hidden_link'href='#1.sentence-1'>.</a></div><divid='1.sentence-2'class='sentence'>The unit of measurement <spanclass='texttt'>U</span> (<ahref="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=112-01-14">IEC 60050, 112-01-14</a>)
is used to measure a value of the quantity <spanclass='texttt'>Q</span> (<ahref="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=112-01-28">IEC 60050, 112-01-28</a>)<aclass='hidden_link'href='#1.sentence-2'>.</a></div><divid='note-1'class='note'><divclass='texpara'>[<i>Note <ahref='#note-1'>1</a></i>: <divid='1.sentence-3'class='sentence'><spanclass='texttt'>reference</span> is typically implicitly instantiated
when specifying that a unit measures a more specific quantity<aclass='hidden_link'href='#1.sentence-3'>.</a></div><divid='example-1'class='example'><divclass='texpara'>[<i>Example <ahref='#example-1'>1</a></i>: <spanclass='codeblock'><spanclass='keyword'>using</span><spanclass='keyword'>namespace</span> si<spanclass='operator'>::</span>unit_symbols;
<spanclass='keyword'>auto</span> x <spanclass='operator'>=</span><spanclass='literal'>1</span><spanclass='operator'>*</span> m; <spanclass='comment'>// measures a length</span>
<spanclass='keyword'>auto</span> y <spanclass='operator'>=</span><spanclass='literal'>1</span><spanclass='operator'>*</span> isq<spanclass='operator'>::</span>width<spanclass='squarebracket'>[</span>m<spanclass='squarebracket'>]</span>; <spanclass='comment'>// measures a width</span>
<spanclass='keyword'>auto</span> z <spanclass='operator'>=</span><spanclass='literal'>1</span><spanclass='operator'>*</span> isq<spanclass='operator'>::</span>diameter<spanclass='squarebracket'>[</span>m<spanclass='squarebracket'>]</span>; <spanclass='comment'>// measures a diameter</span>