forked from mpusz/mp-units
23 lines
9.1 KiB
HTML
23 lines
9.1 KiB
HTML
<!DOCTYPE html><html lang='en'><head><title>[qty.spec.utils]</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.spec.utils'>[qty.ref]</a></h2><h3 ><a class='secnum' style='min-width:80pt'>5.4.3</a> Quantity specification <a class='abbr_ref' href='qty.spec.html#utils'>[qty.spec]</a></h3><h4 ><a class='secnum' style='min-width:95pt'>5.4.3.4</a> Utilities <a class='abbr_ref'>[qty.spec.utils]</a></h4><div class='texpara'><div id='lib:clone-kind-of,QuantitySpec'><div id='lib:QuantitySpec,clone-kind-of'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:QuantitySpec,clone-kind-of'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'><</span><a href='qty.spec.concepts.html#concept:QuantitySpec' title='5.4.3.2 Concepts [qty.spec.concepts]'><span id='conceptref:QuantitySpec'><span class='texttt'>QuantitySpec</span></span></a> <span class='keyword'>auto</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span> From, <a href='qty.spec.concepts.html#concept:QuantitySpec' title='5.4.3.2 Concepts [qty.spec.concepts]'><span id='conceptref:QuantitySpec_'><span class='texttt'>QuantitySpec</span></span></a> Q<span class='anglebracket'>></span>
|
|
<span class='keyword'>consteval</span> <a href='qty.spec.concepts.html#concept:QuantitySpec' title='5.4.3.2 Concepts [qty.spec.concepts]'><span id='conceptref:QuantitySpec__'><span class='texttt'>QuantitySpec</span></span></a> <span class='keyword'>auto</span> <span class='texttt'><i >clone-kind-of</i></span><span class='parenthesis'>(</span>Q q<span class='parenthesis'>)</span>; <span class='comment'>// <i >exposition only</i></span>
|
|
</code></div></div></div></div><div class='para' id='1'><div class='marginalizedparent'><a class='marginalized' href='#1'>1</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/mpusz/mp-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L1844'>#</a></div><div class='texpara'><div id='1.sentence-1' class='sentence'><i >Effects</i>: Equivalent to:
|
|
<span class='codeblock'><span class='keyword'>if</span> <span class='keyword'>constexpr</span> <span class='parenthesis'>(</span><span class='parenthesis'>(</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span> <span class='operator'>&</span><span class='operator'>&</span> <a class='index' id='conceptref:QuantityKindSpec'></a><i >QuantityKindSpec</i><span class='anglebracket'><</span><span class='keyword'>decltype</span><span class='parenthesis'>(</span>From<span class='parenthesis'>)</span><span class='anglebracket'>></span><span class='parenthesis'>)</span><span class='parenthesis'>)</span>
|
|
<span class='keyword'>return</span> kind_of<span class='anglebracket'><</span>Q<span class='curlybracket'>{</span><span class='curlybracket'>}</span><span class='anglebracket'>></span>;
|
|
<span class='keyword'>else</span>
|
|
<span class='keyword'>return</span> q;
|
|
</span></div></div></div></div><div class='texpara'><div id='lib:remove-kind,QuantitySpec'><div id='lib:QuantitySpec,remove-kind'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:QuantitySpec,remove-kind'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'><</span><a href='qty.spec.concepts.html#concept:QuantitySpec' title='5.4.3.2 Concepts [qty.spec.concepts]'><span id='conceptref:QuantitySpec___'><span class='texttt'>QuantitySpec</span></span></a> Q<span class='anglebracket'>></span>
|
|
<span class='keyword'>consteval</span> <span class='keyword'>auto</span> <span class='texttt'><i >remove-kind</i></span><span class='parenthesis'>(</span>Q q<span class='parenthesis'>)</span>; <span class='comment'>// <i >exposition only</i></span>
|
|
</code></div></div></div></div><div class='para' id='2'><div class='marginalizedparent'><a class='marginalized' href='#2'>2</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/mpusz/mp-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L1862'>#</a></div><div class='texpara'><div id='2.sentence-1' class='sentence'><i >Effects</i>: Equivalent to:
|
|
<span class='codeblock'><span class='keyword'>if</span> <span class='keyword'>constexpr</span> <span class='parenthesis'>(</span><a class='index' id='conceptref:QuantityKindSpec_'></a><i >QuantityKindSpec</i><span class='anglebracket'><</span>Q<span class='anglebracket'>></span><span class='parenthesis'>)</span>
|
|
<span class='keyword'>return</span> Q<span class='operator'>::</span><i >quantity-spec</i>;
|
|
<span class='keyword'>else</span>
|
|
<span class='keyword'>return</span> q;
|
|
</span></div></div></div></div><div class='texpara'><div id='lib:make-reference,Unit'><div id='lib:Unit,make-reference'><div id='lib:make-reference,QuantitySpec'><div id='lib:QuantitySpec,make-reference'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:QuantitySpec,make-reference'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'><</span><a href='qty.spec.concepts.html#concept:QuantitySpec' title='5.4.3.2 Concepts [qty.spec.concepts]'><span id='conceptref:QuantitySpec____'><span class='texttt'>QuantitySpec</span></span></a> QS, <a href='qty.unit.concepts.html#concept:Unit' title='5.4.4.4 Concepts [qty.unit.concepts]'><span id='conceptref:Unit'><span class='texttt'>Unit</span></span></a> U<span class='anglebracket'>></span>
|
|
<span class='keyword'>requires</span><span class='parenthesis'>(</span><span class='operator'>!</span><a href='qty.unit.concepts.html#concept:AssociatedUnit' title='5.4.4.4 Concepts [qty.unit.concepts]'><span id='conceptref:AssociatedUnit'><span class='texttt'>AssociatedUnit</span></span></a><span class='anglebracket'><</span>U<span class='anglebracket'>></span><span class='parenthesis'>)</span> <span class='operator'>|</span><span class='operator'>|</span> <a href='qty.unit.concepts.html#concept:UnitOf' title='5.4.4.4 Concepts [qty.unit.concepts]'><span id='conceptref:UnitOf'><span class='texttt'>UnitOf</span></span></a><span class='anglebracket'><</span>U, QS<span class='curlybracket'>{</span><span class='curlybracket'>}</span><span class='anglebracket'>></span>
|
|
<span class='keyword'>consteval</span> <a href='qty.ref.concepts.html#concept:Reference' title='5.4.5 Concepts [qty.ref.concepts]'><span id='conceptref:Reference'><span class='texttt'>Reference</span></span></a> <span class='keyword'>auto</span> <span class='texttt'><i >make-reference</i></span><span class='parenthesis'>(</span>QS, U u<span class='parenthesis'>)</span>; <span class='comment'>// <i >exposition only</i></span>
|
|
</code></div></div></div></div></div></div><div class='para' id='3'><div class='marginalizedparent'><a class='marginalized' href='#3'>3</a></div><div class='itemdescr'><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/mpusz/mp-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L1882'>#</a></div><div class='texpara'><div id='3.sentence-1' class='sentence'><i >Effects</i>: Equivalent to:
|
|
<span class='codeblock'><span class='keyword'>if</span> <span class='keyword'>constexpr</span> <span class='parenthesis'>(</span><span class='keyword'>requires</span> <span class='curlybracket'>{</span> <span class='keyword'>requires</span> get_quantity_spec<span class='parenthesis'>(</span>U<span class='curlybracket'>{</span><span class='curlybracket'>}</span><span class='parenthesis'>)</span> <span class='operator'>=</span><span class='operator'>=</span> QS<span class='curlybracket'>{</span><span class='curlybracket'>}</span>; <span class='curlybracket'>}</span><span class='parenthesis'>)</span>
|
|
<span class='keyword'>return</span> u;
|
|
<span class='keyword'>else</span>
|
|
<span class='keyword'>return</span> reference<span class='anglebracket'><</span>QS, U<span class='anglebracket'>></span><span class='curlybracket'>{</span><span class='curlybracket'>}</span>;
|
|
</span></div></div></div></div></div></body></html> |