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

20 lines
7.9 KiB
HTML

<!DOCTYPE html><html lang='en'><head><title>[qty.unit.cmp]</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.unit.cmp'>[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#cmp'>[qty.unit]</a></h3><h4 ><a class='secnum' style='min-width:95pt'>5.4.4.7</a> Comparison <a class='abbr_ref'>[qty.unit.cmp]</a></h4><div class='texpara'><div id='lib:Unit,operator=='><div id='lib:operator==,Unit'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:operator==,Unit'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><a href='qty.unit.concepts.html#concept:Unit' title='5.4.4.4&emsp;Concepts&emsp;[qty.unit.concepts]'><span id='conceptref:Unit'><span class='texttt'>Unit</span></span></a> Lhs, <a href='qty.unit.concepts.html#concept:Unit' title='5.4.4.4&emsp;Concepts&emsp;[qty.unit.concepts]'><span id='conceptref:Unit_'><span class='texttt'>Unit</span></span></a> Rhs<span class='anglebracket'>&gt;</span>
<span class='keyword'>friend</span> <span class='keyword'>consteval</span> <span class='keyword'>bool</span> <span class='keyword'>operator</span><span class='operator'>=</span><span class='operator'>=</span><span class='parenthesis'>(</span>Lhs, Rhs<span class='parenthesis'>)</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#L3089'>#</a></div><div class='texpara'><div id='1.sentence-1' class='sentence'><i >Returns</i>: <span class='texttt'>std<span class='operator'>&#x200b;::&#x200b;</span>is_<span class='shy'></span>same_<span class='shy'></span>v<span class='anglebracket'>&lt;</span>Lhs, Rhs<span class='anglebracket'>&gt;</span></span><a class='hidden_link' href='#1.sentence-1'>.</a></div></div></div></div><div class='texpara'><div id='lib:Unit,equivalent'><div id='lib:equivalent,Unit'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:equivalent,Unit'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><a href='qty.unit.concepts.html#concept:Unit' title='5.4.4.4&emsp;Concepts&emsp;[qty.unit.concepts]'><span id='conceptref:Unit__'><span class='texttt'>Unit</span></span></a> Lhs, <a href='qty.unit.concepts.html#concept:Unit' title='5.4.4.4&emsp;Concepts&emsp;[qty.unit.concepts]'><span id='conceptref:Unit___'><span class='texttt'>Unit</span></span></a> Rhs<span class='anglebracket'>&gt;</span>
<span class='keyword'>friend</span> <span class='keyword'>consteval</span> <span class='keyword'>bool</span> equivalent<span class='parenthesis'>(</span>Lhs lhs, Rhs rhs<span class='parenthesis'>)</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#L3101'>#</a></div><div class='texpara'><div id='2.sentence-1' class='sentence'><i >Effects</i>: Equivalent to:
<span class='codeblock'><span class='keyword'>const</span> <span class='keyword'>auto</span> lhs_canonical <span class='operator'>=</span> <i >get-canonical-unit</i><span class='parenthesis'>(</span>lhs<span class='parenthesis'>)</span>;
<span class='keyword'>const</span> <span class='keyword'>auto</span> rhs_canonical <span class='operator'>=</span> <i >get-canonical-unit</i><span class='parenthesis'>(</span>rhs<span class='parenthesis'>)</span>;
<span class='keyword'>return</span> lhs_canonical<span class='operator'>.</span>mag <span class='operator'>=</span><span class='operator'>=</span> rhs_canonical<span class='operator'>.</span>mag <span class='operator'>&amp;</span><span class='operator'>&amp;</span>
lhs_canonical<span class='operator'>.</span>reference_unit <span class='operator'>=</span><span class='operator'>=</span> rhs_canonical<span class='operator'>.</span>reference_unit;
</span></div></div></div></div><div class='texpara'><div id='lib:Unit,convertible'><div id='lib:convertible,Unit'><div class='itemdecl'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:convertible,Unit'>🔗</a></div><code class='itemdeclcode'><span class='keyword'>template</span><span class='anglebracket'>&lt;</span><a href='qty.unit.concepts.html#concept:Unit' title='5.4.4.4&emsp;Concepts&emsp;[qty.unit.concepts]'><span id='conceptref:Unit____'><span class='texttt'>Unit</span></span></a> From, <a href='qty.unit.concepts.html#concept:Unit' title='5.4.4.4&emsp;Concepts&emsp;[qty.unit.concepts]'><span id='conceptref:Unit_____'><span class='texttt'>Unit</span></span></a> To<span class='anglebracket'>&gt;</span>
<span class='keyword'>consteval</span> <span class='keyword'>bool</span> convertible<span class='parenthesis'>(</span>From from, To to<span class='parenthesis'>)</span>;
</code></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#L3119'>#</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>std<span class='operator'>::</span>is_same_v<span class='anglebracket'>&lt;</span>From, To<span class='anglebracket'>&gt;</span><span class='parenthesis'>)</span>
<span class='keyword'>return</span> <span class='literal'>true</span>;
<span class='keyword'>else</span> <span class='keyword'>if</span> <span class='keyword'>constexpr</span> <span class='parenthesis'>(</span><a class='index' id='conceptref:PotentiallyConvertibleTo'></a><i >PotentiallyConvertibleTo</i><span class='anglebracket'>&lt;</span>From, To<span class='anglebracket'>&gt;</span><span class='parenthesis'>)</span>
<span class='keyword'>return</span> std<span class='operator'>::</span>is_same_v<span class='anglebracket'>&lt;</span><span class='keyword'>decltype</span><span class='parenthesis'>(</span><i >get-canonical-unit</i><span class='parenthesis'>(</span>from<span class='parenthesis'>)</span><span class='operator'>.</span>reference_unit<span class='parenthesis'>)</span>,
<span class='keyword'>decltype</span><span class='parenthesis'>(</span><i >get-canonical-unit</i><span class='parenthesis'>(</span>to<span class='parenthesis'>)</span><span class='operator'>.</span>reference_unit<span class='parenthesis'>)</span><span class='anglebracket'>&gt;</span>;
<span class='keyword'>else</span>
<span class='keyword'>return</span> <span class='literal'>false</span>;
</span></div></div></div></div></div></body></html>