forked from mpusz/mp-units
22 lines
5.5 KiB
HTML
22 lines
5.5 KiB
HTML
<!DOCTYPE html><html lang='en'><head><title>[qty.derived.unit]</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.derived.unit'>[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#qty.derived.unit'>[qty.unit]</a></h3><h4 ><a class='secnum' style='min-width:95pt'>5.4.4.5</a> Types <a class='abbr_ref' href='qty.unit.types.html#qty.derived.unit'>[qty.unit.types]</a></h4><h4 ><a class='secnum' style='min-width:110pt'>5.4.4.5.6</a> Derived <a class='abbr_ref'>[qty.derived.unit]</a></h4><div class='texpara'><span id='lib:derived_unit'><div class='marginalizedparent'><a class='itemDeclLink' href='#lib:derived_unit'>🔗</a></div><span class='codeblock'><span class='keyword'>namespace</span> mp_units <span class='curlybracket'>{</span>
|
|
|
|
<span class='keyword'>template</span><span class='anglebracket'><</span><span class='keyword'>typename</span><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span> Expr<span class='anglebracket'>></span>
|
|
<span class='keyword'>struct</span> <i >derived-unit-impl</i> <span class='operator'>:</span> <span class='comment'>// <i >exposition only</i></span>
|
|
<i >unit-interface</i>,
|
|
<i >expr-fractions</i><span class='anglebracket'><</span><span class='keyword'>struct</span> one, Expr<span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span><span class='anglebracket'>></span> <span class='curlybracket'>{</span>
|
|
<span class='keyword'>using</span> <i >base-type</i> <span class='operator'>=</span> <i >derived-unit-impl</i>; <span class='comment'>// <i >exposition only</i></span>
|
|
<span class='curlybracket'>}</span>;
|
|
|
|
<span class='keyword'>template</span><span class='anglebracket'><</span><a class='index' id='conceptref:SymbolicConstant'></a><i >SymbolicConstant</i><span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span> Expr<span class='anglebracket'>></span>
|
|
<span class='keyword'>struct</span> derived_unit <span class='keyword'>final</span> <span class='operator'>:</span> <i >derived-unit-impl</i><span class='anglebracket'><</span>Expr<span class='operator'>.</span><span class='operator'>.</span><span class='operator'>.</span><span class='anglebracket'>></span> <span class='curlybracket'>{</span><span class='curlybracket'>}</span>;
|
|
|
|
<span class='curlybracket'>}</span>
|
|
</span></span></div><div class='para' id='1'><div class='marginalizedparent'><a class='marginalized' href='#1'>1</a></div><div class='sourceLinkParent'><a class='sourceLink' href='https://github.com/mpusz/mp-units329ffdaacb1bd7bed08565ac80d9eef7ccb1e5b5/source/quantities.tex#L2879'>#</a></div><div class='texpara'><div id='1.sentence-1' class='sentence'><span class='texttt'>derived_<span class='shy'></span>unit</span> is used by the library
|
|
to represent a derived unit (<a href="https://www.electropedia.org/iev/iev.nsf/display?openform&ievref=112-01-19">IEC 60050, 112-01-19</a>)<a class='hidden_link' href='#1.sentence-1'>.</a></div> <div id='example-1' class='example'><div class='texpara'>[<i>Example <a href='#example-1'>1</a></i>: <span class='codeblock'><span class='keyword'>using</span> <span class='keyword'>namespace</span> si<span class='operator'>::</span>unit_symbols;
|
|
<span class='keyword'>int</span> x <span class='operator'>=</span> m <span class='operator'>*</span> m; <span class='comment'>// error: cannot construct from <span class='tcode_in_codeblock'>derived_<span class='shy'></span>unit<power<si​::​metre, 2>></span></span>
|
|
<span class='keyword'>int</span> y <span class='operator'>=</span> m <span class='operator'>*</span> s; <span class='comment'>// error: cannot construct from <span class='tcode_in_codeblock'>derived_<span class='shy'></span>unit<si​::​metre, si​::​second></span></span>
|
|
<span class='keyword'>int</span> z <span class='operator'>=</span> m <span class='operator'>/</span> s; <span class='comment'>// error: cannot construct from <span class='tcode_in_codeblock'>derived_<span class='shy'></span>unit<si​::​metre, per<si​::​second>></span></span>
|
|
</span> — <i>end example</i>]</div></div> <div id='1.sentence-2' class='sentence'>
|
|
A program that instantiates a specialization of <span class='texttt'>derived_<span class='shy'></span>unit</span>
|
|
that is not a possible result of the library specifications
|
|
is ill-formed, no diagnostic required<a class='hidden_link' href='#1.sentence-2'>.</a></div></div></div></div></body></html> |