Files
mp-units/HEAD/api_reference/gen/qty.prefixed.unit.html
T

18 lines
6.4 KiB
HTML

<!DOCTYPE html><html lang='en'><head><title>[qty.prefixed.unit]</title><meta charset='UTF-8'/><link rel='stylesheet' type='text/css' href='14882.css'/><link rel='stylesheet' type='text/css' href='https://fonts.googleapis.com/css2?family=Noto+Serif'/><link rel='stylesheet' type='text/css' href='https://fonts.googleapis.com/css2?family=Noto+Sans'/><link rel='stylesheet' type='text/css' href='https://fonts.googleapis.com/css2?family=Noto+Sans+Mono'/><link rel='icon' href='icon.png'/><link rel='stylesheet' type='text/css' href='expanded.css' title='Normal'/><link rel='alternate stylesheet' type='text/css' href='colored.css' title='Notes and examples colored'/><link rel='alternate stylesheet' type='text/css' href='normative-only.css' title='Notes and examples hidden'/></head><body><div class='wrapper'><h1 ><a class='secnum' style='min-width:50pt'>5</a> Quantities and units library <a class='abbr_ref' href='index.html#quantities'>[quantities]</a></h1><h2 ><a class='secnum' style='min-width:65pt'>5.4</a> Reference <a class='abbr_ref' href='qty.ref.html#qty.prefixed.unit'>[qty.ref]</a></h2><h3 ><a class='secnum' style='min-width:80pt'>5.4.4</a> Unit <a class='abbr_ref' href='qty.unit.html#qty.prefixed.unit'>[qty.unit]</a></h3><h4 ><a class='secnum' style='min-width:95pt'>5.4.4.5</a> Types <a class='abbr_ref' href='qty.unit.types.html#qty.prefixed.unit'>[qty.unit.types]</a></h4><h4 ><a class='secnum' style='min-width:110pt'>5.4.4.5.4</a> Prefixed <a class='abbr_ref'>[qty.prefixed.unit]</a></h4><div class='texpara'><span id='lib:prefixed_unit'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:prefixed_unit'>🔗</a></div><span class='codeblock'><span class='keyword'>namespace</span> mp_units <span class='curlybracket'>{</span>
<span class='keyword'>template</span><span class='anglebracket'>&lt;</span>symbol_text Symbol, <a href='qty.unit.mag.concepts.html#concept:UnitMagnitude' title='5.4.4.2.2&emsp;Concepts&emsp;[qty.unit.mag.concepts]'><span id='conceptref:UnitMagnitude'><span class='tcode_in_codeblock'>UnitMagnitude</span></span></a> <span class='keyword'>auto</span> M, <a href='qty.unit.concepts.html#concept:PrefixableUnit' title='5.4.4.4&emsp;Concepts&emsp;[qty.unit.concepts]'><span id='conceptref:PrefixableUnit'><span class='tcode_in_codeblock'>PrefixableUnit</span></span></a> <span class='keyword'>auto</span> U<span class='anglebracket'>&gt;</span>
<span class='keyword'>requires</span><span class='parenthesis'>(</span><span class='operator'>!</span>Symbol<span class='operator'>.</span>empty<span class='parenthesis'>(</span><span class='parenthesis'>)</span><span class='parenthesis'>)</span>
<span class='keyword'>struct</span> prefixed_unit <span class='operator'>:</span> <span class='keyword'>decltype</span><span class='parenthesis'>(</span>M <span class='operator'>*</span> U<span class='parenthesis'>)</span><span class='operator'>::</span><i >base-type</i> <span class='curlybracket'>{</span>
<span class='keyword'>using</span> <i >base-type</i> <span class='operator'>=</span> prefixed_unit; <span class='comment'>// <i >exposition only</i></span>
<span class='keyword'>static</span> <span class='keyword'>constexpr</span> <span class='keyword'>auto</span> <i >symbol</i> <span class='operator'>=</span> Symbol <span class='operator'>+</span> U<span class='operator'>.</span><i >symbol</i>; <span class='comment'>// <i >exposition only</i></span>
<span class='curlybracket'>}</span>;
<span class='curlybracket'>}</span>
</span></span></div><div class='para' id='1'><div class='marginalizedparent'><a class='marginalized' href='#1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/mpusz/mp-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L2777'>#</a></div><div class='texpara'><div id='1.sentence-1' class='sentence'><span class='texttt'>prefixed_<span class='shy'></span>unit<span class='anglebracket'>&lt;</span>Symbol, M, U<span class='anglebracket'>&gt;</span></span> represents the unit <span class='texttt'>U</span> with a unit prefix (<a href="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=112-01-26">IEC 60050, 112-01-26</a>)<a class='hidden_link' href='#1.sentence-1'>.</a></div> <div id='1.sentence-2' class='sentence'><span class='texttt'>Symbol</span> is the symbol of the unit prefix<a class='hidden_link' href='#1.sentence-2'>.</a></div> <div id='1.sentence-3' class='sentence'><span class='texttt'>M</span> is the factor of the unit prefix<a class='hidden_link' href='#1.sentence-3'>.</a></div> <div id='1.sentence-4' class='sentence'>A specialization of <span class='texttt'>prefixed_<span class='shy'></span>unit</span> is used as a base type when defining a unit prefix<a class='hidden_link' href='#1.sentence-4'>.</a></div> <div id='example-1' class='example'><div class='texpara'>[<i>Example&nbsp;<a href='#example-1'>1</a></i>:&ensp;<span class='codeblock'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><a href='qty.unit.concepts.html#concept:PrefixableUnit' title='5.4.4.4&emsp;Concepts&emsp;[qty.unit.concepts]'><span id='conceptref:PrefixableUnit_'><span class='tcode_in_codeblock'>PrefixableUnit</span></span></a> <span class='keyword'>auto</span> U<span class='anglebracket'>&gt;</span>
<span class='keyword'>struct</span> kilo_ <span class='operator'>:</span> prefixed_unit<span class='anglebracket'>&lt;</span><span class='literal'>"k"</span>, mag_power<span class='anglebracket'>&lt;</span><span class='literal'>10</span>, <span class='literal'>3</span><span class='anglebracket'>&gt;</span>, U<span class='anglebracket'>&gt;</span> <span class='curlybracket'>{</span><span class='curlybracket'>}</span>;
<span class='keyword'>template</span><span class='anglebracket'>&lt;</span><a href='qty.unit.concepts.html#concept:PrefixableUnit' title='5.4.4.4&emsp;Concepts&emsp;[qty.unit.concepts]'><span id='conceptref:PrefixableUnit__'><span class='tcode_in_codeblock'>PrefixableUnit</span></span></a> <span class='keyword'>auto</span> U<span class='anglebracket'>&gt;</span>
<span class='keyword'>constexpr</span> kilo_<span class='anglebracket'>&lt;</span>U<span class='anglebracket'>&gt;</span> kilo;
<span class='keyword'>inline</span> <span class='keyword'>constexpr</span> <span class='keyword'>auto</span> kilogram <span class='operator'>=</span> kilo<span class='anglebracket'>&lt;</span>si<span class='operator'>::</span>gram<span class='anglebracket'>&gt;</span>;
</span>&nbsp;<i>end example</i>]</div></div></div></div></div></body></html>