<!DOCTYPE html><htmllang='en'><head><title>[qty.cmp]</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.6</a> Quantity <aclass='abbr_ref'href='qty.html#cmp'>[qty]</a></h2><h3><aclass='secnum'style='min-width:80pt'>5.6.12</a> Comparison <aclass='abbr_ref'>[qty.cmp]</a></h3><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#L5153'>#</a></div><divclass='texpara'><divid='1.sentence-1'class='sentence'>In the following descriptions,
let <spanclass='texttt'>@</span> be the <spanclass='textsf'><i>operator</i></span><aclass='hidden_link'href='#1.sentence-1'>.</a></div></div></div><divclass='texpara'><divid='lib:quantity,operator<=>'><divid='lib:operator<=>,quantity'><divid='lib:quantity,operator=='><divid='lib:operator==,quantity'><divclass='itemdecl'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#lib:operator==,quantity'>🔗</a></div><codeclass='itemdeclcode'><spanclass='keyword'>template</span><spanclass='anglebracket'><</span>std<spanclass='operator'>::</span>derived_from<spanclass='anglebracket'><</span>quantity<spanclass='anglebracket'>></span> Q, <spanclass='keyword'>auto</span> R2, <spanclass='keyword'>typename</span> Rep2<spanclass='anglebracket'>></span>
</code></div></div></div></div></div></div><divclass='para'id='2'><divclass='marginalizedparent'><aclass='marginalized'href='#2'>2</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L5169'>#</a></div><divclass='texpara'><divid='2.sentence-1'class='sentence'>Let <i>C</i> be
<spanclass='texttt'>std<spanclass='operator'>​::​</span>equality_<spanclass='shy'></span>comparable</span> if <spanclass='texttt'>@</span> is <spanclass='texttt'><spanclass='operator'>=</span><spanclass='operator'>=</span></span>, and
<spanclass='texttt'>std<spanclass='operator'>​::​</span>three_<spanclass='shy'></span>way_<spanclass='shy'></span>comparable</span> if <spanclass='texttt'>@</span> is <spanclass='texttt'><spanclass='anglebracket'><</span><spanclass='operator'>=</span><spanclass='anglebracket'>></span></span><aclass='hidden_link'href='#2.sentence-1'>.</a></div></div></div></div><divclass='para'id='3'><divclass='marginalizedparent'><aclass='marginalized'href='#3'>3</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L5174'>#</a></div><divclass='texpara'><divid='3.sentence-1'class='sentence'><i>Effects</i>: Equivalent to:
</span></div></div></div></div><divclass='para'id='4'><divclass='marginalizedparent'><aclass='marginalized'href='#4'>4</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L5184'>#</a></div><divclass='texpara'><divid='4.sentence-1'class='sentence'><i>Remarks</i>: The expression in the <spanclass='textsf'><i>requires-clause</i></span> is equivalent to:
</span></div></div></div></div><divclass='texpara'><divid='lib:quantity,operator<=>_'><divid='lib:operator<=>,quantity_'><divid='lib:quantity,operator==_'><divid='lib:operator==,quantity_'><divclass='itemdecl'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#lib:operator==,quantity_'>🔗</a></div><codeclass='itemdeclcode'><spanclass='keyword'>template</span><spanclass='anglebracket'><</span>std<spanclass='operator'>::</span>derived_from<spanclass='anglebracket'><</span>quantity<spanclass='anglebracket'>></span> Q, <ahref='qty.rep.concepts.html#concept:Representation'title='5.5.4 Concepts [qty.rep.concepts]'><spanid='conceptref:Representation'><spanclass='texttt'>Representation</span></span></a> Value<spanclass='anglebracket'>></span>
<spanclass='keyword'>template</span><spanclass='anglebracket'><</span>std<spanclass='operator'>::</span>derived_from<spanclass='anglebracket'><</span>quantity<spanclass='anglebracket'>></span> Q, <ahref='qty.rep.concepts.html#concept:Representation'title='5.5.4 Concepts [qty.rep.concepts]'><spanid='conceptref:Representation_'><spanclass='texttt'>Representation</span></span></a> Value<spanclass='anglebracket'>></span>
</code></div></div></div></div></div></div><divclass='para'id='5'><divclass='marginalizedparent'><aclass='marginalized'href='#5'>5</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L5206'>#</a></div><divclass='texpara'><divid='5.sentence-1'class='sentence'>Let <i>C</i> be
<spanclass='texttt'>std<spanclass='operator'>​::​</span>equality_<spanclass='shy'></span>comparable_<spanclass='shy'></span>with</span> if <spanclass='texttt'>@</span> is <spanclass='texttt'><spanclass='operator'>=</span><spanclass='operator'>=</span></span>, and
<spanclass='texttt'>std<spanclass='operator'>​::​</span>three_<spanclass='shy'></span>way_<spanclass='shy'></span>comparable_<spanclass='shy'></span>with</span> if <spanclass='texttt'>@</span> is <spanclass='texttt'><spanclass='anglebracket'><</span><spanclass='operator'>=</span><spanclass='anglebracket'>></span></span><aclass='hidden_link'href='#5.sentence-1'>.</a></div></div></div></div><divclass='para'id='6'><divclass='marginalizedparent'><aclass='marginalized'href='#6'>6</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L5211'>#</a></div><divclass='texpara'><divid='6.sentence-1'class='sentence'><i>Returns</i>: <spanclass='texttt'>lhs<spanclass='operator'>.</span>numerical_<spanclass='shy'></span>value_<spanclass='shy'></span>ref_<spanclass='shy'></span>in<spanclass='parenthesis'>(</span>unit<spanclass='parenthesis'>)</span> @ rhs</span><aclass='hidden_link'href='#6.sentence-1'>.</a></div></div></div></div><divclass='para'id='7'><divclass='marginalizedparent'><aclass='marginalized'href='#7'>7</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-unitse9c5f7236ebfe1b287a5a4a49aaf57fbefa87233/source/quantities.tex#L5215'>#</a></div><divclass='texpara'><divid='7.sentence-1'class='sentence'><i>Remarks</i>: The expression in the <spanclass='textsf'><i>requires-clause</i></span> is equivalent to: