<!DOCTYPE html><htmllang='en'><head><title>[qty.like]</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#like'>[qty]</a></h2><h3><aclass='secnum'style='min-width:80pt'>5.6.2</a> Interoperability <aclass='abbr_ref'>[qty.like]</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-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L4070'>#</a></div><divclass='texpara'><divid='1.sentence-1'class='sentence'>The interfaces specified in this subclause and subclause <ahref='qty.pt.like.html'title='5.7.3 Interoperability'>[qty.<spanclass='shy'></span>pt.<spanclass='shy'></span>like]</a>
are used by <spanclass='texttt'>quantity</span> and <spanclass='texttt'>quantity_<spanclass='shy'></span>point</span>
to specify conversions with other types representing quantities<aclass='hidden_link'href='#1.sentence-1'>.</a></div><divid='note-1'class='note'><divclass='texpara'>[<i>Note <ahref='#note-1'>1</a></i>: <divid='1.sentence-2'class='sentence'><ahref='qty.chrono.html'title='5.9 std​::​chrono interoperability'>[qty.<spanclass='shy'></span>chrono]</a> implements them for <spanclass='texttt'>std<spanclass='operator'>​::​</span>chrono<spanclass='operator'>​::​</span>duration</span> and <spanclass='texttt'>std<spanclass='operator'>​::​</span>chrono<spanclass='operator'>​::​</span>time_<spanclass='shy'></span>point</span><aclass='hidden_link'href='#1.sentence-2'>.</a></div> — <i>end note</i>]</div></div></div></div><divclass='texpara'><divclass='itemdecl'id='itemdecl:1'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#itemdecl:1'>🔗</a></div><codeclass='itemdeclcode'><spanclass='keyword'>template</span><spanclass='anglebracket'><</span><spanclass='keyword'>typename</span> T, <spanclass='keyword'>template</span><spanclass='anglebracket'><</span><spanclass='keyword'>typename</span><spanclass='anglebracket'>></span><spanclass='keyword'>typename</span> Traits<spanclass='anglebracket'>></span>
</code></div></div><divclass='para'id='2'><divclass='marginalizedparent'><aclass='marginalized'href='#2'>2</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L4095'>#</a></div><divclass='texpara'><divid='2.sentence-1'class='sentence'>In the following descriptions, let
<ulclass='itemize'><liid='2.1'><divclass='marginalizedparent'style='left:-27mm'><aclass='marginalized'href='#2.1'>(2.1)</a></div><spanclass='texttt'>Traits</span> be <spanclass='texttt'>quantity_<spanclass='shy'></span>like_<spanclass='shy'></span>traits</span> or <spanclass='texttt'>quantity_<spanclass='shy'></span>point_<spanclass='shy'></span>like_<spanclass='shy'></span>traits</span>,</li><liid='2.2'><divclass='marginalizedparent'style='left:-27mm'><aclass='marginalized'href='#2.2'>(2.2)</a></div><spanclass='texttt'>Q</span> be a type for which <spanclass='texttt'>Traits<spanclass='anglebracket'><</span>Q<spanclass='anglebracket'>></span></span> is specialized,</li><liid='2.3'><divclass='marginalizedparent'style='left:-27mm'><aclass='marginalized'href='#2.3'>(2.3)</a></div><spanclass='texttt'>qty</span> be an lvalue of type <spanclass='texttt'><spanclass='keyword'>const</span> Q</span>, and</li><liid='2.4'><divclass='marginalizedparent'style='left:-27mm'><aclass='marginalized'href='#2.4'>(2.4)</a></div><spanclass='texttt'>num</span> be an lvalue of type <spanclass='texttt'><spanclass='keyword'>const</span> Traits<spanclass='anglebracket'><</span>Q<spanclass='anglebracket'>></span><spanclass='operator'>​::​</span>rep</span><aclass='hidden_link'href='#2.sentence-1'>.</a></li></ul></div></div></div><divclass='para'id='3'><divclass='marginalizedparent'><aclass='marginalized'href='#3'>3</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L4108'>#</a></div><divclass='texpara'><divid='3.sentence-1'class='sentence'><spanclass='texttt'>Q</span> models <spanclass='texttt'><aclass='index'id='conceptref:qty-like-impl_'></a><spanclass='texttt'><i>qty-like-impl</i></span><spanclass='anglebracket'><</span>Traits<spanclass='anglebracket'>></span></span> if and only if:
<ulclass='itemize'><liid='3.1'><divclass='marginalizedparent'style='left:-27mm'><aclass='marginalized'href='#3.1'>(3.1)</a></div><divclass='texpara'><divid='3.1.sentence-1'class='sentence'><spanclass='texttt'>Traits<spanclass='anglebracket'><</span>Q<spanclass='anglebracket'>></span><spanclass='operator'>​::​</span>to_<spanclass='shy'></span>numerical_<spanclass='shy'></span>value<spanclass='parenthesis'>(</span>qty<spanclass='parenthesis'>)</span></span> returns the numerical value (<ahref="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=112-01-29">IEC 60050, 112-01-29</a>) of <spanclass='texttt'>qty</span><aclass='hidden_link'href='#3.1.sentence-1'>.</a></div></div></li><liid='3.2'><divclass='marginalizedparent'style='left:-27mm'><aclass='marginalized'href='#3.2'>(3.2)</a></div><divclass='texpara'><divid='3.2.sentence-1'class='sentence'><spanclass='texttt'>Traits<spanclass='anglebracket'><</span>Q<spanclass='anglebracket'>></span><spanclass='operator'>​::​</span>from_<spanclass='shy'></span>numerical_<spanclass='shy'></span>value<spanclass='parenthesis'>(</span>num<spanclass='parenthesis'>)</span></span> returns a <spanclass='texttt'>Q</span> with numerical value <spanclass='texttt'>num</span><aclass='hidden_link'href='#3.2.sentence-1'>.</a></div></div></li><liid='3.3'><divclass='marginalizedparent'style='left:-27mm'><aclass='marginalized'href='#3.3'>(3.3)</a></div><divclass='texpara'><divid='3.3.sentence-1'class='sentence'>If <spanclass='texttt'>Traits</span> is <spanclass='texttt'>quantity_<spanclass='shy'></span>point_<spanclass='shy'></span>like_<spanclass='shy'></span>traits</span>,
both numerical values are offset from <spanclass='texttt'>Traits<spanclass='anglebracket'><</span>Q<spanclass='anglebracket'>></span><spanclass='operator'>​::​</span>point_<spanclass='shy'></span>origin</span><aclass='hidden_link'href='#3.3.sentence-1'>.</a></div></div></li></ul></div></div></div><divclass='para'id='4'><divclass='marginalizedparent'><aclass='marginalized'href='#4'>4</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L4120'>#</a></div><divclass='texpara'><divid='4.sentence-1'class='sentence'>If the following expression is <spanclass='texttt'><spanclass='literal'>true</span></span>, the specified conversion will be explicit<aclass='hidden_link'href='#4.sentence-1'>.</a></div><ulclass='itemize'><liid='4.1'><divclass='marginalizedparent'style='left:-27mm'><aclass='marginalized'href='#4.1'>(4.1)</a></div><divclass='texpara'><divid='4.1.sentence-1'class='sentence'><spanclass='texttt'>Traits<spanclass='anglebracket'><</span>Q<spanclass='anglebracket'>></span><spanclass='operator'>​::​</span>explicit_<spanclass='shy'></span>import</span> for the conversion from <spanclass='texttt'>Q</span> to this library's type<aclass='hidden_link'href='#4.1.sentence-1'>.</a></div></div></li><liid='4.2'><divclass='marginalizedparent'style='left:-27mm'><aclass='marginalized'href='#4.2'>(4.2)</a></div><divclass='texpara'><divid='4.2.sentence-1'class='sentence'><spanclass='texttt'>Traits<spanclass='anglebracket'><</span>Q<spanclass='anglebracket'>></span><spanclass='operator'>​::​</span>explicit_<spanclass='shy'></span>export</span> for the conversion from this library's type to <spanclass='texttt'>Q</span><aclass='hidden_link'href='#4.2.sentence-1'>.</a></div></div></li></ul></div></div></div></body></html>