<!DOCTYPE html><htmllang='en'><head><title>[qty.rep.traits]</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.5</a> Representation <aclass='abbr_ref'href='qty.rep.html#traits'>[qty.rep]</a></h2><h3><aclass='secnum'style='min-width:80pt'>5.5.2</a> Traits <aclass='abbr_ref'>[qty.rep.traits]</a></h3><divid='qty.fp.traits'class='section'><h4><aclass='secnum'href='#qty.fp.traits'style='min-width:95pt'>5.5.2.1</a> Floating-point <aclass='abbr_ref'href='qty.fp.traits.html'>[qty.fp.traits]</a></h4><divclass='texpara'><divclass='itemdecl'id='qty.fp.traits-itemdecl:1'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#qty.fp.traits-itemdecl:1'>🔗</a></div><codeclass='itemdeclcode'><spanclass='keyword'>template</span><spanclass='anglebracket'><</span><spanclass='keyword'>typename</span> T<spanclass='anglebracket'>></span>
<spanclass='keyword'>struct</span><spanclass='texttt'><i>actual-value-type</i></span><spanclass='operator'>:</span><spanclass='texttt'><i>cond-value-type</i></span><spanclass='anglebracket'><</span>T<spanclass='anglebracket'>></span><spanclass='curlybracket'>{</span><spanclass='curlybracket'>}</span>; <spanclass='comment'>// see <ahref="https://wg21.link/readable.traits">N4971, [readable.traits]</a></span>
</code></div></div><divclass='para'id='qty.fp.traits-1'><divclass='marginalizedparent'><aclass='marginalized'href='#qty.fp.traits-1'>1</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L3708'>#</a></div><divclass='texpara'><divid='qty.fp.traits-1.sentence-1'class='sentence'><spanclass='texttt'>quantity</span> and <spanclass='texttt'>quantity_<spanclass='shy'></span>point</span> use <spanclass='texttt'>treat_<spanclass='shy'></span>as_<spanclass='shy'></span>floating_<spanclass='shy'></span>point</span>
to help determine whether implicit conversions are allowed among them<aclass='hidden_link'href='#qty.fp.traits-1.sentence-1'>.</a></div></div></div></div><divclass='para'id='qty.fp.traits-2'><divclass='marginalizedparent'><aclass='marginalized'href='#qty.fp.traits-2'>2</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L3712'>#</a></div><divclass='texpara'><divid='qty.fp.traits-2.sentence-1'class='sentence'><i>Remarks</i>: Pursuant to <ahref="https://wg21.link/namespace.std">N4971, [namespace.std]</a> (<ahref='spec.ext.html'title='4.1 External'>[spec.<spanclass='shy'></span>ext]</a>),
users may specialize <spanclass='texttt'>treat_<spanclass='shy'></span>as_<spanclass='shy'></span>floating_<spanclass='shy'></span>point</span>
for cv-unqualified program-defined types<aclass='hidden_link'href='#qty.fp.traits-2.sentence-1'>.</a></div><divid='qty.fp.traits-2.sentence-2'class='sentence'>Such specializations shall be usable in constant expressions (<ahref="https://wg21.link/expr.const">N4971, [expr.const]</a>)
and have type <spanclass='texttt'><spanclass='keyword'>const</span><spanclass='keyword'>bool</span></span><aclass='hidden_link'href='#qty.fp.traits-2.sentence-2'>.</a></div></div></div></div></div><divid='qty.char.traits'class='section'><h4><aclass='secnum'href='#qty.char.traits'style='min-width:95pt'>5.5.2.2</a> Quantity character <aclass='abbr_ref'href='qty.char.traits.html'>[qty.char.traits]</a></h4><divclass='texpara'><divid='lib:disable_vector'><divid='lib:disable_complex'><divid='lib:disable_scalar'><divclass='itemdecl'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#lib:disable_scalar'>🔗</a></div><codeclass='itemdeclcode'><spanclass='keyword'>template</span><spanclass='anglebracket'><</span><spanclass='keyword'>typename</span> T<spanclass='anglebracket'>></span>
</code></div></div></div></div></div><divclass='para'id='qty.char.traits-1'><divclass='marginalizedparent'><aclass='marginalized'href='#qty.char.traits-1'>1</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L3736'>#</a></div><divclass='texpara'><divid='qty.char.traits-1.sentence-1'class='sentence'>Some quantities are defined as having a numerical value (<ahref="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=112-01-29">IEC 60050, 112-01-29</a>) of a specific set (<ahref="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=102-01-02">IEC 60050, 102-01-02</a>)<aclass='hidden_link'href='#qty.char.traits-1.sentence-1'>.</a></div><divid='qty.char.traits-1.sentence-2'class='sentence'>The representation concepts use these traits
to help determine the sets <spanclass='texttt'>T</span> represents<aclass='hidden_link'href='#qty.char.traits-1.sentence-2'>.</a></div></div></div></div><divclass='para'id='qty.char.traits-2'><divclass='marginalizedparent'><aclass='marginalized'href='#qty.char.traits-2'>2</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L3741'>#</a></div><divclass='texpara'><divid='qty.char.traits-2.sentence-1'class='sentence'><i>Remarks</i>: Pursuant to <ahref="https://wg21.link/namespace.std">N4971, [namespace.std]</a> (<ahref='spec.ext.html'title='4.1 External'>[spec.<spanclass='shy'></span>ext]</a>),
for cv-unqualified program-defined types<aclass='hidden_link'href='#qty.char.traits-2.sentence-1'>.</a></div><divid='qty.char.traits-2.sentence-2'class='sentence'>Such specializations shall be usable in constant expressions (<ahref="https://wg21.link/expr.const">N4971, [expr.const]</a>)
and have type <spanclass='texttt'><spanclass='keyword'>const</span><spanclass='keyword'>bool</span></span><aclass='hidden_link'href='#qty.char.traits-2.sentence-2'>.</a></div></div></div></div><divclass='para nonNormativeOnly'id='qty.char.traits-3'><divclass='marginalizedparent'><aclass='marginalized'href='#qty.char.traits-3'>3</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L3749'>#</a></div><divclass='texpara'><divid='qty.char.traits-note-1'class='note'><divclass='texpara'>[<i>Note <ahref='#qty.char.traits-note-1'>1</a></i>: <divid='qty.char.traits-3.sentence-1'class='sentence'>These templates prevent use of representation types with the library
that satisfy but do not in fact model their corresponding concept<aclass='hidden_link'href='#qty.char.traits-3.sentence-1'>.</a></div> — <i>end note</i>]</div></div></div></div></div></div><divid='qty.val.traits'class='section'><h4><aclass='secnum'href='#qty.val.traits'style='min-width:95pt'>5.5.2.3</a> Values <aclass='abbr_ref'href='qty.val.traits.html'>[qty.val.traits]</a></h4><divclass='para'id='qty.val.traits-1'><divclass='marginalizedparent'><aclass='marginalized'href='#qty.val.traits-1'>1</a></div><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L3758'>#</a></div><divclass='texpara'><divid='qty.val.traits-1.sentence-1'class='sentence'><spanclass='texttt'>quantity</span> and <spanclass='texttt'>quantity_<spanclass='shy'></span>point</span> use <spanclass='texttt'>representation_<spanclass='shy'></span>values</span>
to construct special values of its representation type<aclass='hidden_link'href='#qty.val.traits-1.sentence-1'>.</a></div></div><divclass='texpara'><spanclass='codeblock'><spanclass='keyword'>namespace</span> mp_units <spanclass='curlybracket'>{</span>
also apply to <spanclass='texttt'>representation_<spanclass='shy'></span>values<spanclass='anglebracket'><</span>Rep<spanclass='anglebracket'>></span></span><aclass='hidden_link'href='#qty.val.traits-2.sentence-1'>.</a></div></div></div><divclass='texpara'><divclass='itemdecl'id='qty.val.traits-itemdecl:1'><divclass='marginalizedparent'><aclass='itemDeclLink'href='#qty.val.traits-itemdecl:1'>🔗</a></div><codeclass='itemdeclcode'><spanclass='keyword'>static</span><spanclass='keyword'>constexpr</span> Rep one<spanclass='parenthesis'>(</span><spanclass='parenthesis'>)</span><spanclass='keyword'>noexcept</span>;
</code></div></div><divclass='para'id='qty.val.traits-3'><divclass='marginalizedparent'><aclass='marginalized'href='#qty.val.traits-3'>3</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L3782'>#</a></div><divclass='texpara'><divid='qty.val.traits-3.sentence-1'class='sentence'><i>Returns</i>: <spanclass='texttt'>Rep<spanclass='parenthesis'>(</span><spanclass='literal'>1</span><spanclass='parenthesis'>)</span></span><aclass='hidden_link'href='#qty.val.traits-3.sentence-1'>.</a></div></div></div></div><divclass='para'id='qty.val.traits-4'><divclass='marginalizedparent'><aclass='marginalized'href='#qty.val.traits-4'>4</a></div><divclass='itemdescr'><divclass='sourceLinkParent'><aclass='sourceLink'href='https://github.com/mpusz/mp-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L3786'>#</a></div><divclass='texpara'><divid='qty.val.traits-4.sentence-1'class='sentence'><i>Remarks</i>: The value returned shall be the neutral element for multiplication (<ahref="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=102-01-19">IEC 60050, 102-01-19</a>)<aclass='hidden_link'href='#qty.val.traits-4.sentence-1'>.</a></div></div></div></div></div></div></body></html>