Deployed 1d9a7c28 to HEAD with MkDocs 1.6.1 and mike 2.1.3

This commit is contained in:
github-actions committed 2025-06-17 14:21:09 +00:00
1 parent 4e9c622982
commit 86d0af388e
9 files changed
+99 -47

No files matched your search

@@ -2399,7 +2399,7 @@ You're not viewing the latest version.
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 20a8 8 0 0 0 8-8 8 8 0 0 0-8-8 8 8 0 0 0-8 8 8 8 0 0 0 8 8m0-18a10 10 0 0 1 10 10 10 10 0 0 1-10 10C6.47 22 2 17.5 2 12A10 10 0 0 1 12 2m.5 5v5.25l4.5 2.67-.75 1.23L11 13V7z"/></svg>
<span class="md-ellipsis">
7 min read
8 min read
</span>
</div>
@@ -2489,6 +2489,15 @@ You're not viewing the latest version.
</span>
</a>
</li>
<li class="md-nav__item">
<a href="#motivating-example" class="md-nav__link">
<span class="md-ellipsis">
Motivating example
</span>
</a>
</li>
</ul>
@@ -2614,7 +2623,7 @@ in many equations in source code where it would be a good fit otherwise.</p>
(e.g., temperatures in degrees Celsius, tared mass measurements, altitudes above some
reference point, etc.) and do it really well. Constrained affine space arithmetic
(e.g., preventing accidental addition of points) also improves the safety of our programs.
This is why it is a very valuable abstraction and should be used even more often than now.</p>
This is why it is a valuable abstraction and should be used more even often than now.</p>
<p>To improve the user experience and open the doors for new features in the future, we are
considering adding a third abstraction for absolute quantities. In terms of properties,
an absolute quantity will lie between points and deltas.</p>
@@ -2661,7 +2670,7 @@ an absolute quantity will lie between points and deltas.</p>
<tr>
<td><strong>Relative to origin</strong></td>
<td style="text-align: center;">Absolute &amp; relative</td>
<td style="text-align: center;">Absolute (implicit only)</td>
<td style="text-align: center;">Measured against nothing/void</td>
<td style="text-align: center;"><span class="twemoji"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 6.91 17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12z"/></svg></span></td>
</tr>
<tr>
@@ -2687,23 +2696,22 @@ an absolute quantity will lie between points and deltas.</p>
<p>As we can see above, absolute quantities have only two limitations, and both are connected
to the offset units' usage. They can't use those because they must remain absolute
instead of being measured relative to some custom origin.</p>
<p>It is also vital to notice that there will be no way to provide a custom origin for
absolute quantities, even if it is defined in terms of <code>absolute_point_origin</code>. Those
quantities are meant to model abstractions with well-established and unambiguous zero
origins. If we allow passing absolute point origins, we could define two quantities
of the same type measured according to different not-related origins, which would be
too confusing.</p>
<p>The above also allows us to print them, as we do not need any special text to describe
their origin.</p>
<p>Absolute quantities could be considered delta quantities that represent a whole
-- the entire entity being measured. This is why we can represent a system mass by adding
absolute masses of all system elements or a system energy by adding absolute
temperatures of all the system elements.</p>
<p>As those are more related to deltas than points, it is impossible to specify their origin
points. This also allows us to print them, as we do not need any special text to describe
their origin as they are always measured against nothing/void.</p>
<h2 id="interfaces-refactoring">Interfaces refactoring<a class="headerlink" href="#interfaces-refactoring" title="Permanent link">&para;</a></h2>
<p>As I mentioned in my <a href="../../../01/15/bringing-quantity-safety-to-the-next-level/#should-we-get-rid-of-a-quantity_point">previous post</a>,
we are seriously considering removing <code>quantity_point</code> class template and replacing it with
a <code>quantity_spec</code> point wrapper. For example, <code>quantity_point&lt;isq::altitude[m]&gt;</code> will become
<code>quantity&lt;point&lt;isq::altitude[m]&gt;&gt;</code>.</p>
<p>I initially planned <code>quantity&lt;isq::mass&gt;</code> to be the same as <code>quantity&lt;delta&lt;isq::mass&gt;&gt;</code>,
but it turns out that deltas probably should not be the default. It is consistent with how we
write physical expressions on paper, right? Delta symbol (∆) is always "verbose"
in our equations, it would be nice for the C++ code to do the same. So, deltas will always
but it turns out that deltas probably should not be the default. It is consistent with how
we write physical expressions on paper, right? Delta symbol (∆) is always "verbose"
in physical equations, it would be nice for the C++ code to do the same. So, deltas will always
need to be explicit.</p>
<p>And this brings us to absolute quantities. They should actually be the default we are looking
for. This is what we write as quantities in most of the physical equations. This is why we
@@ -2732,16 +2740,15 @@ will not need any specifier to denote them.</p>
<p>Affine space arithmetic is well-defined. However, we are adding a new type to the library
that lands between points and deltas. This is why we must agree on the arithmetic for all
possible combinations.</p>
<p>Let's try to define them here, assuming that points and absolute values share
a common origin.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>If points and absolute values do not share a common absolute point origin
the operation should fail to compile.</p>
</div>
<h3 id="addition">Addition<a class="headerlink" href="#addition" title="Permanent link">&para;</a></h3>
<p>In case of addition, a more constrained type is preserved (except for adding two points,
which is undefined):</p>
<p>Absolute quantities are deltas against nothing so adding them to a point yields another point.</p>
<p>Adding a delta to them yields a delta, as a delta may represent only a part of something and
a whole, and a part is not a whole. The delta may also be negative and greater
than the absolute quantity, which may yield a negative value. This is why delta is a good
result here.</p>
<p>Only adding whole non-negative entities of the system yields a system being expressed as
an entire non-negative entity. This is why adding absolute quantities results in an absolute
quantity.</p>
<table>
<thead>
<tr>
@@ -2762,20 +2769,23 @@ which is undefined):</p>
<td><strong>Absolute</strong></td>
<td style="text-align: center;">Point</td>
<td style="text-align: center;">Absolute</td>
<td style="text-align: center;">Absolute</td>
<td style="text-align: center;">Delta</td>
</tr>
<tr>
<td><strong>Delta</strong></td>
<td style="text-align: center;">Point</td>
<td style="text-align: center;">Absolute</td>
<td style="text-align: center;">Delta</td>
<td style="text-align: center;">Delta</td>
</tr>
</tbody>
</table>
<h3 id="subtraction">Subtraction<a class="headerlink" href="#subtraction" title="Permanent link">&para;</a></h3>
<p>Subtraction is more tricky. To verify the logic below, it might be helpful to ask whether
a result may be negative when two arguments are non-negative. If the answer is true,
the result should be a delta quantity.</p>
<p>Similarly, during subtraction, regular affine space arithmetics for deltas apply.
Subtracting an absolute quantity from a point yields a point, and trying to do the opposite
does not make physical sense.</p>
<p>Subtracting two non-negative absolute quantities may yield a negative value if we subtract
a larger one from the smaller one, so the result should be a delta. A similar result
may be obtained by subtracting a delta from absolute quantity or absolute quantity from a delta.</p>
<table>
<thead>
<tr>
@@ -2794,9 +2804,9 @@ the result should be a delta quantity.</p>
</tr>
<tr>
<td><strong>Absolute</strong></td>
<td style="text-align: center;"><span class="twemoji"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M20 6.91 17.09 4 12 9.09 6.91 4 4 6.91 9.09 12 4 17.09 6.91 20 12 14.91 17.09 20 20 17.09 14.91 12z"/></svg></span></td>
<td style="text-align: center;">Delta</td>
<td style="text-align: center;">Delta</td>
<td style="text-align: center;">Absolute</td>
</tr>
<tr>
<td><strong>Delta</strong></td>
@@ -2806,29 +2816,71 @@ the result should be a delta quantity.</p>
</tr>
</tbody>
</table>
<div class="admonition info">
<p class="admonition-title">Info</p>
<p>Based on the above assumptions, one of the lines of the below code can't compile:</p>
<div class="language-cpp highlight"><pre><span></span><code><span id="__span-3-1"><a id="__codelineno-3-1" name="__codelineno-3-1" href="#__codelineno-3-1"></a><span class="n">quantity</span><span class="w"> </span><span class="n">temp1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">270</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">K</span><span class="p">;</span>
</span><span id="__span-3-2"><a id="__codelineno-3-2" name="__codelineno-3-2" href="#__codelineno-3-2"></a><span class="n">quantity</span><span class="w"> </span><span class="n">temp2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">point</span><span class="o">&lt;</span><span class="n">K</span><span class="o">&gt;</span><span class="p">(</span><span class="mi">300</span><span class="p">);</span><span class="w"> </span>
</span><span id="__span-3-3"><a id="__codelineno-3-3" name="__codelineno-3-3" href="#__codelineno-3-3"></a><span class="n">quantity</span><span class="w"> </span><span class="n">temp3</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">temp2</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">temp1</span><span class="p">;</span><span class="w"> </span><span class="c1">// Point</span>
</span><span id="__span-3-4"><a id="__codelineno-3-4" name="__codelineno-3-4" href="#__codelineno-3-4"></a><span class="c1">// quantity temp4 = temp1 - temp2; // Compile-time error</span>
</span><span id="__span-3-5"><a id="__codelineno-3-5" name="__codelineno-3-5" href="#__codelineno-3-5"></a><span class="n">quantity</span><span class="w"> </span><span class="n">temp5</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">temp1</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">temp2</span><span class="p">.</span><span class="n">absolute</span><span class="p">();</span><span class="w"> </span><span class="c1">// Delta</span>
</span></code></pre></div>
</div>
<h3 id="motivating-example">Motivating example<a class="headerlink" href="#motivating-example" title="Permanent link">&para;</a></h3>
<p>Let's consider a room with a table and two glasses filled with fluid on top of it.
Let's also assume that we want to stack one on top of the other and treat them as a system
we observe.</p>
<p><img alt="Absolute quantities" src="../../../../absolute-quantities.jpeg" width="500" /></p>
<div class="language-cpp highlight"><pre><span></span><code><span id="__span-4-1"><a id="__codelineno-4-1" name="__codelineno-4-1" href="#__codelineno-4-1"></a><span class="c1">// absolute quantities</span>
</span><span id="__span-4-2"><a id="__codelineno-4-2" name="__codelineno-4-2" href="#__codelineno-4-2"></a><span class="n">quantity</span><span class="o">&lt;</span><span class="n">isq</span><span class="o">::</span><span class="n">height</span><span class="p">[</span><span class="n">cm</span><span class="p">]</span><span class="o">&gt;</span><span class="w"> </span><span class="n">glass1_height</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">20</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">cm</span><span class="p">;</span>
</span><span id="__span-4-3"><a id="__codelineno-4-3" name="__codelineno-4-3" href="#__codelineno-4-3"></a><span class="n">quantity</span><span class="o">&lt;</span><span class="n">isq</span><span class="o">::</span><span class="n">height</span><span class="p">[</span><span class="n">cm</span><span class="p">]</span><span class="o">&gt;</span><span class="w"> </span><span class="n">glass2_height</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">15</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">cm</span><span class="p">;</span>
</span><span id="__span-4-4"><a id="__codelineno-4-4" name="__codelineno-4-4" href="#__codelineno-4-4"></a>
</span><span id="__span-4-5"><a id="__codelineno-4-5" name="__codelineno-4-5" href="#__codelineno-4-5"></a><span class="c1">// delta quantities</span>
</span><span id="__span-4-6"><a id="__codelineno-4-6" name="__codelineno-4-6" href="#__codelineno-4-6"></a><span class="n">quantity</span><span class="o">&lt;</span><span class="n">delta</span><span class="o">&lt;</span><span class="n">isq</span><span class="o">::</span><span class="n">height</span><span class="o">&gt;</span><span class="p">[</span><span class="n">cm</span><span class="p">]</span><span class="o">&gt;</span><span class="w"> </span><span class="n">fluid_level</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">16</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">cm</span><span class="p">;</span>
</span><span id="__span-4-7"><a id="__codelineno-4-7" name="__codelineno-4-7" href="#__codelineno-4-7"></a>
</span><span id="__span-4-8"><a id="__codelineno-4-8" name="__codelineno-4-8" href="#__codelineno-4-8"></a><span class="c1">// point quantities</span>
</span><span id="__span-4-9"><a id="__codelineno-4-9" name="__codelineno-4-9" href="#__codelineno-4-9"></a><span class="kr">inline</span><span class="w"> </span><span class="k">constexpr</span><span class="w"> </span><span class="k">struct</span><span class="w"> </span><span class="nc">floor_level</span><span class="w"> </span><span class="k">final</span><span class="w"> </span><span class="o">:</span><span class="w"> </span><span class="n">absolute_point_origin</span><span class="o">&lt;</span><span class="n">isq</span><span class="o">::</span><span class="n">height</span><span class="o">&gt;</span><span class="w"> </span><span class="n">floor_level</span><span class="p">;</span>
</span><span id="__span-4-10"><a id="__codelineno-4-10" name="__codelineno-4-10" href="#__codelineno-4-10"></a><span class="n">quantity</span><span class="o">&lt;</span><span class="n">point</span><span class="o">&lt;</span><span class="n">isq</span><span class="o">::</span><span class="n">height</span><span class="p">[</span><span class="n">cm</span><span class="p">],</span><span class="w"> </span><span class="n">floor_level</span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="n">table_top</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">floor_level</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">m</span><span class="p">;</span>
</span><span id="__span-4-11"><a id="__codelineno-4-11" name="__codelineno-4-11" href="#__codelineno-4-11"></a><span class="c1">// quantity&lt;point&lt;isq::height[cm]&gt;&gt; glass1_top(glass1_height); // point against nothing (no length)</span>
</span><span id="__span-4-12"><a id="__codelineno-4-12" name="__codelineno-4-12" href="#__codelineno-4-12"></a>
</span><span id="__span-4-13"><a id="__codelineno-4-13" name="__codelineno-4-13" href="#__codelineno-4-13"></a><span class="c1">// absolute results</span>
</span><span id="__span-4-14"><a id="__codelineno-4-14" name="__codelineno-4-14" href="#__codelineno-4-14"></a><span class="n">quantity</span><span class="w"> </span><span class="n">system_height</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">glass1_height</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">glass2_height</span><span class="p">;</span>
</span><span id="__span-4-15"><a id="__codelineno-4-15" name="__codelineno-4-15" href="#__codelineno-4-15"></a>
</span><span id="__span-4-16"><a id="__codelineno-4-16" name="__codelineno-4-16" href="#__codelineno-4-16"></a><span class="c1">// delta results</span>
</span><span id="__span-4-17"><a id="__codelineno-4-17" name="__codelineno-4-17" href="#__codelineno-4-17"></a><span class="n">quantity</span><span class="w"> </span><span class="n">empty_height_res</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">glass1_height</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">fluid_level</span><span class="p">;</span>
</span><span id="__span-4-18"><a id="__codelineno-4-18" name="__codelineno-4-18" href="#__codelineno-4-18"></a><span class="n">quantity</span><span class="w"> </span><span class="n">glass2_height_res</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">system_height</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">glass1_height</span><span class="p">;</span><span class="w"> </span><span class="c1">// could result in an absolute quantity</span>
</span><span id="__span-4-19"><a id="__codelineno-4-19" name="__codelineno-4-19" href="#__codelineno-4-19"></a><span class="n">assert</span><span class="p">(</span><span class="n">glass2_height_res</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">glass2_height</span><span class="p">);</span>
</span><span id="__span-4-20"><a id="__codelineno-4-20" name="__codelineno-4-20" href="#__codelineno-4-20"></a><span class="n">quantity</span><span class="w"> </span><span class="n">height_diff_res</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">glass2_height</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">glass1_height</span><span class="p">;</span><span class="w"> </span><span class="c1">// but this one should definitely return delta</span>
</span><span id="__span-4-21"><a id="__codelineno-4-21" name="__codelineno-4-21" href="#__codelineno-4-21"></a>
</span><span id="__span-4-22"><a id="__codelineno-4-22" name="__codelineno-4-22" href="#__codelineno-4-22"></a><span class="c1">// point results</span>
</span><span id="__span-4-23"><a id="__codelineno-4-23" name="__codelineno-4-23" href="#__codelineno-4-23"></a><span class="n">quantity</span><span class="o">&lt;</span><span class="n">point</span><span class="o">&lt;</span><span class="n">isq</span><span class="o">::</span><span class="n">height</span><span class="p">[</span><span class="n">cm</span><span class="p">],</span><span class="w"> </span><span class="n">floor_level</span><span class="o">&gt;&gt;</span><span class="w"> </span><span class="n">glass1_top</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">table_top</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">glass1_height</span><span class="p">;</span>
</span><span id="__span-4-24"><a id="__codelineno-4-24" name="__codelineno-4-24" href="#__codelineno-4-24"></a><span class="n">quantity</span><span class="w"> </span><span class="n">point1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">glass1_top</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">glass1_height</span><span class="p">;</span>
</span><span id="__span-4-25"><a id="__codelineno-4-25" name="__codelineno-4-25" href="#__codelineno-4-25"></a><span class="n">assert</span><span class="p">(</span><span class="n">point1</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">table_top</span><span class="p">);</span>
</span><span id="__span-4-26"><a id="__codelineno-4-26" name="__codelineno-4-26" href="#__codelineno-4-26"></a><span class="c1">// quantity point2 = glass1_height - glass1_top;      // no sense - does not compile</span>
</span></code></pre></div>
<h2 id="new-opportunities">New opportunities<a class="headerlink" href="#new-opportunities" title="Permanent link">&para;</a></h2>
<p>The new syntax simplifies API as one <code>quantity</code> class template will now serve all quantity
variations (possibly even more in the future). It also allows us to model quantities that
were impossible to express before without some workarounds.</p>
<p>For example, we can now correctly calculate Carnot engine efficiency with any of the following:</p>
<div class="language-cpp highlight"><pre><span></span><code><span id="__span-3-1"><a id="__codelineno-3-1" name="__codelineno-3-1" href="#__codelineno-3-1"></a><span class="n">quantity</span><span class="w"> </span><span class="n">temp_cold</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">300.</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">K</span><span class="p">;</span>
</span><span id="__span-3-2"><a id="__codelineno-3-2" name="__codelineno-3-2" href="#__codelineno-3-2"></a><span class="n">quantity</span><span class="w"> </span><span class="n">temp_hot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">500.</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">K</span><span class="p">;</span>
</span><span id="__span-3-3"><a id="__codelineno-3-3" name="__codelineno-3-3" href="#__codelineno-3-3"></a><span class="n">quantity</span><span class="w"> </span><span class="n">carnot_eff_1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">1.</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">temp_cold</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="n">temp_hot</span><span class="p">;</span>
</span><span id="__span-3-4"><a id="__codelineno-3-4" name="__codelineno-3-4" href="#__codelineno-3-4"></a><span class="n">quantity</span><span class="w"> </span><span class="n">carnot_eff_2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">temp_hot</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">temp_cold</span><span class="p">)</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="n">temp_hot</span><span class="p">;</span>
<div class="language-cpp highlight"><pre><span></span><code><span id="__span-5-1"><a id="__codelineno-5-1" name="__codelineno-5-1" href="#__codelineno-5-1"></a><span class="n">quantity</span><span class="w"> </span><span class="n">temp_cold</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">300.</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">K</span><span class="p">;</span>
</span><span id="__span-5-2"><a id="__codelineno-5-2" name="__codelineno-5-2" href="#__codelineno-5-2"></a><span class="n">quantity</span><span class="w"> </span><span class="n">temp_hot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">500.</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="n">K</span><span class="p">;</span>
</span><span id="__span-5-3"><a id="__codelineno-5-3" name="__codelineno-5-3" href="#__codelineno-5-3"></a><span class="n">quantity</span><span class="w"> </span><span class="n">carnot_eff_1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">1.</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">temp_cold</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="n">temp_hot</span><span class="p">;</span>
</span><span id="__span-5-4"><a id="__codelineno-5-4" name="__codelineno-5-4" href="#__codelineno-5-4"></a><span class="n">quantity</span><span class="w"> </span><span class="n">carnot_eff_2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">temp_hot</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">temp_cold</span><span class="p">)</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="n">temp_hot</span><span class="p">;</span>
</span></code></pre></div>
<p>In the above code, we can easily create absolute or delta values of temperatures and do
arithmetics on them. Previously, we had to create deltas from both points artificially
with:</p>
<div class="language-cpp highlight"><pre><span></span><code><span id="__span-4-1"><a id="__codelineno-4-1" name="__codelineno-4-1" href="#__codelineno-4-1"></a><span class="n">quantity</span><span class="w"> </span><span class="n">temp_cold</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">point</span><span class="o">&lt;</span><span class="n">K</span><span class="o">&gt;</span><span class="p">(</span><span class="mf">300.</span><span class="p">);</span>
</span><span id="__span-4-2"><a id="__codelineno-4-2" name="__codelineno-4-2" href="#__codelineno-4-2"></a><span class="n">quantity</span><span class="w"> </span><span class="n">temp_hot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">point</span><span class="o">&lt;</span><span class="n">K</span><span class="o">&gt;</span><span class="p">(</span><span class="mf">500.</span><span class="p">);</span>
</span><span id="__span-4-3"><a id="__codelineno-4-3" name="__codelineno-4-3" href="#__codelineno-4-3"></a><span class="n">quantity</span><span class="w"> </span><span class="n">carnot_eff_1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">1.</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">temp_cold</span><span class="p">.</span><span class="n">quantity_from_zero</span><span class="p">()</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="n">temp_hot</span><span class="p">.</span><span class="n">quantity_from_zero</span><span class="p">();</span>
</span><span id="__span-4-4"><a id="__codelineno-4-4" name="__codelineno-4-4" href="#__codelineno-4-4"></a><span class="n">quantity</span><span class="w"> </span><span class="n">carnot_eff_2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">temp_hot</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">temp_cold</span><span class="p">)</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="n">temp_hot</span><span class="p">.</span><span class="n">quantity_from_zero</span><span class="p">();</span>
<div class="language-cpp highlight"><pre><span></span><code><span id="__span-6-1"><a id="__codelineno-6-1" name="__codelineno-6-1" href="#__codelineno-6-1"></a><span class="n">quantity</span><span class="w"> </span><span class="n">temp_cold</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">point</span><span class="o">&lt;</span><span class="n">K</span><span class="o">&gt;</span><span class="p">(</span><span class="mf">300.</span><span class="p">);</span>
</span><span id="__span-6-2"><a id="__codelineno-6-2" name="__codelineno-6-2" href="#__codelineno-6-2"></a><span class="n">quantity</span><span class="w"> </span><span class="n">temp_hot</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">point</span><span class="o">&lt;</span><span class="n">K</span><span class="o">&gt;</span><span class="p">(</span><span class="mf">500.</span><span class="p">);</span>
</span><span id="__span-6-3"><a id="__codelineno-6-3" name="__codelineno-6-3" href="#__codelineno-6-3"></a><span class="n">quantity</span><span class="w"> </span><span class="n">carnot_eff_1</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mf">1.</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">temp_cold</span><span class="p">.</span><span class="n">quantity_from_zero</span><span class="p">()</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="n">temp_hot</span><span class="p">.</span><span class="n">quantity_from_zero</span><span class="p">();</span>
</span><span id="__span-6-4"><a id="__codelineno-6-4" name="__codelineno-6-4" href="#__codelineno-6-4"></a><span class="n">quantity</span><span class="w"> </span><span class="n">carnot_eff_2</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">(</span><span class="n">temp_hot</span><span class="w"> </span><span class="o">-</span><span class="w"> </span><span class="n">temp_cold</span><span class="p">)</span><span class="w"> </span><span class="o">/</span><span class="w"> </span><span class="n">temp_hot</span><span class="p">.</span><span class="n">quantity_from_zero</span><span class="p">();</span>
</span></code></pre></div>
<p>It worked but was far from being physically pure and pretty.</p>
<h2 id="summary">Summary<a class="headerlink" href="#summary" title="Permanent link">&para;</a></h2>
<p>We believe that adding absolute quantities will be a major improvement in the library that
will allow us to more correctly model physical equations making them terser and easier to
understand at the same time.</p>
<p>We believe that adding absolute quantities will be a significant improvement in the library
that will allow us to model physical equations in a terser, more correct, easier to
write, understand, and maintain way.</p>
<p>We plan to deliver the features mentioned in this post as a part of <strong>mp-units</strong> V3.</p>
<p>Please share your feedback.</p>
Binary file not shown.

After

Width:  |  Height:  |  Size: 108 KiB

+1 -1
View File
@@ -2375,7 +2375,7 @@ You're not viewing the latest version.
<li class="md-meta__item">
7 min read
8 min read
</li>
+1 -1
View File
@@ -2375,7 +2375,7 @@ You're not viewing the latest version.
<li class="md-meta__item">
7 min read
8 min read
</li>
+1 -1
View File
@@ -2361,7 +2361,7 @@ You're not viewing the latest version.
<li class="md-meta__item">
7 min read
8 min read
</li>
+1 -1
View File
@@ -1 +1 @@
{"version": "https://jsonfeed.org/version/1", "title": "mp-units", "home_page_url": "https://mpusz.github.io/mp-units/HEAD/", "feed_url": "https://mpusz.github.io/mp-units/HEAD/feed_json_updated.json", "description": "The quantities and units library for C++", "icon": null, "authors": [{"name": "mp-units Team"}], "language": "en", "items": [{"id": "https://mpusz.github.io/mp-units/HEAD/blog/2025/06/16/introducing-absolute-quantities/", "url": "https://mpusz.github.io/mp-units/HEAD/blog/2025/06/16/introducing-absolute-quantities/", "title": "Introducing absolute quantities", "content_html": "<h1>Introducing absolute quantities</h1>\n<p>This post introduces a new abstraction called an absolute quantity. It complements affine\nspace abstractions (point and delta) and will most probably be a new default in the library\nwhen we release V3.</p>", "image": "https://mpusz.github.io/mp-units/HEADassets/images/social/blog/posts/introducing-absolute-quantities.png", "date_modified": "2025-06-17T08:25:08+00:00", "authors": [{"name": "Mateusz Pusz"}], "tags": ["Metrology"]}, {"id": "https://mpusz.github.io/mp-units/HEAD/blog/2025/01/15/bringing-quantity-safety-to-the-next-level/", "url": "https://mpusz.github.io/mp-units/HEAD/blog/2025/01/15/bringing-quantity-safety-to-the-next-level/", "title": "Bringing Quantity-Safety To The Next Level", "content_html": "<h1>Bringing Quantity-Safety To The Next Level</h1>\n<p>All quantities and units libraries need to be unit-safe. Most of the libraries on the market do\nthis correctly. Some of them are also dimension-safe, which adds another level of protection for\ntheir users.</p>\n<p><strong>mp-units</strong> is probably the only library on the market that additionally is quantity-safe. This\ngives a new quality and possibilities. I've described the major idea behind it, implementation\ndetails, and benefits to the users in the <a href=\"isq-part-5-benefits.md\">series of posts about the International System of Quantities</a>.</p>\n<p>However, this is only the beginning. We've always planned more and worked on the extensions in our\nfree time. In this post, I will describe:</p>\n<ul>\n<li>What a quantity character is?</li>\n<li>The importance of using proper representation types for the quantities.</li>\n<li>The power of providing character-specific operations for the quantities.</li>\n<li>Discuss implementation challenges and possible solutions.</li>\n</ul>", "image": "https://mpusz.github.io/mp-units/HEADassets/images/social/blog/posts/bringing-quantity-safety-to-the-next-level.png", "date_modified": "2025-02-11T16:26:19+00:00", "authors": [{"name": "Mateusz Pusz"}], "tags": ["Metrology"]}, {"id": "https://mpusz.github.io/mp-units/HEAD/blog/2024/10/28/international-system-of-quantities-isq-part-4---implementing-isq/", "url": "https://mpusz.github.io/mp-units/HEAD/blog/2024/10/28/international-system-of-quantities-isq-part-4---implementing-isq/", "title": "International System of Quantities (ISQ): Part 4 - Implementing ISQ", "content_html": "<h1>International System of Quantities (ISQ): Part 4 - Implementing ISQ</h1>\n<p>Up until now, we have introduced the International System of Quantities and described how we can\nmodel its main aspects. This article will present how to implement those models in a programming\nlanguage, and we will point out some of the first issues that stand in our way.</p>", "image": "https://mpusz.github.io/mp-units/HEADassets/images/social/blog/posts/isq-part-4-implemeting-isq.png", "date_modified": "2025-02-11T16:26:19+00:00", "authors": [{"name": "Mateusz Pusz"}], "tags": ["Metrology"]}, {"id": "https://mpusz.github.io/mp-units/HEAD/blog/2024/11/11/international-system-of-quantities-isq-part-6---challenges/", "url": "https://mpusz.github.io/mp-units/HEAD/blog/2024/11/11/international-system-of-quantities-isq-part-6---challenges/", "title": "International System of Quantities (ISQ): Part 6 - Challenges", "content_html": "<h1>International System of Quantities (ISQ): Part 6 - Challenges</h1>\n<p>This article might be the last one from our series. This time, we will discuss the challenges and\nissues with modeling of the ISQ in software.</p>", "image": "https://mpusz.github.io/mp-units/HEADassets/images/social/blog/posts/isq-part-6-challenges.png", "date_modified": "2025-02-11T16:26:19+00:00", "authors": [{"name": "Mateusz Pusz"}], "tags": ["Metrology"]}, {"id": "https://mpusz.github.io/mp-units/HEAD/blog/2024/11/25/report-from-the-wroc%C5%82aw-2024-iso-c-committee-meeting/", "url": "https://mpusz.github.io/mp-units/HEAD/blog/2024/11/25/report-from-the-wroc%C5%82aw-2024-iso-c-committee-meeting/", "title": "Report from the Wroc\u0142aw 2024 ISO C++ Committee meeting", "content_html": "<h1>Report from the Wroc\u0142aw 2024 ISO C++ Committee meeting</h1>\n<p>The Wroc\u0142aw 2024 meeting was another efficient step in the standardization of this library.\nWe've spent the entire day on the joint LEWGI and SG6 discussion and got lots of feedback.\nWe've also iLine truncated
{"version": "https://jsonfeed.org/version/1", "title": "mp-units", "home_page_url": "https://mpusz.github.io/mp-units/HEAD/", "feed_url": "https://mpusz.github.io/mp-units/HEAD/feed_json_updated.json", "description": "The quantities and units library for C++", "icon": null, "authors": [{"name": "mp-units Team"}], "language": "en", "items": [{"id": "https://mpusz.github.io/mp-units/HEAD/blog/2025/06/16/introducing-absolute-quantities/", "url": "https://mpusz.github.io/mp-units/HEAD/blog/2025/06/16/introducing-absolute-quantities/", "title": "Introducing absolute quantities", "content_html": "<h1>Introducing absolute quantities</h1>\n<p>This post introduces a new abstraction called an absolute quantity. It complements affine\nspace abstractions (point and delta) and will most probably be a new default in the library\nwhen we release V3.</p>", "image": "https://mpusz.github.io/mp-units/HEADassets/images/social/blog/posts/introducing-absolute-quantities.png", "date_modified": "2025-06-17T14:16:55+00:00", "authors": [{"name": "Mateusz Pusz"}], "tags": ["Metrology"]}, {"id": "https://mpusz.github.io/mp-units/HEAD/blog/2025/01/15/bringing-quantity-safety-to-the-next-level/", "url": "https://mpusz.github.io/mp-units/HEAD/blog/2025/01/15/bringing-quantity-safety-to-the-next-level/", "title": "Bringing Quantity-Safety To The Next Level", "content_html": "<h1>Bringing Quantity-Safety To The Next Level</h1>\n<p>All quantities and units libraries need to be unit-safe. Most of the libraries on the market do\nthis correctly. Some of them are also dimension-safe, which adds another level of protection for\ntheir users.</p>\n<p><strong>mp-units</strong> is probably the only library on the market that additionally is quantity-safe. This\ngives a new quality and possibilities. I've described the major idea behind it, implementation\ndetails, and benefits to the users in the <a href=\"isq-part-5-benefits.md\">series of posts about the International System of Quantities</a>.</p>\n<p>However, this is only the beginning. We've always planned more and worked on the extensions in our\nfree time. In this post, I will describe:</p>\n<ul>\n<li>What a quantity character is?</li>\n<li>The importance of using proper representation types for the quantities.</li>\n<li>The power of providing character-specific operations for the quantities.</li>\n<li>Discuss implementation challenges and possible solutions.</li>\n</ul>", "image": "https://mpusz.github.io/mp-units/HEADassets/images/social/blog/posts/bringing-quantity-safety-to-the-next-level.png", "date_modified": "2025-02-11T16:26:19+00:00", "authors": [{"name": "Mateusz Pusz"}], "tags": ["Metrology"]}, {"id": "https://mpusz.github.io/mp-units/HEAD/blog/2024/10/28/international-system-of-quantities-isq-part-4---implementing-isq/", "url": "https://mpusz.github.io/mp-units/HEAD/blog/2024/10/28/international-system-of-quantities-isq-part-4---implementing-isq/", "title": "International System of Quantities (ISQ): Part 4 - Implementing ISQ", "content_html": "<h1>International System of Quantities (ISQ): Part 4 - Implementing ISQ</h1>\n<p>Up until now, we have introduced the International System of Quantities and described how we can\nmodel its main aspects. This article will present how to implement those models in a programming\nlanguage, and we will point out some of the first issues that stand in our way.</p>", "image": "https://mpusz.github.io/mp-units/HEADassets/images/social/blog/posts/isq-part-4-implemeting-isq.png", "date_modified": "2025-02-11T16:26:19+00:00", "authors": [{"name": "Mateusz Pusz"}], "tags": ["Metrology"]}, {"id": "https://mpusz.github.io/mp-units/HEAD/blog/2024/11/11/international-system-of-quantities-isq-part-6---challenges/", "url": "https://mpusz.github.io/mp-units/HEAD/blog/2024/11/11/international-system-of-quantities-isq-part-6---challenges/", "title": "International System of Quantities (ISQ): Part 6 - Challenges", "content_html": "<h1>International System of Quantities (ISQ): Part 6 - Challenges</h1>\n<p>This article might be the last one from our series. This time, we will discuss the challenges and\nissues with modeling of the ISQ in software.</p>", "image": "https://mpusz.github.io/mp-units/HEADassets/images/social/blog/posts/isq-part-6-challenges.png", "date_modified": "2025-02-11T16:26:19+00:00", "authors": [{"name": "Mateusz Pusz"}], "tags": ["Metrology"]}, {"id": "https://mpusz.github.io/mp-units/HEAD/blog/2024/11/25/report-from-the-wroc%C5%82aw-2024-iso-c-committee-meeting/", "url": "https://mpusz.github.io/mp-units/HEAD/blog/2024/11/25/report-from-the-wroc%C5%82aw-2024-iso-c-committee-meeting/", "title": "Report from the Wroc\u0142aw 2024 ISO C++ Committee meeting", "content_html": "<h1>Report from the Wroc\u0142aw 2024 ISO C++ Committee meeting</h1>\n<p>The Wroc\u0142aw 2024 meeting was another efficient step in the standardization of this library.\nWe've spent the entire day on the joint LEWGI and SG6 discussion and got lots of feedback.\nWe've also iLine truncated
+1 -1
View File
@@ -1 +1 @@
<?xml version="1.0" encoding="UTF-8" ?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/"> <channel><title>mp-units</title><description>The quantities and units library for C++</description><link>https://mpusz.github.io/mp-units/HEAD/</link><atom:link href="https://mpusz.github.io/mp-units/HEAD/feed_rss_created.xml" rel="self" type="application/rss+xml" /><managingEditor>mp-units Team</managingEditor><docs>https://github.com/mpusz/mp-units</docs><language>en</language> <pubDate>Tue, 17 Jun 2025 08:29:14 -0000</pubDate> <lastBuildDate>Tue, 17 Jun 2025 08:29:14 -0000</lastBuildDate> <ttl>1440</ttl> <generator>MkDocs RSS plugin - v1.17.3</generator> <image> <url>None</url> <title>mp-units</title><link>https://mpusz.github.io/mp-units/HEAD/</link> </image> <item> <title>Introducing absolute quantities</title> <author>Mateusz Pusz</author> <category>Metrology</category> <description>&lt;h1&gt;Introducing absolute quantities&lt;/h1&gt;&lt;p&gt;This post introduces a new abstraction called an absolute quantity. It complements affinespace abstractions (point and delta) and will most probably be a new default in the librarywhen we release V3.&lt;/p&gt;</description><link>https://mpusz.github.io/mp-units/HEAD/blog/2025/06/16/introducing-absolute-quantities/</link> <pubDate>Mon, 16 Jun 2025 00:00:00 +0000</pubDate><source url="https://mpusz.github.io/mp-units/HEAD/feed_rss_created.xml">mp-units</source><guid isPermaLink="true">https://mpusz.github.io/mp-units/HEAD/blog/2025/06/16/introducing-absolute-quantities/</guid> <enclosure url="https://mpusz.github.io/mp-units/HEADassets/images/social/blog/posts/introducing-absolute-quantities.png" type="image/png" length="39574" /> </item> <item> <title>Bringing Quantity-Safety To The Next Level</title> <author>Mateusz Pusz</author> <category>Metrology</category> <description>&lt;h1&gt;Bringing Quantity-Safety To The Next Level&lt;/h1&gt;&lt;p&gt;All quantities and units libraries need to be unit-safe. Most of the libraries on the market dothis correctly. Some of them are also dimension-safe, which adds another level of protection fortheir users.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;mp-units&lt;/strong&gt; is probably the only library on the market that additionally is quantity-safe. Thisgives a new quality and possibilities. I&#39;ve described the major idea behind it, implementationdetails, and benefits to the users in the &lt;a href=&#34;isq-part-5-benefits.md&#34;&gt;series of posts about the International System of Quantities&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;However, this is only the beginning. We&#39;ve always planned more and worked on the extensions in ourfree time. In this post, I will describe:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;What a quantity character is?&lt;/li&gt;&lt;li&gt;The importance of using proper representation types for the quantities.&lt;/li&gt;&lt;li&gt;The power of providing character-specific operations for the quantities.&lt;/li&gt;&lt;li&gt;Discuss implementation challenges and possible solutions.&lt;/li&gt;&lt;/ul&gt;</description><link>https://mpusz.github.io/mp-units/HEAD/blog/2025/01/15/bringing-quantity-safety-to-the-next-level/</link> <pubDate>Wed, 15 Jan 2025 00:00:00 +0000</pubDate><source url="https://mpusz.github.io/mp-units/HEAD/feed_rss_created.xml">mp-units</source><guid isPermaLink="true">https://mpusz.github.io/mp-units/HEAD/blog/2025/01/15/bringing-quantity-safety-to-the-next-level/</guid> <enclosure url="https://mpusz.github.io/mp-units/HEADassets/images/social/blog/posts/bringing-quantity-safety-to-the-next-level.png" type="image/png" length="45128" /> </item> <item> <title>Report from the Wrocław 2024 ISO C++ Committee meeting</title> <author>Mateusz Pusz</author> <category>WG21 Updates</category> <description>&lt;h1&gt;Report from the Wrocław 2024 ISO C++ Committee meeting&lt;/h1&gt;&lt;p&gt;The Wrocław 2024 meeting was another efficient step in the standardization of this library.We&#39;ve spent the entire day on the joint LEWGI and SG6 discussion and got lots of feedback.We&#39;ve also introduced &lt;code&gt;std::fixed_string&lt;/code&gt; to LEWG for C++26.&lt;/p&gt;</description><link>https://mpusz.github.io/mp-units/HEAD/blog/2024/11/25/report-from-the-wroc%C5%82aw-2024-iso-c-committee-meeting/</link> <pubDate>Mon, 25 Nov 2024 00:00:00 +0000</pubDate><source url="https://mpusz.github.io/mp-units/HEAD/feed_rss_created.xml">mp-units</source><guid isPermaLink="true">https://mpusz.github.io/mp-units/HEAD/blog/2024/11/25/report-from-the-wroc%C5%82aw-2024-iso-c-committee-meeting/</guid> <enclosure url="https://mpusz.github.io/mp-units/HEADassets/images/social/blog/posts/wrocław-2024-report.png" type="image/png" length="53358" /> </item> <item> <title>International System of Quantities (ISQ): Part 6 - Challenges</title> <author>Mateusz Pusz</author> <category>Metrology</category> <description>&lt;h1&gt;International System of Quantities (ISQ): Part 6 - Challenges&lt;/h1&gt;&lt;p&gt;This arLine truncated
<?xml version="1.0" encoding="UTF-8" ?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/"> <channel><title>mp-units</title><description>The quantities and units library for C++</description><link>https://mpusz.github.io/mp-units/HEAD/</link><atom:link href="https://mpusz.github.io/mp-units/HEAD/feed_rss_created.xml" rel="self" type="application/rss+xml" /><managingEditor>mp-units Team</managingEditor><docs>https://github.com/mpusz/mp-units</docs><language>en</language> <pubDate>Tue, 17 Jun 2025 14:21:04 -0000</pubDate> <lastBuildDate>Tue, 17 Jun 2025 14:21:04 -0000</lastBuildDate> <ttl>1440</ttl> <generator>MkDocs RSS plugin - v1.17.3</generator> <image> <url>None</url> <title>mp-units</title><link>https://mpusz.github.io/mp-units/HEAD/</link> </image> <item> <title>Introducing absolute quantities</title> <author>Mateusz Pusz</author> <category>Metrology</category> <description>&lt;h1&gt;Introducing absolute quantities&lt;/h1&gt;&lt;p&gt;This post introduces a new abstraction called an absolute quantity. It complements affinespace abstractions (point and delta) and will most probably be a new default in the librarywhen we release V3.&lt;/p&gt;</description><link>https://mpusz.github.io/mp-units/HEAD/blog/2025/06/16/introducing-absolute-quantities/</link> <pubDate>Mon, 16 Jun 2025 00:00:00 +0000</pubDate><source url="https://mpusz.github.io/mp-units/HEAD/feed_rss_created.xml">mp-units</source><guid isPermaLink="true">https://mpusz.github.io/mp-units/HEAD/blog/2025/06/16/introducing-absolute-quantities/</guid> <enclosure url="https://mpusz.github.io/mp-units/HEADassets/images/social/blog/posts/introducing-absolute-quantities.png" type="image/png" length="39574" /> </item> <item> <title>Bringing Quantity-Safety To The Next Level</title> <author>Mateusz Pusz</author> <category>Metrology</category> <description>&lt;h1&gt;Bringing Quantity-Safety To The Next Level&lt;/h1&gt;&lt;p&gt;All quantities and units libraries need to be unit-safe. Most of the libraries on the market dothis correctly. Some of them are also dimension-safe, which adds another level of protection fortheir users.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;mp-units&lt;/strong&gt; is probably the only library on the market that additionally is quantity-safe. Thisgives a new quality and possibilities. I&#39;ve described the major idea behind it, implementationdetails, and benefits to the users in the &lt;a href=&#34;isq-part-5-benefits.md&#34;&gt;series of posts about the International System of Quantities&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;However, this is only the beginning. We&#39;ve always planned more and worked on the extensions in ourfree time. In this post, I will describe:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;What a quantity character is?&lt;/li&gt;&lt;li&gt;The importance of using proper representation types for the quantities.&lt;/li&gt;&lt;li&gt;The power of providing character-specific operations for the quantities.&lt;/li&gt;&lt;li&gt;Discuss implementation challenges and possible solutions.&lt;/li&gt;&lt;/ul&gt;</description><link>https://mpusz.github.io/mp-units/HEAD/blog/2025/01/15/bringing-quantity-safety-to-the-next-level/</link> <pubDate>Wed, 15 Jan 2025 00:00:00 +0000</pubDate><source url="https://mpusz.github.io/mp-units/HEAD/feed_rss_created.xml">mp-units</source><guid isPermaLink="true">https://mpusz.github.io/mp-units/HEAD/blog/2025/01/15/bringing-quantity-safety-to-the-next-level/</guid> <enclosure url="https://mpusz.github.io/mp-units/HEADassets/images/social/blog/posts/bringing-quantity-safety-to-the-next-level.png" type="image/png" length="45128" /> </item> <item> <title>Report from the Wrocław 2024 ISO C++ Committee meeting</title> <author>Mateusz Pusz</author> <category>WG21 Updates</category> <description>&lt;h1&gt;Report from the Wrocław 2024 ISO C++ Committee meeting&lt;/h1&gt;&lt;p&gt;The Wrocław 2024 meeting was another efficient step in the standardization of this library.We&#39;ve spent the entire day on the joint LEWGI and SG6 discussion and got lots of feedback.We&#39;ve also introduced &lt;code&gt;std::fixed_string&lt;/code&gt; to LEWG for C++26.&lt;/p&gt;</description><link>https://mpusz.github.io/mp-units/HEAD/blog/2024/11/25/report-from-the-wroc%C5%82aw-2024-iso-c-committee-meeting/</link> <pubDate>Mon, 25 Nov 2024 00:00:00 +0000</pubDate><source url="https://mpusz.github.io/mp-units/HEAD/feed_rss_created.xml">mp-units</source><guid isPermaLink="true">https://mpusz.github.io/mp-units/HEAD/blog/2024/11/25/report-from-the-wroc%C5%82aw-2024-iso-c-committee-meeting/</guid> <enclosure url="https://mpusz.github.io/mp-units/HEADassets/images/social/blog/posts/wrocław-2024-report.png" type="image/png" length="53358" /> </item> <item> <title>International System of Quantities (ISQ): Part 6 - Challenges</title> <author>Mateusz Pusz</author> <category>Metrology</category> <description>&lt;h1&gt;International System of Quantities (ISQ): Part 6 - Challenges&lt;/h1&gt;&lt;p&gt;This arLine truncated
+1 -1
View File
@@ -1 +1 @@
<?xml version="1.0" encoding="UTF-8" ?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/"> <channel><title>mp-units</title><description>The quantities and units library for C++</description><link>https://mpusz.github.io/mp-units/HEAD/</link><atom:link href="https://mpusz.github.io/mp-units/HEAD/feed_rss_updated.xml" rel="self" type="application/rss+xml" /><managingEditor>mp-units Team</managingEditor><docs>https://github.com/mpusz/mp-units</docs><language>en</language> <pubDate>Tue, 17 Jun 2025 08:29:14 -0000</pubDate> <lastBuildDate>Tue, 17 Jun 2025 08:29:14 -0000</lastBuildDate> <ttl>1440</ttl> <generator>MkDocs RSS plugin - v1.17.3</generator> <image> <url>None</url> <title>mp-units</title><link>https://mpusz.github.io/mp-units/HEAD/</link> </image> <item> <title>Introducing absolute quantities</title> <author>Mateusz Pusz</author> <category>Metrology</category> <description>&lt;h1&gt;Introducing absolute quantities&lt;/h1&gt;&lt;p&gt;This post introduces a new abstraction called an absolute quantity. It complements affinespace abstractions (point and delta) and will most probably be a new default in the librarywhen we release V3.&lt;/p&gt;</description><link>https://mpusz.github.io/mp-units/HEAD/blog/2025/06/16/introducing-absolute-quantities/</link> <pubDate>Tue, 17 Jun 2025 08:25:08 +0000</pubDate><source url="https://mpusz.github.io/mp-units/HEAD/feed_rss_updated.xml">mp-units</source><guid isPermaLink="true">https://mpusz.github.io/mp-units/HEAD/blog/2025/06/16/introducing-absolute-quantities/</guid> <enclosure url="https://mpusz.github.io/mp-units/HEADassets/images/social/blog/posts/introducing-absolute-quantities.png" type="image/png" length="39574" /> </item> <item> <title>Bringing Quantity-Safety To The Next Level</title> <author>Mateusz Pusz</author> <category>Metrology</category> <description>&lt;h1&gt;Bringing Quantity-Safety To The Next Level&lt;/h1&gt;&lt;p&gt;All quantities and units libraries need to be unit-safe. Most of the libraries on the market dothis correctly. Some of them are also dimension-safe, which adds another level of protection fortheir users.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;mp-units&lt;/strong&gt; is probably the only library on the market that additionally is quantity-safe. Thisgives a new quality and possibilities. I&#39;ve described the major idea behind it, implementationdetails, and benefits to the users in the &lt;a href=&#34;isq-part-5-benefits.md&#34;&gt;series of posts about the International System of Quantities&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;However, this is only the beginning. We&#39;ve always planned more and worked on the extensions in ourfree time. In this post, I will describe:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;What a quantity character is?&lt;/li&gt;&lt;li&gt;The importance of using proper representation types for the quantities.&lt;/li&gt;&lt;li&gt;The power of providing character-specific operations for the quantities.&lt;/li&gt;&lt;li&gt;Discuss implementation challenges and possible solutions.&lt;/li&gt;&lt;/ul&gt;</description><link>https://mpusz.github.io/mp-units/HEAD/blog/2025/01/15/bringing-quantity-safety-to-the-next-level/</link> <pubDate>Tue, 11 Feb 2025 16:26:19 +0000</pubDate><source url="https://mpusz.github.io/mp-units/HEAD/feed_rss_updated.xml">mp-units</source><guid isPermaLink="true">https://mpusz.github.io/mp-units/HEAD/blog/2025/01/15/bringing-quantity-safety-to-the-next-level/</guid> <enclosure url="https://mpusz.github.io/mp-units/HEADassets/images/social/blog/posts/bringing-quantity-safety-to-the-next-level.png" type="image/png" length="45128" /> </item> <item> <title>International System of Quantities (ISQ): Part 4 - Implementing ISQ</title> <author>Mateusz Pusz</author> <category>Metrology</category> <description>&lt;h1&gt;International System of Quantities (ISQ): Part 4 - Implementing ISQ&lt;/h1&gt;&lt;p&gt;Up until now, we have introduced the International System of Quantities and described how we canmodel its main aspects. This article will present how to implement those models in a programminglanguage, and we will point out some of the first issues that stand in our way.&lt;/p&gt;</description><link>https://mpusz.github.io/mp-units/HEAD/blog/2024/10/28/international-system-of-quantities-isq-part-4---implementing-isq/</link> <pubDate>Tue, 11 Feb 2025 16:26:19 +0000</pubDate><source url="https://mpusz.github.io/mp-units/HEAD/feed_rss_updated.xml">mp-units</source><guid isPermaLink="true">https://mpusz.github.io/mp-units/HEAD/blog/2024/10/28/international-system-of-quantities-isq-part-4---implementing-isq/</guid> <enclosure url="https://mpusz.github.io/mp-units/HEADassets/images/social/blog/posts/isq-part-4-implemeting-isq.png" type="image/png" length="52250" /> </item> <item> <title>International System of Quantities (ISQ): Part 6 - Challenges</title> <author>Mateusz Pusz</author> <category>Metrology</category> <description>&lt;h1&gt;International System of Quantities (ISQ): Part 6 Line truncated
<?xml version="1.0" encoding="UTF-8" ?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/"> <channel><title>mp-units</title><description>The quantities and units library for C++</description><link>https://mpusz.github.io/mp-units/HEAD/</link><atom:link href="https://mpusz.github.io/mp-units/HEAD/feed_rss_updated.xml" rel="self" type="application/rss+xml" /><managingEditor>mp-units Team</managingEditor><docs>https://github.com/mpusz/mp-units</docs><language>en</language> <pubDate>Tue, 17 Jun 2025 14:21:04 -0000</pubDate> <lastBuildDate>Tue, 17 Jun 2025 14:21:04 -0000</lastBuildDate> <ttl>1440</ttl> <generator>MkDocs RSS plugin - v1.17.3</generator> <image> <url>None</url> <title>mp-units</title><link>https://mpusz.github.io/mp-units/HEAD/</link> </image> <item> <title>Introducing absolute quantities</title> <author>Mateusz Pusz</author> <category>Metrology</category> <description>&lt;h1&gt;Introducing absolute quantities&lt;/h1&gt;&lt;p&gt;This post introduces a new abstraction called an absolute quantity. It complements affinespace abstractions (point and delta) and will most probably be a new default in the librarywhen we release V3.&lt;/p&gt;</description><link>https://mpusz.github.io/mp-units/HEAD/blog/2025/06/16/introducing-absolute-quantities/</link> <pubDate>Tue, 17 Jun 2025 14:16:55 +0000</pubDate><source url="https://mpusz.github.io/mp-units/HEAD/feed_rss_updated.xml">mp-units</source><guid isPermaLink="true">https://mpusz.github.io/mp-units/HEAD/blog/2025/06/16/introducing-absolute-quantities/</guid> <enclosure url="https://mpusz.github.io/mp-units/HEADassets/images/social/blog/posts/introducing-absolute-quantities.png" type="image/png" length="39574" /> </item> <item> <title>Bringing Quantity-Safety To The Next Level</title> <author>Mateusz Pusz</author> <category>Metrology</category> <description>&lt;h1&gt;Bringing Quantity-Safety To The Next Level&lt;/h1&gt;&lt;p&gt;All quantities and units libraries need to be unit-safe. Most of the libraries on the market dothis correctly. Some of them are also dimension-safe, which adds another level of protection fortheir users.&lt;/p&gt;&lt;p&gt;&lt;strong&gt;mp-units&lt;/strong&gt; is probably the only library on the market that additionally is quantity-safe. Thisgives a new quality and possibilities. I&#39;ve described the major idea behind it, implementationdetails, and benefits to the users in the &lt;a href=&#34;isq-part-5-benefits.md&#34;&gt;series of posts about the International System of Quantities&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;However, this is only the beginning. We&#39;ve always planned more and worked on the extensions in ourfree time. In this post, I will describe:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;What a quantity character is?&lt;/li&gt;&lt;li&gt;The importance of using proper representation types for the quantities.&lt;/li&gt;&lt;li&gt;The power of providing character-specific operations for the quantities.&lt;/li&gt;&lt;li&gt;Discuss implementation challenges and possible solutions.&lt;/li&gt;&lt;/ul&gt;</description><link>https://mpusz.github.io/mp-units/HEAD/blog/2025/01/15/bringing-quantity-safety-to-the-next-level/</link> <pubDate>Tue, 11 Feb 2025 16:26:19 +0000</pubDate><source url="https://mpusz.github.io/mp-units/HEAD/feed_rss_updated.xml">mp-units</source><guid isPermaLink="true">https://mpusz.github.io/mp-units/HEAD/blog/2025/01/15/bringing-quantity-safety-to-the-next-level/</guid> <enclosure url="https://mpusz.github.io/mp-units/HEADassets/images/social/blog/posts/bringing-quantity-safety-to-the-next-level.png" type="image/png" length="45128" /> </item> <item> <title>International System of Quantities (ISQ): Part 4 - Implementing ISQ</title> <author>Mateusz Pusz</author> <category>Metrology</category> <description>&lt;h1&gt;International System of Quantities (ISQ): Part 4 - Implementing ISQ&lt;/h1&gt;&lt;p&gt;Up until now, we have introduced the International System of Quantities and described how we canmodel its main aspects. This article will present how to implement those models in a programminglanguage, and we will point out some of the first issues that stand in our way.&lt;/p&gt;</description><link>https://mpusz.github.io/mp-units/HEAD/blog/2024/10/28/international-system-of-quantities-isq-part-4---implementing-isq/</link> <pubDate>Tue, 11 Feb 2025 16:26:19 +0000</pubDate><source url="https://mpusz.github.io/mp-units/HEAD/feed_rss_updated.xml">mp-units</source><guid isPermaLink="true">https://mpusz.github.io/mp-units/HEAD/blog/2024/10/28/international-system-of-quantities-isq-part-4---implementing-isq/</guid> <enclosure url="https://mpusz.github.io/mp-units/HEADassets/images/social/blog/posts/isq-part-4-implemeting-isq.png" type="image/png" length="52250" /> </item> <item> <title>International System of Quantities (ISQ): Part 6 - Challenges</title> <author>Mateusz Pusz</author> <category>Metrology</category> <description>&lt;h1&gt;International System of Quantities (ISQ): Part 6 Line truncated
+1 -1
View File
@@ -1 +1 @@
{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Welcome to mp-units!","text":"<p>mp-units is a compile-time enabled feature-rich Modern C++ modular/header-only library that provides compile-time dimensional analysis and unit/quantity manipulation. Its key strengths include safety, performance, and developer experience.</p> <p>It is the first library on the market that, besides being unit-safe and dimension-safe, is also quantity-safe.</p> <p>The library source code is hosted on GitHub with a permissive MIT license.</p> Supported compilers <p>This library tries to provide the best user experience possible with the C++ language. To achieve that, it extensively uses the latest C++ language features.</p> <p>Even though the library benefits from the latest C++ versions (if available), C++20 is enough to compile and use all of the library's functionality.</p> <p>Please refer to C++ compiler support chapter for more details.</p> C++ modulesHeader files <pre><code>#include &lt;iostream&gt;\n#include &lt;print&gt;\nimport mp_units;\n\nusing namespace mp_units;\n\ninline constexpr struct smoot final : named_unit&lt;\"smoot\", mag&lt;67&gt; * usc::inch&gt; {} smoot;\n\nint main()\n{\n constexpr quantity dist = 364.4 * smoot;\n std::println(\"Harvard Bridge length = {::N[.1f]} ({::N[.1f]}, {::N[.2f]}) \u00b1 1 \u03b5ar\",\n dist, dist.in(usc::foot), dist.in(si::metre));\n}\n</code></pre> <pre><code>#include &lt;mp-units/format.h&gt;\n#include &lt;mp-units/systems/si.h&gt;\n#include &lt;mp-units/systems/usc.h&gt;\n#include &lt;print&gt;\n\nusing namespace mp_units;\n\ninline constexpr struct smoot final : named_unit&lt;\"smoot\", mag&lt;67&gt; * usc::inch&gt; {} smoot;\n\nint main()\n{\n constexpr quantity dist = 364.4 * smoot;\n std::println(\"Harvard Bridge length = {::N[.1f]} ({::N[.1f]}, {::N[.2f]}) \u00b1 1 \u03b5ar\",\n dist, dist.in(usc::foot), dist.in(si::metre));\n}\n</code></pre> <p>Output:</p> <pre><code>Harvard Bridge length = 364.4 smoot (2034.6 ft, 620.14 m) \u00b1 1 \u03b5ar\n</code></pre> <p>Try it on Compiler Explorer</p> What is <code>smoot</code>? <p>The smoot (/\u02c8smu\u02d0t/) is a nonstandard unit of length created as part of an MIT fraternity prank. It is named after Oliver R. Smoot, a fraternity pledge to Lambda Chi Alpha, who, in October 1958, lay on the Harvard Bridge (between Boston and Cambridge, Massachusetts) and was used by his fraternity brothers to measure the length of the bridge.</p> <p>One smoot equals Oliver Smoot's height at the time of the prank (five feet and seven inches). The bridge's length was measured to be 364.4 smoots plus or minus one ear, with the \"plus or minus\" intended to express the measurement uncertainty.</p> <p>Oliver Smoot graduated from MIT with the class of 1962, became a lawyer, and later became chairman of the American National Standards Institute (ANSI) and president of the International Organization for Standardization (ISO).</p> <p>More on the smoot unit of length can be found at https://en.wikipedia.org/wiki/Smoot.</p> <p>Important: Help needed!</p> <p>The mp-units library might be the subject of ISO standardization for C++29. More on this can be found in the following ISO C++ proposals:</p> <ul> <li>P1935: A C++ Approach to Physical Units,</li> <li>P2980: A motivation, scope, and plan for a physical quantities and units library,</li> <li>P3045: Quantities and units library.</li> </ul> <p>We are actively looking for parties interested in field-trialing the library.</p>"},{"location":"api_reference/","title":"API Reference - mp-units","text":""},{"location":"release_notes/","title":"Release Notes","text":""},{"location":"release_notes/#mp-units","title":"mp-units","text":""},{"location":"release_notes/#2.5.0","title":"2.5.0 WIP","text":"<ul> <li>(!) feat: representation concepts improved</li> <li>(!) feat: <code>representation_of</code> concept now also accepts a <code>quantity_spec</code> and accepts any representation character for quantity kinds</li> <li>(!) feat: <code>quantity::one()</code> removed</li> <li>(!) feat: <code>Representation</code> concept removed</li> <li>feat: <code>SymbolicArg</code> applied to expression templates</li> <li>feat: <code>per</code> and <code>power</code> made <code>final</code></li> <li>feat: <code>derived_XXX</code> are now constrained with <code>SymbolicConstant</code></li> <li>feat: prime factorization extended to any magnitude (thanks @chiphogg)</li> <li>feat: <code>cartesian_vector</code> added</li> <li>feat: <code>equivalent</code> now accept any units (even non-convertible)</li> <li>feat: text output should fallback to the portable mode when UTF-8 is not used for <code>text_encoding</code></li> <li>feat: precondition added to <code>to_u8string</code></li> <li>feat: text output of scaled units is now enclosed in parenthesis <code>(...)</code> instead of brackets <code>[...]</code></li> <li>feat: <code>abs(quantity)</Line truncated
{"config":{"lang":["en"],"separator":"[\\s\\-]+","pipeline":["stopWordFilter"]},"docs":[{"location":"","title":"Welcome to mp-units!","text":"<p>mp-units is a compile-time enabled feature-rich Modern C++ modular/header-only library that provides compile-time dimensional analysis and unit/quantity manipulation. Its key strengths include safety, performance, and developer experience.</p> <p>It is the first library on the market that, besides being unit-safe and dimension-safe, is also quantity-safe.</p> <p>The library source code is hosted on GitHub with a permissive MIT license.</p> Supported compilers <p>This library tries to provide the best user experience possible with the C++ language. To achieve that, it extensively uses the latest C++ language features.</p> <p>Even though the library benefits from the latest C++ versions (if available), C++20 is enough to compile and use all of the library's functionality.</p> <p>Please refer to C++ compiler support chapter for more details.</p> C++ modulesHeader files <pre><code>#include &lt;iostream&gt;\n#include &lt;print&gt;\nimport mp_units;\n\nusing namespace mp_units;\n\ninline constexpr struct smoot final : named_unit&lt;\"smoot\", mag&lt;67&gt; * usc::inch&gt; {} smoot;\n\nint main()\n{\n constexpr quantity dist = 364.4 * smoot;\n std::println(\"Harvard Bridge length = {::N[.1f]} ({::N[.1f]}, {::N[.2f]}) \u00b1 1 \u03b5ar\",\n dist, dist.in(usc::foot), dist.in(si::metre));\n}\n</code></pre> <pre><code>#include &lt;mp-units/format.h&gt;\n#include &lt;mp-units/systems/si.h&gt;\n#include &lt;mp-units/systems/usc.h&gt;\n#include &lt;print&gt;\n\nusing namespace mp_units;\n\ninline constexpr struct smoot final : named_unit&lt;\"smoot\", mag&lt;67&gt; * usc::inch&gt; {} smoot;\n\nint main()\n{\n constexpr quantity dist = 364.4 * smoot;\n std::println(\"Harvard Bridge length = {::N[.1f]} ({::N[.1f]}, {::N[.2f]}) \u00b1 1 \u03b5ar\",\n dist, dist.in(usc::foot), dist.in(si::metre));\n}\n</code></pre> <p>Output:</p> <pre><code>Harvard Bridge length = 364.4 smoot (2034.6 ft, 620.14 m) \u00b1 1 \u03b5ar\n</code></pre> <p>Try it on Compiler Explorer</p> What is <code>smoot</code>? <p>The smoot (/\u02c8smu\u02d0t/) is a nonstandard unit of length created as part of an MIT fraternity prank. It is named after Oliver R. Smoot, a fraternity pledge to Lambda Chi Alpha, who, in October 1958, lay on the Harvard Bridge (between Boston and Cambridge, Massachusetts) and was used by his fraternity brothers to measure the length of the bridge.</p> <p>One smoot equals Oliver Smoot's height at the time of the prank (five feet and seven inches). The bridge's length was measured to be 364.4 smoots plus or minus one ear, with the \"plus or minus\" intended to express the measurement uncertainty.</p> <p>Oliver Smoot graduated from MIT with the class of 1962, became a lawyer, and later became chairman of the American National Standards Institute (ANSI) and president of the International Organization for Standardization (ISO).</p> <p>More on the smoot unit of length can be found at https://en.wikipedia.org/wiki/Smoot.</p> <p>Important: Help needed!</p> <p>The mp-units library might be the subject of ISO standardization for C++29. More on this can be found in the following ISO C++ proposals:</p> <ul> <li>P1935: A C++ Approach to Physical Units,</li> <li>P2980: A motivation, scope, and plan for a physical quantities and units library,</li> <li>P3045: Quantities and units library.</li> </ul> <p>We are actively looking for parties interested in field-trialing the library.</p>"},{"location":"api_reference/","title":"API Reference - mp-units","text":""},{"location":"release_notes/","title":"Release Notes","text":""},{"location":"release_notes/#mp-units","title":"mp-units","text":""},{"location":"release_notes/#2.5.0","title":"2.5.0 WIP","text":"<ul> <li>(!) feat: representation concepts improved</li> <li>(!) feat: <code>representation_of</code> concept now also accepts a <code>quantity_spec</code> and accepts any representation character for quantity kinds</li> <li>(!) feat: <code>quantity::one()</code> removed</li> <li>(!) feat: <code>Representation</code> concept removed</li> <li>feat: <code>SymbolicArg</code> applied to expression templates</li> <li>feat: <code>per</code> and <code>power</code> made <code>final</code></li> <li>feat: <code>derived_XXX</code> are now constrained with <code>SymbolicConstant</code></li> <li>feat: prime factorization extended to any magnitude (thanks @chiphogg)</li> <li>feat: <code>cartesian_vector</code> added</li> <li>feat: <code>equivalent</code> now accept any units (even non-convertible)</li> <li>feat: text output should fallback to the portable mode when UTF-8 is not used for <code>text_encoding</code></li> <li>feat: precondition added to <code>to_u8string</code></li> <li>feat: text output of scaled units is now enclosed in parenthesis <code>(...)</code> instead of brackets <code>[...]</code></li> <li>feat: <code>abs(quantity)</Line truncated