<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>foonathan::blog()</title>
    <link>https://www.foonathan.net/post/</link>
    <description>Recent content on foonathan::blog()</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <copyright>2015-2025</copyright>
    <lastBuildDate>Wed, 20 Nov 2024 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://www.foonathan.net/post/feed.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Trip Report: Fall ISO C&#43;&#43; Meeting in Wrocław, Poland</title>
      <link>https://www.foonathan.net/2024/11/trip-report-wroclaw-2024/</link>
      <pubDate>Wed, 20 Nov 2024 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2024/11/trip-report-wroclaw-2024/</guid>
      <description>&lt;p&gt;Last week, I attended the fall 2024 meeting of the ISO C++ standardization committee in Wrocław, Poland. This was the fifth meeting for the upcoming C++26 standard and the feature freeze for major C++26 features.&#xA;For an overview of all the papers that made progress, read &lt;a href=&#34;https://herbsutter.com/2024/11/24/wg21-2024-11/&#34;&gt;Herb Sutter&amp;rsquo;s trip report&lt;/a&gt;.&#xA;&lt;a href=&#34;https://wg21.link/P2900R11&#34;&gt;Contracts&lt;/a&gt; and &lt;a href=&#34;https://wg21.link/P3081R0&#34;&gt;profiles&lt;/a&gt; are the big ticket items that made the most progress this meeting.&#xA;Contracts is forwarded to wording review, while still being fiercely opposed by some.&#xA;Profiles is essentially standardized static analysis to improve memory safety, although some deem it ineffective.&#xA;Due to various scheduling conflicts I did not attend any of the relevant discussions in these spaces.&#xA;Instead, I am going to share my thoughts about ranges, relocation, and reflection.&lt;/p&gt;</description>
    </item>
    <item>
      <title>if constexpr requires requires { requires }</title>
      <link>https://www.foonathan.net/2024/10/if-constexpr-requires-requires/</link>
      <pubDate>Wed, 23 Oct 2024 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2024/10/if-constexpr-requires-requires/</guid>
      <description>&lt;p&gt;Probably the two most useful features added to C++20 are &lt;code&gt;requires&lt;/code&gt; and &lt;code&gt;requires&lt;/code&gt;.&#xA;They make it so much easier to control overload resolution, and when combined with &lt;code&gt;if constexpr&lt;/code&gt; in C++17, they allow basic reflection-based optimizations in templates.&#xA;While &lt;code&gt;requires requires&lt;/code&gt; has gotten a lot of (negative?!) press for controlling overload resolution, its cousin &lt;code&gt;requires { requires }&lt;/code&gt; is a bit overlooked.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Trip Report: Summer ISO C&#43;&#43; Meeting in St. Louis, USA</title>
      <link>https://www.foonathan.net/2024/07/trip-report-stlouis-2024/</link>
      <pubDate>Fri, 12 Jul 2024 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2024/07/trip-report-stlouis-2024/</guid>
      <description>&lt;p&gt;Two weeks ago, I attended the summer 2024 meeting of the ISO C++ standardization committee in St. Louis, USA. We made progress on a lot of features for C++26, but I have some thoughts about senders/receivers, reflection, and the idea of introducing borrow checking to C++.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Trip Report: C&#43;&#43;Now 2024</title>
      <link>https://www.foonathan.net/2024/05/trip-report-cppnow-2024/</link>
      <pubDate>Wed, 08 May 2024 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2024/05/trip-report-cppnow-2024/</guid>
      <description>&lt;p&gt;Last week, I&amp;rsquo;ve attended C++Now 2024 and it was definitely one of the best conferences I&amp;rsquo;ve ever been to!&lt;/p&gt;</description>
    </item>
    <item>
      <title>Trip Report: Spring ISO C&#43;&#43; Meeting in Tokyo, Japan</title>
      <link>https://www.foonathan.net/2024/03/trip-report-tokyo-2024/</link>
      <pubDate>Wed, 27 Mar 2024 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2024/03/trip-report-tokyo-2024/</guid>
      <description>&lt;p&gt;Last week, I attended the spring 2024 meeting of the ISO C++ standardization committee in Tokyo, Japan. We made progress on a bunch of interesting features for C++26.&lt;/p&gt;</description>
    </item>
    <item>
      <title>I&#39;m the new assistant chair of SG 9, the study group for std::ranges! </title>
      <link>https://www.foonathan.net/2024/03/sg9/</link>
      <pubDate>Fri, 08 Mar 2024 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2024/03/sg9/</guid>
      <description>&lt;p&gt;In a week, the C++ standardization committee is meeting in Tokyo, Japan, to continue work on C++26. It will be my first meeting with an official role as assistant chair of SG 9.&lt;/p&gt;</description>
    </item>
    <item>
      <title>C&#43;&#43; needs undefined behavior, but maybe less</title>
      <link>https://www.foonathan.net/2023/11/undefined-behavior/</link>
      <pubDate>Mon, 20 Nov 2023 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2023/11/undefined-behavior/</guid>
      <description>&lt;p&gt;The C++ standard does not specify all behavior. Some things are up to the implementation, while other operations are completely undefined, and the compiler is free to do whatever it wants. This is essential for some optimizations but can also be dangerous. The newly proposed erroneous behavior addresses it, but it cannot be used to eliminate all undefined behavior.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Compile-time sizes for range adaptors</title>
      <link>https://www.foonathan.net/2023/08/compile-time-sizes-range-adaptors/</link>
      <pubDate>Tue, 29 Aug 2023 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2023/08/compile-time-sizes-range-adaptors/</guid>
      <description>&lt;p&gt;In my &lt;a href=&#34;https://www.think-cell.com/en/career/devblog/the-new-static-constexpr-std-integral_constant-idiom&#34;&gt;previous blog post&lt;/a&gt;, we&amp;rsquo;ve discussed the &lt;code&gt;static constexpr std::integral_constant&lt;/code&gt; idiom to specify the size of a range at compile-time.&#xA;Unlike the standard, our [think-cell&amp;rsquo;s] ranges library at think-cell already supports compile-time sizes natively, so I was eager to try the idiom there and see how it works out in practice.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-cpp&#34; data-lang=&#34;cpp&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;namespace&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;tc&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;template&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;typename&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Rng&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;constexpr&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;auto&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;size&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Rng&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;rng&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;// runtime-size of a range, like std::ranges::size&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;template&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;typename&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Rng&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;requires&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;tc&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;has_constexpr_size&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Rng&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;constexpr&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;auto&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;constexpr_size&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;err&#34;&gt;…&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;// compile-time size of a range given its type&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
    </item>
    <item>
      <title>The new static constexpr std::integral_constant idiom</title>
      <link>https://www.foonathan.net/2023/08/static-constexpr-integral_constant/</link>
      <pubDate>Mon, 07 Aug 2023 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2023/08/static-constexpr-integral_constant/</guid>
      <description>&lt;p&gt;The size of &lt;code&gt;std::array&amp;lt;T, N&amp;gt;&lt;/code&gt; is known at compile-time given the type.&#xA;Yet it only provides a regular &lt;code&gt;.size()&lt;/code&gt; member function:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-cpp&#34; data-lang=&#34;cpp&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;template&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;typename&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;std&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;size_t&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;N&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;struct&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;array&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;constexpr&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;std&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;size_t&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;size&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;N&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This is annoying if you&amp;rsquo;re writing generic code that expects some sort of compile-time sized range.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Should we stop writing functions?</title>
      <link>https://www.foonathan.net/2023/07/stop-writing-functions/</link>
      <pubDate>Tue, 25 Jul 2023 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2023/07/stop-writing-functions/</guid>
      <description>&lt;p&gt;&amp;hellip; and use lambdas instead?&lt;/p&gt;&#xA;&lt;p&gt;That is, instead of:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-cpp&#34; data-lang=&#34;cpp&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;sum&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;a&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;b&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;a&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;b&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;You&amp;rsquo;d write:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-cpp&#34; data-lang=&#34;cpp&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;constexpr&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;auto&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;sum&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;[](&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;a&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;b&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;-&amp;gt;&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;a&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;b&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Hear me out.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Constrain your user-defined conversions</title>
      <link>https://www.foonathan.net/2023/07/constrain-user-defined-conversions/</link>
      <pubDate>Wed, 05 Jul 2023 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2023/07/constrain-user-defined-conversions/</guid>
      <description>&lt;p&gt;Sometimes you want to add an implicit conversion to a type.&#xA;This can be done by adding an implicit conversion operator.&#xA;For example, &lt;code&gt;std::string&lt;/code&gt; is implicitly convertible to &lt;code&gt;std::string_view&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-cpp&#34; data-lang=&#34;cpp&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;string&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;// template omitted for simplicity&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;public&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;:&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;operator&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;std&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;string_view&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;noexcept&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;       &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;std&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;string_view&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;c_str&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(),&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;size&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;());&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;};&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The conversion is safe, cheap, and &lt;code&gt;std::string&lt;/code&gt; and &lt;code&gt;std::string_view&lt;/code&gt; represent the same platonic value — we match &lt;a href=&#34;https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0705r0.html&#34;&gt;Tony van Eerd&amp;rsquo;s criteria for implicit conversions&lt;/a&gt; and using implicit conversions is justified.&lt;/p&gt;&#xA;&lt;p&gt;However, even when all criteria are fulfilled, the conversion can still be dangerous.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Trip report: Summer ISO C&#43;&#43; Meeting in Varna, Bulgaria</title>
      <link>https://www.foonathan.net/2023/06/trip-report-varna-2023/</link>
      <pubDate>Sat, 10 Jun 2023 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2023/06/trip-report-varna-2023/</guid>
      <description>&lt;p&gt;Last week, I attended the summer 2023 meeting of the ISO C++ standardization committee in Varna, Bulgaria. This was my first meeting since the pandemic and the first meeting as official member thanks to think-cell&amp;rsquo;s participation in the German national body. In total, 18 different countries sent representatives and over 180 C++ experts attended, although some of them only remotely.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Technique: Proof types to ensure preconditions</title>
      <link>https://www.foonathan.net/2022/11/proof-types/</link>
      <pubDate>Wed, 30 Nov 2022 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2022/11/proof-types/</guid>
      <description>&lt;p&gt;Consider a library using hidden global state that needs to be initialized by calling an initialization function.&#xA;If you don&amp;rsquo;t call the function before you start using the library, it crashes.&lt;/p&gt;&#xA;&lt;p&gt;How do you design the library in such a way that it is impossible to use it before initialization?&lt;/p&gt;&#xA;&lt;p&gt;One idea is to use a technique where you create a special &lt;em&gt;proof type&lt;/em&gt;, which needs to be passed as an additional parameter.&#xA;Let&amp;rsquo;s look at it in more detail.&lt;/p&gt;</description>
    </item>
    <item>
      <title>New integer types I&#39;d like to see</title>
      <link>https://www.foonathan.net/2022/09/new-integer-types/</link>
      <pubDate>Thu, 29 Sep 2022 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2022/09/new-integer-types/</guid>
      <description>&lt;p&gt;(Most) C++ implementations provide at least 8, 16, 32, and 64-bit signed and unsigned integer types.&#xA;There are annoying implicit conversions, discussions about undefined behavior on overflow (some think it&amp;rsquo;s too much UB, others think it&amp;rsquo;s not enough),&#xA;but for the most part they do the job well.&#xA;Newer languages like Rust copied that design, but fixed the conversions and overflow behavior.&lt;/p&gt;&#xA;&lt;p&gt;Still, I think there is room for innovation here.&#xA;Let me talk about three new families of integer types I&amp;rsquo;d like to see.&lt;/p&gt;</description>
    </item>
    <item>
      <title>malloc() and free() are a bad API</title>
      <link>https://www.foonathan.net/2022/08/malloc-interface/</link>
      <pubDate>Wed, 31 Aug 2022 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2022/08/malloc-interface/</guid>
      <description>&lt;p&gt;If you need to allocate dynamic memory in C, you use &lt;code&gt;malloc()&lt;/code&gt; and &lt;code&gt;free()&lt;/code&gt;.&#xA;The API is very old, and while you might want to switch to a different implementation,&#xA;be it &lt;a href=&#34;http://jemalloc.net/&#34;&gt;jemalloc&lt;/a&gt;, &lt;a href=&#34;https://github.com/google/tcmalloc&#34;&gt;tcmalloc&lt;/a&gt;, or &lt;a href=&#34;https://github.com/microsoft/mimalloc&#34;&gt;mimalloc&lt;/a&gt;,&#xA;they mostly copy the interface.&#xA;It makes sense that they do that &amp;ndash; they want to be a mostly drop-in replacement,&#xA;but it&amp;rsquo;s still unfortunate because &lt;code&gt;malloc()&lt;/code&gt; and &lt;code&gt;free()&lt;/code&gt; are a bad API for memory allocation.&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s talk why.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Carbon&#39;s most exciting feature is its calling convention</title>
      <link>https://www.foonathan.net/2022/07/carbon-calling-convention/</link>
      <pubDate>Fri, 29 Jul 2022 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2022/07/carbon-calling-convention/</guid>
      <description>&lt;p&gt;Last week, &lt;a href=&#34;https://github.com/carbon-language/carbon-lang&#34;&gt;Chandler Carruth announced Carbon&lt;/a&gt;, a potential C++ replacement they&amp;rsquo;ve been working on for the past two years.&#xA;It has the usual cool features you expect from a modern language: useful generics, compile-time interfaces/traits/concepts, modules, etc.&#xA;&amp;ndash; but the thing I&amp;rsquo;m most excited about is a tiny detail about the way parameters are passed there.&lt;/p&gt;&#xA;&lt;p&gt;It&amp;rsquo;s something I&amp;rsquo;ve been thinking about in the past myself, and to my knowledge it hasn&amp;rsquo;t been done in any low-level language before, but the concept has a lot of potential.&#xA;Let me explain what I&amp;rsquo;m talking about.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Tutorial: Preparing libraries for CMake FetchContent</title>
      <link>https://www.foonathan.net/2022/06/cmake-fetchcontent/</link>
      <pubDate>Wed, 29 Jun 2022 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2022/06/cmake-fetchcontent/</guid>
      <description>&lt;p&gt;If you&amp;rsquo;re working on an executable project in C++, as opposed to a C++ library, using a package manager to get your dependencies might be overkill:&#xA;If all you need is to get the source code of a library, include in your CMake project, and have it compiled from source with the rest of your project, CMake&amp;rsquo;s &lt;code&gt;FetchContent&lt;/code&gt; module can do it for you.&lt;/p&gt;&#xA;&lt;p&gt;If you&amp;rsquo;re a library writer, there are ways you can structure your CMake project to improve the experience for end users that use &lt;code&gt;FetchContent&lt;/code&gt;:&#xA;hide developer targets like tests, provide a zip archive that contains only the source files relevant downstream, and use GitHub actions to create it automatically.&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s see how.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Technique: Recursive variants and boxes</title>
      <link>https://www.foonathan.net/2022/05/recursive-variant-box/</link>
      <pubDate>Tue, 31 May 2022 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2022/05/recursive-variant-box/</guid>
      <description>&lt;p&gt;There are many data structures that can be elegantly expressed using sum types.&#xA;In C++ a (somewhat clunky) implementation of sum types is &lt;code&gt;std::variant&lt;/code&gt;.&#xA;However, it can&amp;rsquo;t handle recursive data structures, where one alternative contains the entire sum type again.&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s see how we can fix that.&lt;/p&gt;</description>
    </item>
    <item>
      <title>`saturating_add` vs. `saturating_int` -- new function vs. new type?</title>
      <link>https://www.foonathan.net/2022/03/behavior-function-type/</link>
      <pubDate>Wed, 30 Mar 2022 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2022/03/behavior-function-type/</guid>
      <description>&lt;p&gt;Suppose you want to do integer arithmetic that saturates instead of overflowing.&#xA;The built-in &lt;code&gt;operator+&lt;/code&gt; doesn&amp;rsquo;t behave that way, so you need to roll something yourself.&#xA;Do you write a &lt;code&gt;saturating_add()&lt;/code&gt; function or a new &lt;code&gt;saturating_int&lt;/code&gt; type with overloaded &lt;code&gt;operator+&lt;/code&gt;?&#xA;What about &lt;code&gt;atomic_load(x)&lt;/code&gt; vs. &lt;code&gt;atomic&amp;lt;int&amp;gt; x&lt;/code&gt;?&#xA;Or &lt;code&gt;volatile_store(ptr, value)&lt;/code&gt; vs. &lt;code&gt;volatile int*&lt;/code&gt;?&lt;/p&gt;&#xA;&lt;p&gt;When should you provide functions that implement new behavior and when should you write a wrapper type?&#xA;Let&amp;rsquo;s look at the pro and cons.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Technique: Compile Time Code Generation and Optimization</title>
      <link>https://www.foonathan.net/2022/01/compile-time-codegen/</link>
      <pubDate>Thu, 27 Jan 2022 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2022/01/compile-time-codegen/</guid>
      <description>&lt;p&gt;C++ &lt;code&gt;constexpr&lt;/code&gt; is really powerful.&#xA;In this blog post, we&amp;rsquo;ll write a compiler that can parse a Brainfuck program given as string literal,&#xA;and generate optimized assembly instructions that can then be executed at runtime.&#xA;The best part: we neither have to actually generate assembly nor optimize anything ourselves!&#xA;Instead we trick the compiler into doing all the hard work for us.&lt;/p&gt;&#xA;&lt;p&gt;The same technique can be used whenever you want to specify some sort of &amp;ldquo;program&amp;rdquo; in a different way and translate it at runtime:&#xA;regexes, routing tables, etc.&lt;/p&gt;</description>
    </item>
    <item>
      <title>I accidentally wrote a Turing-complete parsing library</title>
      <link>https://www.foonathan.net/2021/11/lexy-turing/</link>
      <pubDate>Thu, 25 Nov 2021 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2021/11/lexy-turing/</guid>
      <description>&lt;p&gt;I&amp;rsquo;m currently working on &lt;a href=&#34;https://github.com/foonathan/lexy&#34;&gt;lexy&lt;/a&gt;, a C++ parsing DSL library:&#xA;you describe &lt;a href=&#34;https://lexy.foonathan.net/reference/dsl/&#34;&gt;how input should be parsed&lt;/a&gt;, and lexy generates code for it, taking care of &lt;a href=&#34;https://lexy.foonathan.net/playground/?id=PnxhPMvEe&amp;amp;mode=trace&#34;&gt;error recovery&lt;/a&gt;, &lt;a href=&#34;https://lexy.foonathan.net/playground/?id=K9T7d1KGf&amp;amp;mode=tree&#34;&gt;parse tree generation&lt;/a&gt;, and &lt;a href=&#34;https://lexy.foonathan.net/reference/callback/&#34;&gt;parse values&lt;/a&gt;.&#xA;Such parser generators are classified based on the &lt;a href=&#34;https://en.wikipedia.org/wiki/Chomsky_hierarchy&#34;&gt;expressiveness of the corresponding formal language&lt;/a&gt;.&#xA;For example, a strict regular expression can only parse regular languages, which is a strict subset of a deterministic context free language, and so on.&lt;/p&gt;&#xA;&lt;p&gt;lexy, being essentially syntax sugar for a recursive descent parser with (manually specified!) arbitrary lookahead but no other state, falls in the latter category.&#xA;Parsers in that category are unable to parse context-sensitive languages such as XML with matching tags.&#xA;To handle them, I&amp;rsquo;ve added support for &amp;ldquo;context variables&amp;rdquo;: state that can be modified during parsing.&lt;/p&gt;&#xA;&lt;p&gt;However, in a recent refactoring of the context variables implementation, I&amp;rsquo;ve accidentally removed a big limitation, which makes lexy Turing-complete:&#xA;the parser is thus able to do arbitrary computation while parsing the input.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;TL;DR:&lt;/strong&gt; I&amp;rsquo;ve written a &lt;a href=&#34;https://github.com/foonathan/lexy/blob/main/examples/turing.cpp&#34;&gt;lexy grammar&lt;/a&gt; that is able to &lt;em&gt;execute&lt;/em&gt;, not just &lt;em&gt;parse&lt;/em&gt;, a simple Turing-complete language.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Tutorial: the CRTP Interface Technique</title>
      <link>https://www.foonathan.net/2021/10/crtp-interface/</link>
      <pubDate>Tue, 12 Oct 2021 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2021/10/crtp-interface/</guid>
      <description>&lt;p&gt;Generic code expects that your types model certain concepts.&#xA;Sometimes, the concept requires many redundant member functions in your type.&#xA;A big culprit here are iterators:&#xA;they require many operator overloads, most of which are trivially implemented in terms of other overloads.&lt;/p&gt;&#xA;&lt;p&gt;CRTP, the curiously recurring template pattern, can help here and automate the boilerplate away.&#xA;Let&amp;rsquo;s look at the CRTP interface technique and explore how it works.&lt;/p&gt;</description>
    </item>
    <item>
      <title>C&#43;&#43;20 concepts are structural: What, why, and how to change it?</title>
      <link>https://www.foonathan.net/2021/07/concepts-structural-nominal/</link>
      <pubDate>Thu, 29 Jul 2021 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2021/07/concepts-structural-nominal/</guid>
      <description>&lt;p&gt;C++20 added concepts as a language feature.&#xA;&lt;a href=&#34;https://stackoverflow.com/questions/32124627/how-are-c-concepts-different-to-haskell-typeclasses&#34;&gt;They&amp;rsquo;re&lt;/a&gt; &lt;a href=&#34;https://stackoverflow.com/questions/56045846/what-are-the-similarities-and-differences-between-cs-concepts-and-rusts-trai&#34;&gt;often&lt;/a&gt; &lt;a href=&#34;https://www.youtube.com/watch?v=Qh7QdG5RK9E&#34;&gt;compared&lt;/a&gt; to Haskell&amp;rsquo;s &lt;a href=&#34;https://en.wikibooks.org/wiki/Haskell/Classes_and_types&#34;&gt;type classes&lt;/a&gt;, Rust&amp;rsquo;s &lt;a href=&#34;https://doc.rust-lang.org/book/ch10-02-traits.html&#34;&gt;traits&lt;/a&gt; or Swift&amp;rsquo;s &lt;a href=&#34;https://docs.swift.org/swift-book/LanguageGuide/Protocols.html&#34;&gt;protocols&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Yet there is one feature that sets them apart: types model C++ concepts automatically.&#xA;In Haskell, you need an &lt;code&gt;instance&lt;/code&gt;, in Rust, you need an &lt;code&gt;impl&lt;/code&gt;, and in Swift, you need an &lt;code&gt;extension&lt;/code&gt;.&#xA;But in C++? In C++, concepts are just fancy boolean predicates that check for well-formed syntax:&#xA;every type that makes the syntax well-formed passes the predicate and thus models the concepts.&lt;/p&gt;&#xA;&lt;p&gt;This was the correct choice, but is sometimes not what you want.&#xA;Let&amp;rsquo;s explore it further.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Tutorial: Interactive code snippets with Hugo and Compiler Explorer</title>
      <link>https://www.foonathan.net/2021/05/hugo-godbolt/</link>
      <pubDate>Mon, 31 May 2021 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2021/05/hugo-godbolt/</guid>
      <description>&lt;p&gt;I&amp;rsquo;m currently rewriting the documentation for &lt;a href=&#34;https://github.com/foonathan/lexy&#34;&gt;lexy&lt;/a&gt;, my C++ parser combinator library &amp;ndash; hey, this is the fourth blog post in a row mentioning it in the introduction!&#xA;It already has an &lt;a href=&#34;https://lexy.foonathan.net/playground/&#34;&gt;interactive online playground&lt;/a&gt; where you can enter a grammar and input and see the resulting parse tree and/or error messages.&#xA;This is really helpful, so the new documentation will contain examples that are directly available in the playground, to try it out and see what happens.&lt;/p&gt;&#xA;&lt;p&gt;While implementing this, I&amp;rsquo;ve realized that this can also be extended to ordinary code snippets on my blog.&#xA;Without any Javascript or manual work on my part, I can give the code snippet a &amp;ldquo;play button&amp;rdquo; that directly links to &lt;a href=&#34;https://godbolt.org/&#34;&gt;Compiler Explorer&lt;/a&gt;, like this:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Implementation Challenge: Lossless, compact parse tree with iterative traversal</title>
      <link>https://www.foonathan.net/2021/04/parse_tree/</link>
      <pubDate>Wed, 28 Apr 2021 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2021/04/parse_tree/</guid>
      <description>&lt;p&gt;My parser combinator library &lt;a href=&#34;https://github.com/foonathan/lexy&#34;&gt;lexy&lt;/a&gt; was originally designed to parse some grammar into a user-defined data structure, comparable to &lt;a href=&#34;https://boost-spirit.com/home/&#34;&gt;Boost.Spirit&lt;/a&gt;.&#xA;This is ideal for parsing simple &amp;ldquo;data&amp;rdquo; grammars like &lt;a href=&#34;https://github.com/foonathan/lexy/blob/main/examples/json.cpp&#34;&gt;JSON&lt;/a&gt; or &lt;a href=&#34;https://github.com/foonathan/lexy/blob/main/examples/email.cpp&#34;&gt;email addresses&lt;/a&gt;, and also works for parsing programming languages: simply parse into your AST.&#xA;However, by design &lt;code&gt;lexy::parse()&lt;/code&gt; will only forward data explicitly produced by the parsing combinators which does not include punctuation, comments, or whitespace.&lt;/p&gt;&#xA;&lt;p&gt;Inspired by &lt;a href=&#34;https://github.com/matklad&#34;&gt;matklad&amp;rsquo;s&lt;/a&gt; blog post about &lt;a href=&#34;https://matklad.github.io/2018/06/06/modern-parser-generator.html&#34;&gt;modern parser generators&lt;/a&gt;, I&amp;rsquo;ve decided to add a way to retain all the information and produce a lossless parse tree by calling &lt;code&gt;lexy::parse_as_tree()&lt;/code&gt;.&#xA;This requires no changes to your existing grammar and simply switches the output.&#xA;With that, I could also add an &lt;a href=&#34;https://lexy.foonathan.net/playground/&#34;&gt;online playground&lt;/a&gt; that visualizes the parse tree of a given grammar on the given input.&lt;/p&gt;&#xA;&lt;p&gt;Implementing the actual code that produces a parse tree during parsing wasn&amp;rsquo;t too hard &amp;ndash; I&amp;rsquo;ve already had a handler that controls what happens during parsing to implement &lt;a href=&#34;https://lexy.foonathan.net/reference/#_matching&#34;&gt;&lt;code&gt;lexy::match()&lt;/code&gt;&lt;/a&gt; and &lt;a href=&#34;https://lexy.foonathan.net/reference/#_validating&#34;&gt;&lt;code&gt;lexy::validate()&lt;/code&gt;&lt;/a&gt;.&#xA;The challenging part was the actual data structure for storing a parse tree:&#xA;it should be memory-efficient, as it can be big, and users should be able to easily iterate over every node without requiring recursion.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Trivially copyable does not mean trivially copy constructible</title>
      <link>https://www.foonathan.net/2021/03/trivially-copyable/</link>
      <pubDate>Thu, 25 Mar 2021 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2021/03/trivially-copyable/</guid>
      <description>&lt;p&gt;About a month ago, I got an &lt;a href=&#34;https://github.com/foonathan/lexy/pull/17&#34;&gt;interesting pull request&lt;/a&gt; for &lt;a href=&#34;https://github.com/foonathan/lexy&#34;&gt;lexy&lt;/a&gt;, my new parser combinator library.&#xA;It fixed a seemingly weird issue relating trivially copyable types and special member function of classes containing unions.&#xA;While digging into it, I learned a lot about trivial special member functions and made a somewhat surprising realization:&lt;/p&gt;&#xA;&lt;p&gt;Just because a class is &lt;code&gt;std::is_trivially_copyable&lt;/code&gt; does not mean the class is actually &lt;code&gt;std::is_trivially_copy_constructible&lt;/code&gt; or even &lt;code&gt;std::is_copy_constructible&lt;/code&gt;:&#xA;you can have classes that you can&amp;rsquo;t copy, but they&amp;rsquo;re still trivially copyable,&#xA;and classes where the copy constructor can do arbitrary amounts of non-trivial work, but they&amp;rsquo;re nonetheless trivially copyable!&lt;/p&gt;&#xA;&lt;p&gt;Let me explain.&lt;/p&gt;</description>
    </item>
    <item>
      <title>What is the unit of a text column number?</title>
      <link>https://www.foonathan.net/2021/02/column/</link>
      <pubDate>Wed, 17 Feb 2021 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2021/02/column/</guid>
      <description>&lt;p&gt;I&amp;rsquo;ve recently published my parsing combinator library &lt;a href=&#34;https://github.com/foonathan/lexy&#34;&gt;lexy&lt;/a&gt;.&#xA;One of the things it does is issue a &lt;code&gt;lexy::error&lt;/code&gt; if the input does not match the grammar.&#xA;This error has a &lt;code&gt;.position()&lt;/code&gt; which gives you the position where the error occurred.&lt;/p&gt;&#xA;&lt;p&gt;In order to keep the happy path fast, &lt;code&gt;.position()&lt;/code&gt; is not something that is easy to use for end users:&#xA;it is simply an iterator into the input range.&#xA;This is no good to a human user who wants something like line and column number to easily locate the problematic input.&lt;/p&gt;&#xA;&lt;p&gt;Converting an iterator into line/column location seems simple enough:&#xA;set &lt;code&gt;line = column = 1&lt;/code&gt; and iterate over the entire input until you&amp;rsquo;ve reached the position of the iterator.&#xA;Every time you see a newline, increment the line number and set the column number back to &lt;code&gt;1&lt;/code&gt;.&#xA;Otherwise, the column is implemented every time you &amp;hellip; see what exactly?&lt;/p&gt;&#xA;&lt;p&gt;What exactly is a &amp;ldquo;column&amp;rdquo; of a text and how do I compute it?&lt;/p&gt;</description>
    </item>
    <item>
      <title>Tricks with Default Template Arguments</title>
      <link>https://www.foonathan.net/2020/10/tricks-default-template-argument/</link>
      <pubDate>Tue, 27 Oct 2020 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2020/10/tricks-default-template-argument/</guid>
      <description>&lt;p&gt;Just like regular function parameters, template parameters can also have default parameters.&#xA;For class templates, this behaves mostly just like default function arguments:&#xA;if you pass fewer template arguments than required, default template arguments are used to fill the remaining places.&#xA;However, for function templates, it gets more complicated as template parameters for functions can be deduced by the normal function arguments.&#xA;This leads to some interesting side-effects.&#xA;In particular, default arguments of template parameters don&amp;rsquo;t need to be put at the end!&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s take a look at a couple of things we can do with default template arguments.&lt;/p&gt;</description>
    </item>
    <item>
      <title>`constexpr` is a Platform</title>
      <link>https://www.foonathan.net/2020/10/constexpr-platform/</link>
      <pubDate>Mon, 19 Oct 2020 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2020/10/constexpr-platform/</guid>
      <description>&lt;p&gt;Let me share a useful insight with you: &lt;code&gt;constexpr&lt;/code&gt; is a platform.&lt;/p&gt;&#xA;&lt;p&gt;Just like you write code that targets Windows or a microcontroller,&#xA;you write code that targets compile-time execution.&#xA;In both cases you restrict yourself to the subset of C++ that works on your target platform,&#xA;use conditional compilation if your code needs to be portable,&#xA;and execute it on the desired target platform.&#xA;You can thus view &lt;code&gt;constexpr&lt;/code&gt; as another platform you can target;&#xA;it just so happens to be run by your compiler.&lt;/p&gt;&#xA;&lt;p&gt;This insight can answer a lot of design questions surrounding &lt;code&gt;constexpr&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Technique: Immediately-Invoked Function Expression for Metaprogramming</title>
      <link>https://www.foonathan.net/2020/10/iife-metaprogramming/</link>
      <pubDate>Fri, 02 Oct 2020 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2020/10/iife-metaprogramming/</guid>
      <description>&lt;p&gt;Common C++ guidelines are to initialize variables on use and to make variables &lt;code&gt;const&lt;/code&gt; whenever possible.&#xA;But sometimes a variable is unchanged once initialized and the initialization is complex, like involving a loop.&#xA;Then an &lt;a href=&#34;https://www.bfilipek.com/2016/11/iife-for-complex-initialization.html&#34;&gt;IIFE&lt;/a&gt; &amp;ndash; immediately-invoked function expression &amp;ndash; can be used: the variable is initialized by a lambda that computes the value, which is then immediately invoked to produce the value.&#xA;Then the variable is initialized on use and can also be made &lt;code&gt;const&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;ve been recently working on a meta-programming library where I found IIFEs useful in a slightly different context &amp;ndash; computing type information.&lt;/p&gt;&#xA;&lt;p&gt;TL;DR: &lt;code&gt;decltype([] { ... } ())&lt;/code&gt;!&lt;/p&gt;</description>
    </item>
    <item>
      <title>Implementation Challenge: Replacing std::move and std::forward</title>
      <link>https://www.foonathan.net/2020/09/move-forward/</link>
      <pubDate>Tue, 22 Sep 2020 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2020/09/move-forward/</guid>
      <description>&lt;p&gt;When C++11 introduced move semantics, it also added two important helper functions: &lt;code&gt;std::move&lt;/code&gt; and &lt;code&gt;std::forward&lt;/code&gt;.&#xA;They are essential when you want to manually indicate that you no longer care about an object or need to propagate the value category in generic code.&#xA;As such, I&amp;rsquo;ve used them countless times in the past.&lt;/p&gt;&#xA;&lt;p&gt;However, they are &lt;em&gt;functions&lt;/em&gt;. Plain, old, standard library functions.&lt;/p&gt;&#xA;&lt;p&gt;This is problematic for multiple reasons.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Nifty Fold Expression Tricks</title>
      <link>https://www.foonathan.net/2020/05/fold-tricks/</link>
      <pubDate>Tue, 05 May 2020 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2020/05/fold-tricks/</guid>
      <description>&lt;p&gt;Suppose you need to have a variadic function and want to add all arguments together.&#xA;Before C++17, you need two pseudo-recursive functions:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-cpp&#34; data-lang=&#34;cpp&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;template&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;typename&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;H&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;typename&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;...&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;auto&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;add&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;H&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;head&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;...&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;tail&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;head&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;add&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;tail&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;...);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;template&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;typename&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;H&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;auto&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;add&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;H&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;head&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;head&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;However, C++17 added &lt;a href=&#34;https://en.cppreference.com/w/cpp/language/fold&#34;&gt;fold expressions&lt;/a&gt;, making it a one-liner:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-cpp&#34; data-lang=&#34;cpp&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;template&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;typename&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;H&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;typename&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;...&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;auto&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;add&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;H&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;head&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;T&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;...&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;tail&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;head&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;...&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;tail&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;// expands to: head + tail[0] + tail[1] + ...&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If we&amp;rsquo;re willing to abuse operator evaluation rules and fold expressions, we can do a lot more.&#xA;This blog posts collects useful tricks.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Tutorial: C&#43;&#43;20&#39;s Iterator Sentinels</title>
      <link>https://www.foonathan.net/2020/03/iterator-sentinel/</link>
      <pubDate>Wed, 25 Mar 2020 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2020/03/iterator-sentinel/</guid>
      <description>&lt;p&gt;You probably know that C++20 adds ranges.&#xA;Finally we can write &lt;code&gt;copy(container, dest)&lt;/code&gt; instead of &lt;code&gt;copy(container.begin(), container.end(), dest)&lt;/code&gt;!&lt;/p&gt;&#xA;&lt;p&gt;Ranges also do a lot more.&#xA;Among other things, they add a new way of specifying an iterator to the end &amp;ndash; sentinels.&lt;/p&gt;</description>
    </item>
    <item>
      <title>std::polymorphic_value &#43; Duck Typing = Type Erasure</title>
      <link>https://www.foonathan.net/2020/01/type-erasure/</link>
      <pubDate>Fri, 17 Jan 2020 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2020/01/type-erasure/</guid>
      <description>&lt;p&gt;I recently had an insight about &lt;a href=&#34;https://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Type_Erasure&#34;&gt;type erasure&lt;/a&gt; that I wanted to share.&#xA;Type erasure is a combination of two techniques working together to achieve both polymorphism and value semantics:&#xA;&lt;code&gt;std::polymorphic_value&lt;/code&gt;, a proposed standard library type, and duck typing.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Naming Things: Implementer vs. User Names</title>
      <link>https://www.foonathan.net/2019/11/implementer-vs-user-names/</link>
      <pubDate>Wed, 27 Nov 2019 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2019/11/implementer-vs-user-names/</guid>
      <description>&lt;p&gt;I wanted to write this blog post about (a specific part of) naming things back in July, but ironically I didn&amp;rsquo;t have a name for the symptom I wanted to describe.&#xA;I only found a good name when I attended &lt;a href=&#34;https://www.youtube.com/watch?v=MBRoCdtZOYg&#34;&gt;Kate Gregory&amp;rsquo;s talk on naming&lt;/a&gt; at CppCon, and now I finally have the time to write my thoughts down.&lt;/p&gt;&#xA;&lt;p&gt;So I want to write about naming.&#xA;In particular, about the phenomenon that sometimes a name is a perfect description of what a function does, yet it is totally useless.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Standardese Documentation Generator: Post Mortem and My Open-Source Future</title>
      <link>https://www.foonathan.net/2019/11/standardese-post-mortem/</link>
      <pubDate>Tue, 05 Nov 2019 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2019/11/standardese-post-mortem/</guid>
      <description>&lt;p&gt;Back in 2016, I started &lt;a href=&#34;https://github.com/standardese/standardese&#34;&gt;standardese&lt;/a&gt;, a C++ documentation generator.&#xA;However, in the past two years I haven&amp;rsquo;t really worked on it.&lt;/p&gt;&#xA;&lt;p&gt;Now, I can officially announce that I have abandoned the project and transferred ownership.&#xA;This blog post explains why.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Tutorial: When to Write Which Special Member</title>
      <link>https://www.foonathan.net/2019/02/special-member-functions/</link>
      <pubDate>Tue, 26 Feb 2019 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2019/02/special-member-functions/</guid>
      <description>&lt;p&gt;When explaining someone the rules behind the special member functions and when you need to write which one, there is this diagram that is always brought up.&#xA;I don&amp;rsquo;t think the diagram is particularly useful for that, however.&lt;/p&gt;&#xA;&lt;p&gt;It covers way more combinations than actually make sense.&#xA;So let&amp;rsquo;s talk about what you actually need to know about the special member functions and when you should write which combination.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Nested Optionals, Expected and Composition</title>
      <link>https://www.foonathan.net/2018/12/nested-optionals-expected/</link>
      <pubDate>Tue, 11 Dec 2018 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2018/12/nested-optionals-expected/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://akrzemi1.wordpress.com/2018/12/09/deducing-your-intentions/&#34;&gt;Andrzej wrote about problems with CTAD and nested optionals&lt;/a&gt;, then &lt;a href=&#34;https://brevzin.github.io/c++/2018/12/09/mixed-comparisons/&#34;&gt;Barry wrote about problems with comparison and nested optionals&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;What do both problems have in common?&lt;/p&gt;&#xA;&lt;p&gt;Nested optionals.&lt;/p&gt;&#xA;&lt;p&gt;So let&amp;rsquo;s talk about them: What do they actually mean?&lt;/p&gt;</description>
    </item>
    <item>
      <title>Inline Namespaces 101</title>
      <link>https://www.foonathan.net/2018/11/inline-namespaces/</link>
      <pubDate>Thu, 22 Nov 2018 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2018/11/inline-namespaces/</guid>
      <description>&lt;p&gt;Almost three years ago — wow, how time flies — I blogged about &lt;a href=&#34;https://www.foonathan.net/blog/2016/01/26/namespace-alias.html&#34;&gt;namespace aliases&lt;/a&gt; and called them one of C++ most underrated features (which probably was a bit of a click bait).&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s talk about some other namespace feature, that is, well, not quite underrated, but relatively obscure:&#xA;&lt;code&gt;inline&lt;/code&gt; namespace.&#xA;They are namespaces that don&amp;rsquo;t really introduce a scope, except when they do.&lt;/p&gt;&#xA;&lt;p&gt;So what can you do with them?&lt;/p&gt;</description>
    </item>
    <item>
      <title>Tutorial: Managing Compiler Warnings with CMake</title>
      <link>https://www.foonathan.net/2018/10/cmake-warnings/</link>
      <pubDate>Wed, 17 Oct 2018 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2018/10/cmake-warnings/</guid>
      <description>&lt;p&gt;Warnings are important, especially in C++.&lt;/p&gt;&#xA;&lt;p&gt;C++ compilers are forced to accept a lot of stupid code, like functions without &lt;code&gt;return&lt;/code&gt;, use of uninitialized warnings, etc.&#xA;But they can at least issue a warning if you do such things.&lt;/p&gt;&#xA;&lt;p&gt;But how do you manage the very compiler-specific flags in CMake?&lt;/p&gt;&#xA;&lt;p&gt;How do you prevent your header files from leaking warnings into other projects?&lt;/p&gt;</description>
    </item>
    <item>
      <title>Proposals to Fix the Spaceship Operator</title>
      <link>https://www.foonathan.net/2018/10/spaceship-proposals/</link>
      <pubDate>Sat, 13 Oct 2018 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2018/10/spaceship-proposals/</guid>
      <description>&lt;p&gt;I did a &lt;a href=&#34;https://www.foonathan.net/blog/2018/06/20/equivalence-relations.html&#34;&gt;series about comparisons&lt;/a&gt; recently where I gave some guidelines about using the upcoming &lt;a href=&#34;https://blog.tartanllama.xyz/spaceship-operator/&#34;&gt;spaceship operator&lt;/a&gt; for three-way comparison.&#xA;In particular, I pointed out a couple of flaws with the design as it is currently.&lt;/p&gt;&#xA;&lt;p&gt;Well, now the proposals for the next C++ standardization meeting are &lt;a href=&#34;http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/#mailing2018-10&#34;&gt;here&lt;/a&gt; — almost 300 of them.&#xA;And I&amp;rsquo;ve counted eleven of them that deal with the spaceship operator.&lt;/p&gt;&#xA;&lt;p&gt;So let&amp;rsquo;s take a look and them and see whether they&amp;rsquo;ll fix any of the issues I&amp;rsquo;ve pointed out.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Mathematics behind Comparison #5: Ordering Algorithms</title>
      <link>https://www.foonathan.net/2018/10/ordering-algorithms/</link>
      <pubDate>Mon, 01 Oct 2018 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2018/10/ordering-algorithms/</guid>
      <description>&lt;p&gt;In order to sort a collection of elements you need to provide a sorting predicate that determines when one element is less than the other.&#xA;This predicate must &amp;ldquo;induce a strict total ordering on the equivalence classes&amp;rdquo; according to &lt;a href=&#34;http://en.cppreference.com/w/cpp/named_req/Compare&#34;&gt;cppreference&lt;/a&gt;.&#xA;Wait, what?&lt;/p&gt;&#xA;&lt;p&gt;The upcoming C++ &lt;a href=&#34;http://wg21.link/p0515&#34;&gt;spaceship operator&lt;/a&gt; implements a three-way comparison,&#xA;i.e. it is a single function that can return the results of &lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;==&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt; combined.&#xA;But related to it are terms like &amp;ldquo;strong equality&amp;rdquo; and &amp;ldquo;weak ordering&amp;rdquo; which are somewhat confusing if you don&amp;rsquo;t have the mathematical background.&lt;/p&gt;&#xA;&lt;p&gt;So let&amp;rsquo;s untangle it:&#xA;This series will explain both the mathematics behind equality and ordering,&#xA;as well as give concrete guidelines for implementing the comparison operators and the spaceship operator.&lt;/p&gt;&#xA;&lt;p&gt;To finish this series let&amp;rsquo;s talk about algorithms that require an ordering and how they can be implemented using three-way comparison.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Mathematics behind Comparison #4: Three-Way Comparison</title>
      <link>https://www.foonathan.net/2018/09/three-way-comparison/</link>
      <pubDate>Fri, 07 Sep 2018 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2018/09/three-way-comparison/</guid>
      <description>&lt;p&gt;In order to sort a collection of elements you need to provide a sorting predicate that determines when one element is less than the other.&#xA;This predicate must &amp;ldquo;induce a strict total ordering on the equivalence classes&amp;rdquo; according to &lt;a href=&#34;http://en.cppreference.com/w/cpp/named_req/Compare&#34;&gt;cppreference&lt;/a&gt;.&#xA;Wait, what?&lt;/p&gt;&#xA;&lt;p&gt;The upcoming C++ &lt;a href=&#34;http://wg21.link/p0515&#34;&gt;spaceship operator&lt;/a&gt; implements a three-way comparison,&#xA;i.e. it is a single function that can return the results of &lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;==&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt; combined.&#xA;But related to it are terms like &amp;ldquo;strong equality&amp;rdquo; and &amp;ldquo;weak ordering&amp;rdquo; which are somewhat confusing if you don&amp;rsquo;t have the mathematical background.&lt;/p&gt;&#xA;&lt;p&gt;So let&amp;rsquo;s untangle it:&#xA;This series will explain both the mathematics behind equality and ordering,&#xA;as well as give concrete guidelines for implementing the comparison operators and the spaceship operator.&lt;/p&gt;&#xA;&lt;p&gt;Now that we&amp;rsquo;ve covered both equivalence and ordering relations we can finally talk about the spaceship operator and three-way comparisons.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Mathematics behind Comparison #3: Ordering Relations in C&#43;&#43;</title>
      <link>https://www.foonathan.net/2018/07/ordering-relations-programming/</link>
      <pubDate>Thu, 19 Jul 2018 00:00:01 +0000</pubDate>
      <guid>https://www.foonathan.net/2018/07/ordering-relations-programming/</guid>
      <description>&lt;p&gt;In order to sort a collection of elements you need to provide a sorting predicate that determines when one element is less than the other.&#xA;This predicate must &amp;ldquo;induce a strict total ordering on the equivalence classes&amp;rdquo; according to &lt;a href=&#34;http://en.cppreference.com/w/cpp/named_req/Compare&#34;&gt;cppreference&lt;/a&gt;.&#xA;Wait, what?&lt;/p&gt;&#xA;&lt;p&gt;The upcoming C++ &lt;a href=&#34;http://wg21.link/p0515&#34;&gt;spaceship operator&lt;/a&gt; implements a three way comparison,&#xA;i.e. it is a single function that can return the results of &lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;==&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt; combined.&#xA;But related to it are terms like &amp;ldquo;strong equality&amp;rdquo; and &amp;ldquo;weak ordering&amp;rdquo; which are somewhat confusing if you don&amp;rsquo;t have the mathematical background.&lt;/p&gt;&#xA;&lt;p&gt;So let&amp;rsquo;s untangle it:&#xA;This series will explain both the mathematics behind equality and ordering,&#xA;as well as give concrete guidelines for implementing the comparison operators and the spaceship operator.&lt;/p&gt;&#xA;&lt;p&gt;The previous part was very math heavy but necessary:&#xA;It introduced the mathematical terminology for ordering relations.&#xA;With that done we can finally talk about how it applies to C++.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Mathematics behind Comparison #2: Ordering Relations in Math</title>
      <link>https://www.foonathan.net/2018/07/ordering-relations-math/</link>
      <pubDate>Thu, 19 Jul 2018 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2018/07/ordering-relations-math/</guid>
      <description>&lt;p&gt;In order to sort a collection of elements you need to provide a sorting predicate that determines when one element is less than the other.&#xA;This predicate must &amp;ldquo;induce a strict total ordering on the equivalence classes&amp;rdquo; according to &lt;a href=&#34;http://en.cppreference.com/w/cpp/named_req/Compare&#34;&gt;cppreference&lt;/a&gt;.&#xA;Wait, what?&lt;/p&gt;&#xA;&lt;p&gt;The upcoming C++ &lt;a href=&#34;http://wg21.link/p0515&#34;&gt;spaceship operator&lt;/a&gt; implements a three way comparison,&#xA;i.e. it is a single function that can return the results of &lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;==&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt; combined.&#xA;But related to it are terms like &amp;ldquo;strong equality&amp;rdquo; and &amp;ldquo;weak ordering&amp;rdquo; which are somewhat confusing if you don&amp;rsquo;t have the mathematical background.&lt;/p&gt;&#xA;&lt;p&gt;So let&amp;rsquo;s untangle it:&#xA;This series will explain both the mathematics behind equality and ordering,&#xA;as well as give concrete guidelines for implementing the comparison operators and the spaceship operator.&lt;/p&gt;&#xA;&lt;p&gt;This part covers the mathematics behind ordering relations.&#xA;They are a lot more complicated than equivalence relations we&amp;rsquo;ve looked at before.&#xA;As my blog posts are usually long anyway, I&amp;rsquo;ve decided to split it into two.&#xA;So this part is only about the mathematics while the next part—already published—is about how they should be implemented in C++.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Let&#39;s Talk about std::optional&lt;T&amp;&gt; and optional references</title>
      <link>https://www.foonathan.net/2018/07/optional-reference/</link>
      <pubDate>Thu, 12 Jul 2018 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2018/07/optional-reference/</guid>
      <description>&lt;p&gt;This should have been part 2 of my &lt;a href=&#34;https://www.foonathan.net/blog/2018/06/20/equivalence-relations.html&#34;&gt;comparison series&lt;/a&gt;,&#xA;and I have almost finished it, but due to university stuff I just haven&amp;rsquo;t found the time to polish it.&lt;/p&gt;&#xA;&lt;p&gt;But the optional discussion started again, so I just wanted to &lt;em&gt;really&lt;/em&gt; quickly share my raw thoughts on the topic.&#xA;In case you are lucky and don&amp;rsquo;t know what I mean:&#xA;&lt;code&gt;std::optional&amp;lt;T&amp;amp;&amp;gt;&lt;/code&gt; doesn&amp;rsquo;t compile right now, because the behavior of assignment wasn&amp;rsquo;t clear (even though it actually is).&#xA;There are basically four questions in the discussion I want to answer:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;Is &lt;code&gt;std::optional&amp;lt;T&amp;amp;&amp;gt;&lt;/code&gt; the same as a pointer?&lt;/li&gt;&#xA;&lt;li&gt;Do we need &lt;code&gt;std::optional&amp;lt;T&amp;amp;&amp;gt;&lt;/code&gt;?&lt;/li&gt;&#xA;&lt;li&gt;Should the assignment operator rebind or assign through?&lt;/li&gt;&#xA;&lt;li&gt;Should it even have an assignment operator?&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;tl;dr: no, I don&amp;rsquo;t, rebind, no.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Mathematics behind Comparison #1: Equality and Equivalence Relations</title>
      <link>https://www.foonathan.net/2018/06/equivalence-relations/</link>
      <pubDate>Wed, 20 Jun 2018 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2018/06/equivalence-relations/</guid>
      <description>&lt;p&gt;In order to sort a collection of elements you need to provide a sorting predicate that determines when one element is less than the other.&#xA;This predicate must &amp;ldquo;induce a strict total ordering on the equivalence classes&amp;rdquo; according to &lt;a href=&#34;http://en.cppreference.com/w/cpp/named_req/Compare&#34;&gt;cppreference&lt;/a&gt;.&#xA;Wait, what?&lt;/p&gt;&#xA;&lt;p&gt;The upcoming C++ &lt;a href=&#34;http://wg21.link/p0515&#34;&gt;spaceship operator&lt;/a&gt; implements a three way comparison,&#xA;i.e. it is a single function that can return the results of &lt;code&gt;&amp;lt;&lt;/code&gt;, &lt;code&gt;==&lt;/code&gt; and &lt;code&gt;&amp;gt;&lt;/code&gt; combined.&#xA;But related to it are terms like &amp;ldquo;strong equality&amp;rdquo; and &amp;ldquo;weak ordering&amp;rdquo; which are somewhat confusing if you don&amp;rsquo;t have the mathematical background.&lt;/p&gt;&#xA;&lt;p&gt;So let&amp;rsquo;s untangle it:&#xA;This series will explain both the mathematics behind equality and ordering,&#xA;as well as give concrete guidelines for implementing the comparison operators and the spaceship operator.&lt;/p&gt;&#xA;&lt;p&gt;This part covers equality and equivalence relations.&#xA;What does it mean for two objects to be equal?&#xA;What are the mathematical properties and C++ semantics it needs to fulfill?&#xA;How do I implement proper equality comparison in C++?&lt;/p&gt;&#xA;&lt;p&gt;In the following parts we&amp;rsquo;ll look at ordering relations, the new three way comparison and algorithms like sorting and searching on various orderings.&lt;/p&gt;</description>
    </item>
    <item>
      <title>A (Better) Taxonomy of Pointers</title>
      <link>https://www.foonathan.net/2018/06/pointer-taxonomy/</link>
      <pubDate>Fri, 01 Jun 2018 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2018/06/pointer-taxonomy/</guid>
      <description>&lt;p&gt;At &lt;a href=&#34;http://cppnow.org/&#34;&gt;C++Now 2018&lt;/a&gt; I gave a talk about rethinking pointers: &lt;a href=&#34;https://jonathanmueller.dev/talk/cppnow2018&#34;&gt;jonathanmueller.dev/talk/cppnow2018&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;I highly recommend you check it out, even if you watched the similar talk I gave at ACCU,&#xA;as that version is a lot better.&#xA;It rediscovers and discusses the common guidelines about when to use references over pointers,&#xA;when smart pointers, etc.&lt;/p&gt;&#xA;&lt;p&gt;If you&amp;rsquo;re an expert, you might get a deeper meaning from the structured analysis.&#xA;And if you&amp;rsquo;re a beginner, you get the condensed guidelines.&lt;/p&gt;&#xA;&lt;p&gt;However, I think the most valuable thing is the taxonomy of pointer types.&#xA;It gives new vocabulary when talking about &lt;code&gt;T*&lt;/code&gt; vs &lt;code&gt;std::optional&amp;lt;T&amp;amp;&amp;gt;&lt;/code&gt; which gives the whole discussion an obvious answer.&lt;/p&gt;&#xA;&lt;p&gt;And here is also the big problem: Naming is hard.&lt;/p&gt;&#xA;&lt;p&gt;In particular, my naming of the taxonomy in the talk is bad, so let&amp;rsquo;s introduce new names.&lt;/p&gt;</description>
    </item>
    <item>
      <title>optional&lt;T&gt; in Containers Ⅱ — Not All std::vector Usages Are The Same</title>
      <link>https://www.foonathan.net/2018/04/optional-container-followup/</link>
      <pubDate>Tue, 17 Apr 2018 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2018/04/optional-container-followup/</guid>
      <description>&lt;p&gt;Okay, so in the &lt;a href=&#34;https://www.foonathan.net/blog/2018/04/09/optional-in-container.html&#34;&gt;previous post&lt;/a&gt; I talked about putting &lt;code&gt;optional&amp;lt;T&amp;gt;&lt;/code&gt; in container.&#xA;I came to conclusions which I though were reasonable at the time, however, people — rightfully — pointed out some flaws in my argumentation.&lt;/p&gt;&#xA;&lt;p&gt;As I was at ACCU last week, I wasn&amp;rsquo;t able to respond to them earlier (note to self: don&amp;rsquo;t publish and then fly away to a conference),&#xA;so I&amp;rsquo;m doing that now.&#xA;Let&amp;rsquo;s revisit my argumentations and see where I was wrong.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Should You Put optional&lt;T&gt; in a Container?</title>
      <link>https://www.foonathan.net/2018/04/optional-in-container/</link>
      <pubDate>Mon, 09 Apr 2018 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2018/04/optional-in-container/</guid>
      <description>&lt;p&gt;Title says it all: should you put &lt;code&gt;std::optional&amp;lt;T&amp;gt;&lt;/code&gt; in a container?&lt;/p&gt;&#xA;&lt;p&gt;To answer that we have to take a slight detour first.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Guidelines For Rvalue References In APIs</title>
      <link>https://www.foonathan.net/2018/03/rvalue-references-api-guidelines/</link>
      <pubDate>Mon, 26 Mar 2018 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2018/03/rvalue-references-api-guidelines/</guid>
      <description>&lt;p&gt;I&amp;rsquo;ll be giving a talk at &lt;a href=&#34;https://conference.accu.org/2018/sessions.html#XIjustwantedtopointtosomething&#34;&gt;ACCU&lt;/a&gt; about when to use which pointer types and why.&lt;/p&gt;&#xA;&lt;p&gt;While working on that I made some guidelines for rvalue references in interfaces which didn&amp;rsquo;t quite fit the talk,&#xA;so I&amp;rsquo;m writing about them here.&lt;/p&gt;&#xA;&lt;p&gt;When should you use rvalue references as function parameters?&lt;/p&gt;&#xA;&lt;p&gt;When as return types?&lt;/p&gt;&#xA;&lt;p&gt;What are ref-qualified member functions and when and how should you use them?&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s tackle it one by one.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Flexible issue management with Trello and IFTTT</title>
      <link>https://www.foonathan.net/2018/03/issue-management-trello-ifttt/</link>
      <pubDate>Thu, 15 Mar 2018 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2018/03/issue-management-trello-ifttt/</guid>
      <description>&lt;p&gt;Like many open source developers I use &lt;a href=&#34;https://github.comn/foonathan&#34;&gt;GitHub&lt;/a&gt; to publish my work.&#xA;It comes with a built-in issue tracking system, however, it isn&amp;rsquo;t that great.&lt;/p&gt;&#xA;&lt;p&gt;The main issue - no pun intended - I have with it is that there is not an easy way to see all open issues and pull requests on all repositories you have.&#xA;There is the &lt;a href=&#34;https://github.com/issues&#34;&gt;issue workspace&lt;/a&gt;, but it only shows issues I&amp;rsquo;ve created, where I&amp;rsquo;m mentioned, or I&amp;rsquo;m assigned to.&#xA;This isn&amp;rsquo;t helpful in my case, so I&amp;rsquo;ve looked for a different solution.&#xA;There are also so-called &amp;ldquo;Projects&amp;rdquo;, but they are just for one repository - I need one for all.&lt;/p&gt;&#xA;&lt;p&gt;I finally found a solution: It uses &lt;a href=&#34;https://trello.com&#34;&gt;Trello&lt;/a&gt; and &lt;a href=&#34;https://ifttt.com&#34;&gt;If This Then That&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Guidelines for constructor and cast design</title>
      <link>https://www.foonathan.net/2018/01/constructors-casts-design/</link>
      <pubDate>Fri, 26 Jan 2018 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2018/01/constructors-casts-design/</guid>
      <description>&lt;p&gt;A while back — but sadly not too many blog posts ago — I wrote about &lt;a href=&#34;https://www.foonathan.net/blog/2017/10/11/explicit-assignment.html&#34;&gt;&lt;code&gt;explicit&lt;/code&gt; constructors and how to handle assignment&lt;/a&gt;.&#xA;In this blog post, I made the assumption that you most likely want to have &lt;code&gt;explicit&lt;/code&gt; single argument constructors.&lt;/p&gt;&#xA;&lt;p&gt;But when do we actually want implicit single argument constructors?&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s consider the broader question: How should I design a cast operation for my user-defined type?&#xA;And how should I design a constructor?&lt;/p&gt;&#xA;&lt;p&gt;But first, something different: what is the difference between a cast and a constructor?&lt;/p&gt;</description>
    </item>
    <item>
      <title>Implementation Challenge: Revisiting the visitor pattern</title>
      <link>https://www.foonathan.net/2017/12/visitors/</link>
      <pubDate>Thu, 21 Dec 2017 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2017/12/visitors/</guid>
      <description>&lt;p&gt;C++ as a language is moving away from the classical, &amp;ldquo;Java style&amp;rdquo;, object-oriented programming.&#xA;Long gone are the days of &lt;a href=&#34;http://en.cppreference.com/w/cpp/io/ios_base&#34;&gt;grand, &lt;code&gt;virtual&lt;/code&gt; hierarchies&lt;/a&gt;.&#xA;They&amp;rsquo;ve been replaced with standalone classes, free functions and &lt;a href=&#34;https://www.youtube.com/watch?v=bIhUE5uUFOA&#34;&gt;type erasure&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;And the benefits are clear:&#xA;Instead of reference semantics, they allow value semantics which are simpler and more natural for C++.&#xA;Instead of intrusive interface inheritance, they allow external duck-typing.&lt;/p&gt;&#xA;&lt;p&gt;So in the spirit of this movement, let&amp;rsquo;s take a look at one OOP pattern and see if we can adopt it to this style:&#xA;the visitor pattern.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Exceptions vs expected: Let&#39;s find a compromise</title>
      <link>https://www.foonathan.net/2017/12/exceptions-vs-expected/</link>
      <pubDate>Mon, 04 Dec 2017 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2017/12/exceptions-vs-expected/</guid>
      <description>&lt;p&gt;This isn&amp;rsquo;t the blog post I wanted to publish today, this is the blog post I had to publish.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://twitter.com/TartanLlama&#34;&gt;Simon&lt;/a&gt; blogged about &lt;a href=&#34;https://blog.tartanllama.xyz/optional-expected/&#34;&gt;using ADTs&lt;/a&gt; for error handling, leading to an interesting &lt;a href=&#34;https://www.reddit.com/r/cpp/comments/7gua48/functional_exceptionless_errorhandling_with/&#34;&gt;reddit discussion&lt;/a&gt;.&#xA;Then &lt;a href=&#34;https://twitter.com/supahvee1234&#34;&gt;Vittorio&lt;/a&gt; wanted to share his thoughts on the matter, leading to an &lt;a href=&#34;https://www.reddit.com/r/cpp/comments/7ha64y/why_choose_sum_types_over_exceptions/&#34;&gt;even bigger reddit discussion&lt;/a&gt;.&#xA;Now I&amp;rsquo;d like to chime in and offer a reasonable solution.&lt;/p&gt;&#xA;&lt;p&gt;It is the age-old question: return codes vs exceptions.&#xA;But this time, return codes have gotten an upgrade: &lt;code&gt;std::expected&lt;/code&gt; and similar types.&lt;/p&gt;</description>
    </item>
    <item>
      <title>What should be part of the C&#43;&#43; standard library?</title>
      <link>https://www.foonathan.net/2017/11/standard-library/</link>
      <pubDate>Mon, 20 Nov 2017 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2017/11/standard-library/</guid>
      <description>&lt;p&gt;At &lt;a href=&#34;https://meetingcpp.com/&#34;&gt;Meeting C++ 2017&lt;/a&gt; — which was great, BTW — I attended a talk by Guy Davidson about the C++ &lt;a href=&#34;http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0669r0.pdf&#34;&gt;graphics 2D proposal&lt;/a&gt;, wording &lt;a href=&#34;http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0267r6.pdf&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Now, there is some controversy about the proposal — especially by those who do serious graphics stuff.&#xA;Does the C++ standard library need 2D graphics?&#xA;Shouldn&amp;rsquo;t the committee focus on real issues instead of some toy library that is never going to be used for serious applications?&lt;/p&gt;&#xA;&lt;p&gt;But I&amp;rsquo;m not here to rant about the stupid standard committee and the completely bloated and unusable standard library, like some do.&#xA;Instead, this discussion got me thinking:&#xA;What &lt;em&gt;should&lt;/em&gt; be part of a language&amp;rsquo;s standard library?&lt;/p&gt;</description>
    </item>
    <item>
      <title>Write explicit constructors - but what about assignment?</title>
      <link>https://www.foonathan.net/2017/10/explicit-assignment/</link>
      <pubDate>Wed, 11 Oct 2017 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2017/10/explicit-assignment/</guid>
      <description>&lt;p&gt;Implicit conversions considered harmful.&lt;/p&gt;&#xA;&lt;p&gt;Okay, this might be a little harsh:&lt;/p&gt;&#xA;&lt;p&gt;Potentially dangerous and/or expensive implicit conversions considered harmful.&lt;/p&gt;&#xA;&lt;p&gt;Better.&lt;/p&gt;&#xA;&lt;p&gt;Implicit conversions will happen &amp;ldquo;accidentally&amp;rdquo; by their very nature,&#xA;so if they happen, they should always do the right thing.&lt;/p&gt;&#xA;&lt;p&gt;And how to prevent implicit conversions?&#xA;Simple: use an &lt;code&gt;explicit&lt;/code&gt; constructor.&lt;/p&gt;&#xA;&lt;p&gt;But that&amp;rsquo;s only half of the problem: What about assignment?&#xA;Is there &lt;code&gt;explicit&lt;/code&gt; assignment?&#xA;If so, when do I use it?&lt;/p&gt;</description>
    </item>
    <item>
      <title>Thoughts on destructive move</title>
      <link>https://www.foonathan.net/2017/09/destructive-move/</link>
      <pubDate>Thu, 14 Sep 2017 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2017/09/destructive-move/</guid>
      <description>&lt;p&gt;C++11 introduced move semantics.&#xA;With it, you can encode transfer of ownership and allow to put types in a container where you can&amp;rsquo;t copy them.&lt;/p&gt;&#xA;&lt;p&gt;This clearly is powerful.&lt;/p&gt;&#xA;&lt;p&gt;But the current move system isn&amp;rsquo;t perfect, there are a couple of issues.&#xA;There is an arguably cleaner approach: destructive move.&lt;/p&gt;&#xA;&lt;p&gt;In this post we&amp;rsquo;ll explore a purely theoretical alternative C++ with destructive move.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Operator precedence is broken</title>
      <link>https://www.foonathan.net/2017/07/operator-precedence/</link>
      <pubDate>Mon, 24 Jul 2017 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2017/07/operator-precedence/</guid>
      <description>&lt;p&gt;A discussion on Twitter got me thinking about operator precedence.&#xA;It is a crucial part of most programming languages as it dictates the meaning of expressions.&lt;/p&gt;&#xA;&lt;p&gt;Interestingly enough, it is practically the same in almost all programming languages, even ones that radical try to be a better alternative for an established language.&#xA;So apparently operator precedence is a solved problem, right?&lt;/p&gt;&#xA;&lt;p&gt;Well, I don&amp;rsquo;t think so.&#xA;I think operator precedence is fundamentally flawed and could easily be improved.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Lazy evaluation of function arguments in C&#43;&#43;</title>
      <link>https://www.foonathan.net/2017/06/lazy-evaluation/</link>
      <pubDate>Tue, 27 Jun 2017 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2017/06/lazy-evaluation/</guid>
      <description>&lt;p&gt;Sometimes you&amp;rsquo;re lazy.&#xA;You know you need to do something, but don&amp;rsquo;t want to do it &lt;em&gt;yet&lt;/em&gt;.&#xA;You don&amp;rsquo;t need to do it right now, only at some later point.&#xA;And maybe later it turns out that you don&amp;rsquo;t need to do the entire work, just a part of it or nothing at all!&#xA;So if you&amp;rsquo;re eager and do it &lt;em&gt;right now&lt;/em&gt;, you might do more work than needed.&lt;/p&gt;&#xA;&lt;p&gt;The same applies to your code.&#xA;Sometimes you do things even though it is not necessary.&#xA;You call a function passing it some arguments that were expensive to calculate and then the function don&amp;rsquo;t need all of them due to some other arguments.&#xA;Wouldn&amp;rsquo;t it be great to only calculate the arguments when they are actually needed?&lt;/p&gt;&#xA;&lt;p&gt;This is called lazy evaluation of function arguments and this blog post presents how it can be done in C++.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Prefer nonmember, nonfriends?</title>
      <link>https://www.foonathan.net/2017/06/member-vs-free/</link>
      <pubDate>Wed, 14 Jun 2017 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2017/06/member-vs-free/</guid>
      <description>&lt;p&gt;How many member functions does &lt;code&gt;std::string&lt;/code&gt; have?&lt;/p&gt;&#xA;&lt;p&gt;As of C++17 the answer is 153, assuming I counted correctly.&lt;/p&gt;&#xA;&lt;p&gt;One Hundred Fifty Three.&lt;/p&gt;&#xA;&lt;p&gt;That is a &lt;em&gt;lot&lt;/em&gt;.&#xA;And as &lt;a href=&#34;http://www.gotw.ca/gotw/084.htm&#34;&gt;Herb Sutter has pointed out&lt;/a&gt;, most of those members could easily be implemented as non-members without loss of performance.&lt;/p&gt;&#xA;&lt;p&gt;And they should be implemented as nonmembers according to an old guideline from the &lt;a href=&#34;http://www.gotw.ca/publications/c++cs.htm&#34;&gt;C++ coding standards&lt;/a&gt;: Prefer nonmember, nonfriends.&#xA;Write free functions whenever possible, not members.&lt;/p&gt;&#xA;&lt;p&gt;But how true is that advice really?&lt;/p&gt;</description>
    </item>
    <item>
      <title>The year is 2017 - Is the preprocessor still needed in C&#43;&#43;?</title>
      <link>https://www.foonathan.net/2017/05/preprocessor/</link>
      <pubDate>Mon, 08 May 2017 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2017/05/preprocessor/</guid>
      <description>&lt;p&gt;The C++, eh C, preprocessor is wonderful.&lt;/p&gt;&#xA;&lt;p&gt;Well, no - it isn&amp;rsquo;t wonderful.&lt;/p&gt;&#xA;&lt;p&gt;It is a primitive text replacement tool that must be used to work with C++.&#xA;But is &amp;ldquo;must&amp;rdquo; really true?&#xA;Most of the usage has become obsolete thanks to new and better C++ language features.&#xA;And many more features like modules will come soon™.&#xA;So can we get rid of the preprocessor?&#xA;And if so, how can we do it?&lt;/p&gt;</description>
    </item>
    <item>
      <title>cppast - A library to parse and work with the C&#43;&#43; AST</title>
      <link>https://www.foonathan.net/2017/04/cppast/</link>
      <pubDate>Thu, 20 Apr 2017 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2017/04/cppast/</guid>
      <description>&lt;p&gt;Last year I started &lt;a href=&#34;https://github.com/foonathan/standardese&#34;&gt;standardese&lt;/a&gt;, a C++ documentation generator.&#xA;In order to provide exact documentation, I need to parse C++ code.&#xA;As I didn&amp;rsquo;t want to waste time implementing my own parser,&#xA;which will take ages and don&amp;rsquo;t work most of the time,&#xA;I opted to use &lt;a href=&#34;https://clang.llvm.org/doxygen/group__CINDEX.html&#34;&gt;libclang&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;libclang is a C API that exposes the C++ abstract syntax tree (AST) which is built on top of clang.&#xA;And clang is a good and conforming C++ compiler,&#xA;so I expected an interface to read the AST that just works and give me the information I need.&lt;/p&gt;&#xA;&lt;p&gt;Well, I was wrong.&#xA;Here&amp;rsquo;s why and how I solved it.&lt;/p&gt;</description>
    </item>
    <item>
      <title>std::string_view accepting temporaries: good idea or horrible pitfall?</title>
      <link>https://www.foonathan.net/2017/03/string_view-temporary/</link>
      <pubDate>Wed, 22 Mar 2017 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2017/03/string_view-temporary/</guid>
      <description>&lt;p&gt;C++17 brings us &lt;a href=&#34;http://en.cppreference.com/w/cpp/string/basic_string_view&#34;&gt;&lt;code&gt;std::string_view&lt;/code&gt;&lt;/a&gt;.&#xA;It is a really useful tool:&#xA;If you want to write a function accepting some string, but does not need ownership, i.e. a &lt;em&gt;view&lt;/em&gt;,&#xA;use &lt;code&gt;std::string_view&lt;/code&gt;.&#xA;It supports both &lt;code&gt;const char*&lt;/code&gt; and &lt;code&gt;std::string&lt;/code&gt; without any work,&#xA;and does not involve any heap allocations.&#xA;Further, it clearly signals intent: this function takes a view.&#xA;It doesn&amp;rsquo;t own anything, it just views it.&lt;/p&gt;&#xA;&lt;p&gt;&lt;a href=&#34;http://sched.co/A8Is&#34;&gt;As someone who frequently advocates for using correct types&lt;/a&gt;,&#xA;I am happy about &lt;code&gt;std::string_view&lt;/code&gt;.&#xA;Yet there is one design decisions that warrants a discussion:&#xA;&lt;code&gt;std::string_view&lt;/code&gt; silently views temporaries as well.&#xA;This can create a problem if the view lives longer than the temporary,&#xA;as the view now views already destroyed data.&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s look into the reasons behind this decision&#xA;and what that means for using &lt;code&gt;std::string_view&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Implementation Challenge flag_set: Type-safe, hard to misuse bitmask</title>
      <link>https://www.foonathan.net/2017/03/implementation-challenge-bitmask/</link>
      <pubDate>Thu, 16 Mar 2017 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2017/03/implementation-challenge-bitmask/</guid>
      <description>&lt;p&gt;Sometimes when writing an API you need to pass various flags to a function.&#xA;For example, when opening a file you can pass information like whether or not the file is opened for reading,&#xA;writing, binary, write at the end etc.&#xA;And often those flags can be combined arbitrarily.&lt;/p&gt;&#xA;&lt;p&gt;Usually you&amp;rsquo;d implement that by using a bitmask:&#xA;Each flag is a bit in an integer,&#xA;they can be set/reset and toggled with bitwise operations.&#xA;However, the naive implementation isn&amp;rsquo;t very good:&#xA;I&amp;rsquo;ll explain why and show you how to do it better.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Implementing a tuple_iterator</title>
      <link>https://www.foonathan.net/2017/03/tuple-iterator/</link>
      <pubDate>Wed, 01 Mar 2017 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2017/03/tuple-iterator/</guid>
      <description>&lt;p&gt;This post is part of a collaboration with Arne Mertz.&#xA;Arne is a software Engineer at Zühlke and a clean code enthusiast with a focus on modern C++. You can find him online at &lt;a href=&#34;https://twitter.com/arne_mertz/&#34;&gt;Twitter&lt;/a&gt; and at his &lt;a href=&#34;https://arne-mertz.de&#34;&gt;&amp;ldquo;Simplify C++!&amp;rdquo; blog&lt;/a&gt;.&#xA;We&amp;rsquo;ve both written something about accessing &lt;code&gt;std::tuple&lt;/code&gt;,&#xA;but swapped our blogs - my post is over at his blog and his one follows here now:&lt;/p&gt;&#xA;&lt;hr&gt;&#xA;&lt;p&gt;Did you ever wonder how we could iterate over the contents of a &lt;code&gt;std::tuple&lt;/code&gt; at runtime, similar to an array or &lt;code&gt;std::vector&lt;/code&gt;?&#xA;You may or may not see the need for such a functionality - this walkthrough shows a proof of concept and how you tackle problems like this in C++17.&lt;/p&gt;</description>
    </item>
    <item>
      <title>The problem with policy-based design</title>
      <link>https://www.foonathan.net/2017/02/policy-based-design-problem/</link>
      <pubDate>Wed, 08 Feb 2017 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2017/02/policy-based-design-problem/</guid>
      <description>&lt;p&gt;Policy-based design is a great way for library authors to provide more flexibility to the user.&#xA;Instead of hard coding certain behaviors, policy-based design provides various &lt;em&gt;policies&lt;/em&gt; the users can select to customize the behavior.&#xA;If done properly, a library author can accommodate all use cases with a single implementation.&lt;/p&gt;&#xA;&lt;p&gt;I&amp;rsquo;m a big fan of policy-based design for that reason.&#xA;Whenever there&amp;rsquo;s a possible trade-off, where multiple solutions are possible,&#xA;each with their own set of advantages and disadvantages,&#xA;I make the decision available to the user.&#xA;Instead of favoring a certain use case, I favor all of them.&#xA;This is for example what I did with &lt;a href=&#34;https://www.foonathan.net/blog/2016/12/28/variant.html&#34;&gt;my variant implementation&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, policy-based design isn&amp;rsquo;t perfect.&#xA;In particular, it has a great problem:&#xA;It creates lots and lots of different and incompatible types.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Implementing function_view is harder than you might think</title>
      <link>https://www.foonathan.net/2017/01/function-ref-implementation/</link>
      <pubDate>Fri, 20 Jan 2017 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2017/01/function-ref-implementation/</guid>
      <description>&lt;p&gt;I&amp;rsquo;ve recently read &lt;a href=&#34;https://vittorioromeo.info/index/blog/passing_functions_to_functions.html&#34;&gt;this blog post&lt;/a&gt; by Vittorio Romeo.&#xA;He talks about various ways to pass a function (callback, comparator for algorithm, etc.) to another function.&#xA;One of them is &lt;code&gt;function_view&lt;/code&gt;.&#xA;&lt;code&gt;function_view&lt;/code&gt; is a lightweight &lt;code&gt;std::function&lt;/code&gt;:&#xA;it should be able to refer to any callable with a given signature.&#xA;But unlike &lt;code&gt;std::function&lt;/code&gt; it does not &lt;em&gt;own&lt;/em&gt; the callable,&#xA;just &lt;em&gt;refers&lt;/em&gt; to it.&#xA;This allows a much more efficient implementation.&lt;/p&gt;&#xA;&lt;p&gt;In this post he presented one.&#xA;But his has a flaw, that can bite you very easily.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How to handle errors in constructors without exceptions?</title>
      <link>https://www.foonathan.net/2017/01/exceptions-constructor/</link>
      <pubDate>Mon, 09 Jan 2017 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2017/01/exceptions-constructor/</guid>
      <description>&lt;p&gt;While browsing the &lt;a href=&#34;https://www.reddit.com/r/cpp&#34;&gt;C++ subreddit&lt;/a&gt; I&amp;rsquo;ve encountered the following comment.&lt;/p&gt;&#xA;&lt;div class=&#34;reddit-embed&#34; data-embed-media=&#34;www.redditmedia.com&#34; data-embed-parent=&#34;false&#34; data-embed-live=&#34;false&#34; data-embed-uuid=&#34;f7e5b3a9-befc-4613-8dee-4a59a1a3b008&#34; data-embed-created=&#34;2017-01-10T13:25:11.169Z&#34;&gt;&lt;a href=&#34;https://www.reddit.com/r/cpp/comments/5msdf4/measuring_execution_performance_of_c_exceptions/dc5zkq3/&#34;&gt;Comment&lt;/a&gt; from discussion &lt;a href=&#34;https://www.reddit.com/r/cpp/comments/5msdf4/measuring_execution_performance_of_c_exceptions/&#34;&gt;Measuring execution performance of C++ exceptions vs plain C error codes&lt;/a&gt;.&lt;/div&gt;&lt;script async src=&#34;https://www.redditstatic.com/comment-embed.js&#34;&gt;&lt;/script&gt;&#xA;&lt;p&gt;I&amp;rsquo;m not going to jump on the exception discussion currently happening in the child comments.&#xA;I&amp;rsquo;m just going to focus on the part where he said it is sad that C++ constructors require exceptions for error handling.&#xA;So let&amp;rsquo;s assume you don&amp;rsquo;t have exception support in your application and has a constructor that needs to report an error.&#xA;What do you do?&lt;/p&gt;</description>
    </item>
    <item>
      <title>My take on variant</title>
      <link>https://www.foonathan.net/2016/12/variant/</link>
      <pubDate>Wed, 28 Dec 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/12/variant/</guid>
      <description>&lt;p&gt;C++17 is going to add &lt;a href=&#34;https://en.cppreference.com/w/cpp/utility/variant&#34;&gt;std::variant&lt;/a&gt;.&#xA;To quote the linked documentation, it is a &amp;ldquo;type-safe union&amp;rdquo;.&#xA;A &lt;code&gt;union&lt;/code&gt; is like a &lt;code&gt;struct&lt;/code&gt;, but can only store one member at a time.&#xA;This has many applications, but sadly it doesn&amp;rsquo;t mix well with non-trivial types,&#xA;you have to call the destructor yourself etc.&#xA;Furthermore, nothing prevents you from accessing a union member that isn&amp;rsquo;t active.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;std::variant&lt;/code&gt; fixes that. It correctly calls the destructor when switching the active member,&#xA;it prevents invalid access, etc.&#xA;However, I&amp;rsquo;m not quite happy with it and I needed an implementation now.&#xA;So I&amp;rsquo;ve decided to implement my own variant as part of my &lt;a href=&#34;https://github.com/foonathan/type_safe&#34;&gt;type_safe&lt;/a&gt; library.&lt;/p&gt;&#xA;&lt;p&gt;It was a fun challenge and since my previous attempt was &lt;a href=&#34;https://github.com/foonathan/storage/blob/master/variant.hpp&#34;&gt;two years ago&lt;/a&gt;,&#xA;I could improve it a lot.&#xA;Let&amp;rsquo;s go through some of my design decisions.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Tutorial: Conditionally disabling non-template functions</title>
      <link>https://www.foonathan.net/2016/12/conditionally-removing-functions/</link>
      <pubDate>Wed, 21 Dec 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/12/conditionally-removing-functions/</guid>
      <description>&lt;p&gt;Consider that you have a function template that takes a parameter on type &lt;code&gt;T&lt;/code&gt;.&#xA;If the function template has a rather generic name like &lt;code&gt;operator==&lt;/code&gt;, is a constructor,&#xA;or anything whose existence might be queried with type traits to further constrain other functions,&#xA;it is often beneficial if you can conditionally disable the function if the type does not have some required properties.&#xA;Otherwise the function will be &amp;ldquo;greedy&amp;rdquo; and accept more than it should - making some traits near useless,&#xA;as they only check for existence and the error only occurs later.&lt;/p&gt;&#xA;&lt;p&gt;Conditionally removing functions if their template parameters don&amp;rsquo;t fulfill certain properties&#xA;is done with &lt;a href=&#34;https://www.foonathan.net/blog/2015/11/30/overload-resolution-4.html&#34;&gt;SFINAE&lt;/a&gt;.&#xA;But what if you have member functions of a class template that are not templates themselves?&lt;/p&gt;</description>
    </item>
    <item>
      <title>Fixing std::initializer_list&lt;T&gt;</title>
      <link>https://www.foonathan.net/2016/12/fixing-initializer-list/</link>
      <pubDate>Thu, 08 Dec 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/12/fixing-initializer-list/</guid>
      <description>&lt;p&gt;C++11 introduced &lt;code&gt;std::initializer_list&lt;/code&gt;.&#xA;This is a small class used if you want to initialize some container type with a pre-defined set of elements.&#xA;It allows very convenient syntax just like plain old C arrays have.&lt;/p&gt;&#xA;&lt;p&gt;Yet it has a couple of problems.&#xA;This post will talk about them and how they can be fixed.&lt;/p&gt;</description>
    </item>
    <item>
      <title>standardese documentation generator version 0.3: Groups, inline documentation, template mode &amp; more</title>
      <link>https://www.foonathan.net/2016/11/standardese-0.3/</link>
      <pubDate>Sat, 26 Nov 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/11/standardese-0.3/</guid>
      <description>&lt;p&gt;After two bugfix release for the parsing code, I finally got around to implement more features for &lt;a href=&#34;https://github.com/foonathan/standardese&#34;&gt;standardese&lt;/a&gt;.&#xA;A complete refactoring of the internal code allowed me to implement some advanced features:&#xA;standardese now comes with member groups,&#xA;the ability to show inline documentation, a template language and many minor things that just improve the overall documentation generation.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Memory 0.6: Composition and Joint Allocators</title>
      <link>https://www.foonathan.net/2016/11/memory-0.6/</link>
      <pubDate>Mon, 21 Nov 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/11/memory-0.6/</guid>
      <description>&lt;p&gt;If you&amp;rsquo;ve been a long reader of my blog, you might remember my &lt;a href=&#34;https://github.com/foonathan/memory&#34;&gt;memory library&lt;/a&gt;.&#xA;I haven&amp;rsquo;t forgotten about it, even though the 0.5 release was in February!&#xA;After three patches and a long pause in development to focus on &lt;a href=&#34;https://github.com/foonathan/standardese&#34;&gt;standardese&lt;/a&gt;,&#xA;I&amp;rsquo;ve finally finished the 0.6 release.&#xA;It mainly provides two major features: composition and joint allocators.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Function templates - deduce template arguments or pass explicitly?</title>
      <link>https://www.foonathan.net/2016/11/template-argument-deduction/</link>
      <pubDate>Fri, 04 Nov 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/11/template-argument-deduction/</guid>
      <description>&lt;p&gt;Function templates allow writing a single definition that can handle multiple different types.&#xA;It is a very powerful form of C++&amp;rsquo;s static polymorphism.&lt;/p&gt;&#xA;&lt;p&gt;When instantiating a class template, we have to pass in the types explictly (at least until C++17):&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-cpp&#34; data-lang=&#34;cpp&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;std&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;vector&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;vec&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;std&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;basic_string&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;my_char&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;std&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;char_traits&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;my_char&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;str&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;std&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;tuple&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;bool&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;std&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;string&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;tuple&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;But when instantiating a function template, the compiler can often figure the types out:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-cpp&#34; data-lang=&#34;cpp&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;template&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;typename&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;A&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;typename&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;B&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;typename&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;C&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;func&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;A&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;a&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;B&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;b&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;C&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;c&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;err&#34;&gt;…&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;x&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;func&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;x&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;sc&#34;&gt;&amp;#39;A&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;hello&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;// equivalent to:&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;func&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;char&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;char&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;*&amp;gt;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;x&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;sc&#34;&gt;&amp;#39;A&amp;#39;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;hello&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Let&amp;rsquo;s look at this process into a little bit more detail and establish some guidelines&#xA;as well as see how we can prohibit template argument deduction for arguments.&lt;/p&gt;</description>
    </item>
    <item>
      <title>void foo(T&amp; out) - How to fix output parameters</title>
      <link>https://www.foonathan.net/2016/10/output-parameter/</link>
      <pubDate>Wed, 26 Oct 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/10/output-parameter/</guid>
      <description>&lt;p&gt;There are some cases where you need to return a value from a function but cannot use the return value.&#xA;It happens, for example, in functions where you want to return multiple values at once.&#xA;While you can pass multiple inputs to a function - the parameters,&#xA;you cannot pass multiple return values in the same way.&lt;/p&gt;&#xA;&lt;p&gt;C++ programmers tend to use a good old (lvalue) reference for that.&#xA;You take a non-&lt;code&gt;const&lt;/code&gt; reference as parameter and assign the output to that reference.&#xA;The caller will pass a variable and upon function completion find the value of the variable changed.&lt;/p&gt;&#xA;&lt;p&gt;Yet this approach has some problems:&#xA;For starters, it is not obvious when just looking at the call that the variable is going to be changed.&#xA;This is the reason that C++ style guides such as the one used by &lt;a href=&#34;https://google.github.io/styleguide/cppguide.html#Reference_Arguments&#34;&gt;Google&lt;/a&gt; recommend using a pointer for that.&#xA;The caller then has to explicitly pass in the address of the variable, making it explicit.&lt;/p&gt;&#xA;&lt;p&gt;But with a pointer you can now pass in &lt;code&gt;nullptr&lt;/code&gt;,&#xA;you have to check for that in the function:&#xA;A pointer where you really mean &amp;ldquo;reference&amp;rdquo; does not follow &lt;a href=&#34;https://www.foonathan.net/blog/2016/09/27/error-handling-types.html&#34;&gt;the guidelines&lt;/a&gt; I&amp;rsquo;ve been &lt;a href=&#34;https://www.foonathan.net/blog/2016/10/11/type-safe.html&#34;&gt;advocating for&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So is there not a universal solution?&lt;/p&gt;&#xA;&lt;p&gt;There is, but first we need to understand the full scope of the problem.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Tutorial: Emulating strong/opaque typedefs in C&#43;&#43;</title>
      <link>https://www.foonathan.net/2016/10/strong-typedefs/</link>
      <pubDate>Wed, 19 Oct 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/10/strong-typedefs/</guid>
      <description>&lt;p&gt;Last week, I&amp;rsquo;ve released my &lt;a href=&#34;https://github.com/foonathan/type_safe&#34;&gt;type_safe&lt;/a&gt; library.&#xA;I described it&amp;rsquo;s features in &lt;a href=&#34;https://www.foonathan.net/blog/2016/10/11/type-safe.html&#34;&gt;the corresponding blog post&lt;/a&gt; but because the blog post got rather long,&#xA;I couldn&amp;rsquo;t cover one feature: strong typedefs.&lt;/p&gt;&#xA;&lt;p&gt;Strong or opaque typedefs are a very powerful feature if you want to prevent errors with the type system &amp;ndash; and as &lt;a href=&#34;https://www.foonathan.net/blog/2016/09/27/error-handling-types.html&#34;&gt;I&amp;rsquo;ve been advocating for&lt;/a&gt;, you want that.&#xA;Unlike &amp;ldquo;normal&amp;rdquo; typedefs, they are a true type definition:&#xA;they create a new type and allow stuff like overloading on them and/or prevent implicit conversions.&lt;/p&gt;&#xA;&lt;p&gt;Sadly, C++ doesn&amp;rsquo;t provide a native way to create them,&#xA;so you have to resort to a library based emulation.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;BTW, &lt;a href=&#34;https://github.com/foonathan/type_safe&#34;&gt;type_safe&lt;/a&gt; received a couple of requested features:&#xA;There are improvements to the monadic optional functions (&lt;code&gt;bind()&lt;/code&gt;, &lt;code&gt;map()&lt;/code&gt;, &lt;code&gt;unwrap()&lt;/code&gt; as well as a new &lt;code&gt;transform()&lt;/code&gt;),&#xA;multi-visitation of optionals and &lt;code&gt;ArithmeticPolicy&lt;/code&gt; to control over/underflow behavior of the &lt;code&gt;ts::integer&amp;lt;T&amp;gt;&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;</description>
    </item>
    <item>
      <title>Type safe - Zero overhead utilities for more type safety</title>
      <link>https://www.foonathan.net/2016/10/type-safe/</link>
      <pubDate>Tue, 11 Oct 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/10/type-safe/</guid>
      <description>&lt;p&gt;Two weeks ago I&amp;rsquo;ve blogged about &lt;a href=&#34;https://www.foonathan.net/blog/2016/09/27/error-handling-types.html&#34;&gt;using C++&amp;rsquo;s type system to prevent errors&lt;/a&gt;.&#xA;The post spawned a lot of discussion so I wanted to address some of the responses I&amp;rsquo;ve got.&#xA;I&amp;rsquo;ve also said at the end of the post that I was going to write a library that helps to implement the techniques.&#xA;The library is now done - &lt;a href=&#34;https://github.com/foonathan/type_safe&#34;&gt;type_safe&lt;/a&gt; can be found on Github,&#xA;but please do read on for a discussion about the motivation and feature overview.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Prevent precondition errors with the C&#43;&#43; type system</title>
      <link>https://www.foonathan.net/2016/09/error-handling-types/</link>
      <pubDate>Tue, 27 Sep 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/09/error-handling-types/</guid>
      <description>&lt;p&gt;In the &lt;a href=&#34;https://www.foonathan.net/blog/2016/09/16/assertions.html&#34;&gt;previous part&lt;/a&gt; of the error handling series I&amp;rsquo;ve talked about assertions and wrote a &lt;a href=&#34;https://github.com/foonathan/debug-assert&#34;&gt;debug assert&lt;/a&gt; library that provides flexible assertions.&lt;/p&gt;&#xA;&lt;p&gt;Assertions are a useful tool to check preconditions of functions - but proper type design can prevent situations where assertions are needed.&#xA;C++ has a great type system, let&amp;rsquo;s use it to our advantage.&lt;/p&gt;&#xA;&lt;p&gt;At the recent &lt;a href=&#34;http://cppcon.org&#34;&gt;CppCon&lt;/a&gt; &lt;a href=&#34;https://twitter.com/ben_deane&#34;&gt;Ben Deane&lt;/a&gt; gave a - as far as I&amp;rsquo;ve heard - great talk about type design.&#xA;I sadly didn&amp;rsquo;t attend the conference and his video isn&amp;rsquo;t released yet but according to the &lt;a href=&#34;http://www.elbeno.com/presentations/using-types-effectively/presentation.html#/slide-orgheadline82&#34;&gt;slides&lt;/a&gt; there is some overlapping between his talk and what I&amp;rsquo;m going to say.&#xA;But because I&amp;rsquo;ve planned this posts for weeks and even made the entire series just for it I decided to post it anyway.&#xA;After all: some things cannot be said often enough.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Also I&amp;rsquo;m going to focus explicitly about type design for error handling,&#xA;while his talk seems to be more generic.&lt;/p&gt;&#xA;&lt;/blockquote&gt;</description>
    </item>
    <item>
      <title>How do I implement assertions?</title>
      <link>https://www.foonathan.net/2016/09/assertions/</link>
      <pubDate>Fri, 16 Sep 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/09/assertions/</guid>
      <description>&lt;p&gt;In &lt;a href=&#34;https://www.foonathan.net/blog/2016/09/07/error-handling-strategy.html&#34;&gt;part 1&lt;/a&gt; of the series I&amp;rsquo;ve talked about various error handling strategies and when to use which one.&#xA;In particular, I said that function precondition should only be checked with debug assertions, i.e. only in debug mode.&lt;/p&gt;&#xA;&lt;p&gt;The C library provides the macro &lt;code&gt;assert()&lt;/code&gt; for checking a condition only if &lt;code&gt;NDEBUG&lt;/code&gt; is not defined.&#xA;But as with most things coming from C, it is a simple but sometimes not sufficient solution.&#xA;The biggest problem I have with it is that it is &lt;em&gt;global&lt;/em&gt;, you either have assertions everywhere or none.&#xA;This is bad, because you might not want to have assertions enabled in a library, only in your own code.&#xA;For that reason, many library programmers write an assertion macro themselves, over and over again.&lt;/p&gt;&#xA;&lt;p&gt;Instead, let&amp;rsquo;s write same thing better ourselves, but something we can easily reuse.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Implementation Challenge: Concepts in C&#43;&#43;14</title>
      <link>https://www.foonathan.net/2016/09/cpp14-concepts/</link>
      <pubDate>Fri, 09 Sep 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/09/cpp14-concepts/</guid>
      <description>&lt;p&gt;There is the &lt;a href=&#34;http://en.cppreference.com/w/cpp/language/constraints&#34;&gt;concept TS&lt;/a&gt;, a technical specification for including concepts into C++17.&#xA;Concepts have always been a &amp;hellip; concept in C++.&#xA;They are used to document constraints on template parameters.&#xA;For example:&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-cpp&#34; data-lang=&#34;cpp&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;template&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&#34;k&#34;&gt;typename&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;RandomAccessIterator&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;typename&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Comperator&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kt&#34;&gt;void&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;sort&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;RandomAccessIterator&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;begin&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;RandomAccessIterator&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;end&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Comperator&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;comp&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;);&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This function has the requirement that &lt;code&gt;begin&lt;/code&gt; and &lt;code&gt;end&lt;/code&gt; are both &lt;a href=&#34;http://en.cppreference.com/w/cpp/concept/RandomAccessIterator&#34;&gt;random access iterators&lt;/a&gt; and &lt;code&gt;comp&lt;/code&gt; is a comparison function.&#xA;Right now, the concepts are only documented and ignoring them leads to great error messages.&#xA;The concept TS provides ways to embed them in the language directly and make, for example, overloading based on the concept easier.&lt;/p&gt;&#xA;&lt;p&gt;But it doesn&amp;rsquo;t really bring anything new to the language.&#xA;Everything it does can be accomplished with C++11&amp;rsquo;s expression SFINAE today,&#xA;it only brings an (arguably) cleaner syntax and more complexity to the language.&lt;/p&gt;&#xA;&lt;p&gt;In this post I&amp;rsquo;ll show you how to do implement concepts using only C++14 language features.&#xA;I&amp;rsquo;ll try to make it as easy as possible by introducing some library utilities you can use very easily.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Choosing the right error handling strategy</title>
      <link>https://www.foonathan.net/2016/09/error-handling-strategy/</link>
      <pubDate>Wed, 07 Sep 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/09/error-handling-strategy/</guid>
      <description>&lt;p&gt;To quote a &lt;a href=&#34;https://www.foonathan.net/blog/2016/06/27/flexible-error-handling.html&#34;&gt;previous post&lt;/a&gt;: &amp;ldquo;Sometimes things aren&amp;rsquo;t working.&amp;rdquo;&#xA;If something isn&amp;rsquo;t working, you have to deal with it.&#xA;But how?&lt;/p&gt;&#xA;&lt;p&gt;There are two fundamental kinds of strategies:&#xA;recoverable error handling (exceptions, error return codes, &lt;a href=&#34;https://www.foonathan.net/blog/2016/06/27/flexible-error-handling.html#solution-i-exception-handler&#34;&gt;handler functions&lt;/a&gt;) and un-recoverable error handling (&lt;code&gt;assert()&lt;/code&gt;, &lt;code&gt;abort()&lt;/code&gt;).&#xA;When do I use which one?&lt;/p&gt;</description>
    </item>
    <item>
      <title>Move Semantics and Default Constructors -- Rule of Six?</title>
      <link>https://www.foonathan.net/2016/08/move-default-ctor/</link>
      <pubDate>Wed, 24 Aug 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/08/move-default-ctor/</guid>
      <description>&lt;p&gt;A really long time ago - over four weeks! - I wrote about &lt;a href=&#34;https://www.foonathan.net/blog/2016/07/23/move-safety.html&#34;&gt;move safety&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;I &lt;strong&gt;really&lt;/strong&gt; need to force myself into blogging on a schedule.&#xA;Let&amp;rsquo;s say I&amp;rsquo;ll publish something at least every two weeks.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;The post spawned a lot of discussion about whether you should rely on moved-from state behavior or make any guarantees. See the first half of this &lt;a href=&#34;https://www.youtube.com/watch?v=tlkGnlNX6EE&#34;&gt;CppChat episode&lt;/a&gt; for more.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;BTW: Thanks for the nice words, Jon!&#xA;Really appreciate it.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;But I&amp;rsquo;m not going to continue that discussion.&#xA;Both sides have convincing arguments and I don&amp;rsquo;t really want to advocate for one side here.&lt;/p&gt;&#xA;&lt;p&gt;Instead I&amp;rsquo;m going to talk about something else related to the C++ move semantics, that couldn&amp;rsquo;t fit into the original post:&#xA;The relationship between a default constructor and move semantics.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Standardese documentation generator version 0.2: Entity linking, index generation &amp; more</title>
      <link>https://www.foonathan.net/2016/08/standardese-02/</link>
      <pubDate>Wed, 10 Aug 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/08/standardese-02/</guid>
      <description>&lt;p&gt;Two months ago I&amp;rsquo;ve released &lt;a href=&#34;https://github.com/foonathan/standardese&#34;&gt;standardese&lt;/a&gt; version 0.1.&#xA;I promised that the next version wouldn&amp;rsquo;t take so long as the first one - which took one month.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Well, I&amp;rsquo;m really not good as estimates.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;But this release brings the last missing features to make standardese an actually usable documentation generator: index generation, referring to other parts of the documentation and more output formats, as well as other amazing features like an overhauled comment system.&#xA;Also a lot of internal changes and bug fixes.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Move Safety -- Know What Can Be Done in the Moved-From State</title>
      <link>https://www.foonathan.net/2016/07/move-safety/</link>
      <pubDate>Sat, 23 Jul 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/07/move-safety/</guid>
      <description>&lt;p&gt;C++ programmers have this notion of &lt;em&gt;exception safety&lt;/em&gt;.&#xA;It is a very useful concept.&#xA;With it one can easily describe the post-conditions of a function if it throws.&lt;/p&gt;&#xA;&lt;p&gt;There is another situation where you need to easily describe some post-conditions: when talking about the state of an object after a move operation, i.e. after a move constructor or move assignment operator.&#xA;I thus want to introduce vocabulary for those post-conditions of the right-hand argument similar to the exception safety of a function:&#xA;The &lt;em&gt;move safety&lt;/em&gt;, if you will.&lt;/p&gt;&#xA;&lt;p&gt;The exception safety describes the post-conditions of a function if the function throws an exception.&#xA;Similarly, the move safety describes the post-conditions of the object after a move operation.&#xA;It thus gives information about what can be done safely with a moved-from object.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Tutorial: Easy dependency management for C&#43;&#43; with CMake and Git</title>
      <link>https://www.foonathan.net/2016/07/cmake-dependency-handling/</link>
      <pubDate>Thu, 07 Jul 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/07/cmake-dependency-handling/</guid>
      <description>&lt;p&gt;C++ dependency management is a more controversial topic with many alternatives and &lt;a href=&#34;https://www.conan.io/&#34;&gt;lots&lt;/a&gt; &lt;a href=&#34;https://github.com/ruslo/hunter&#34;&gt;of&lt;/a&gt; &lt;a href=&#34;https://github.com/Offirmo/cvm&#34;&gt;third-party&lt;/a&gt; &lt;a href=&#34;https://github.com/pfultz2/cget&#34;&gt;tools&lt;/a&gt;.&#xA;The following reddit comment describes it well:&lt;/p&gt;&#xA;&lt;div class=&#34;reddit-embed&#34; data-embed-media=&#34;www.redditmedia.com&#34; data-embed-parent=&#34;false&#34; data-embed-live=&#34;false&#34; data-embed-uuid=&#34;6dbdf0f7-b926-4a03-b18e-c086f3ae15e0&#34; data-embed-created=&#34;2016-07-06T14:20:52.525Z&#34;&gt;&lt;a href=&#34;https://www.reddit.com/r/cpp/comments/3d1vjq/is_there_a_c_package_manager_if_not_how_do_you/ct13yo0&#34;&gt;Comment&lt;/a&gt; from discussion &lt;a href=&#34;https://www.reddit.com/r/cpp/comments/3d1vjq/is_there_a_c_package_manager_if_not_how_do_you/&#34;&gt;Is there a C++ package manager? If not, how do you handle dependencies?&lt;/a&gt;.&lt;/div&gt;&lt;script async src=&#34;https://www.redditstatic.com/comment-embed.js&#34;&gt;&lt;/script&gt;&#xA;&lt;p&gt;This tutorial explains a relatively simple solution using &lt;a href=&#34;https://cmake.org&#34;&gt;CMake&lt;/a&gt; - the de-facto standard build tool - and &lt;a href=&#34;https://git-scm.com/&#34;&gt;git&lt;/a&gt; - the de-facto source code version control system.&#xA;It doesn&amp;rsquo;t require any external tools, works on all platforms and is relatively easy to setup and flexible for the user.&#xA;This is the same system I&amp;rsquo;m currently using for &lt;a href=&#34;https://github.com/foonathan/standardese&#34;&gt;standardese&lt;/a&gt;, my C++ documentation generator.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Flexible error handling techniques in C&#43;&#43;</title>
      <link>https://www.foonathan.net/2016/06/flexible-error-handling/</link>
      <pubDate>Mon, 27 Jun 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/06/flexible-error-handling/</guid>
      <description>&lt;p&gt;Sometimes things aren&amp;rsquo;t working.&#xA;The user enters stuff in the wrong format, a file isn&amp;rsquo;t found, a network connection fails and the system runs out of memory.&#xA;Those are errors and they need to be handling.&lt;/p&gt;&#xA;&lt;p&gt;In a high-level function this is relatively easy.&#xA;You know exactly &lt;em&gt;why&lt;/em&gt; something was wrong and can handle it in the right way.&#xA;But for low-level functions this isn&amp;rsquo;t quite as easy.&#xA;They don&amp;rsquo;t know &lt;em&gt;what&lt;/em&gt; was wrong, they only know &lt;em&gt;that&lt;/em&gt; something was wrong and need to report it to their caller.&lt;/p&gt;&#xA;&lt;p&gt;In C++ there are two main strategies: error return codes and exceptions.&#xA;The &amp;ldquo;modern&amp;rdquo;, mainstream C++ way of handling errors are exceptions.&#xA;But some people cannot use/think they cannot use/don&amp;rsquo;t want exceptions - for whatever reason.&lt;/p&gt;&#xA;&lt;p&gt;This blog post isn&amp;rsquo;t going to pick a side on the fight.&#xA;Instead I am describing techniques that make both sides - relatively - happy.&#xA;Those techniques are especially useful if you are developing libraries.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Standardese documentation generator version 0.1</title>
      <link>https://www.foonathan.net/2016/06/standardese-01/</link>
      <pubDate>Thu, 09 Jun 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/06/standardese-01/</guid>
      <description>&lt;p&gt;A little over a month ago, I&amp;rsquo;ve released the first prototype of &lt;a href=&#34;https://github.com/foonathan/standardese&#34;&gt;standardese&lt;/a&gt;.&#xA;Now, it has finally reached version 0.1 - it took way longer than I thought.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Well, it always takes longer as the estimate.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;It doesn&amp;rsquo;t bring many more features on first look, but massive parsing improvements.&lt;/p&gt;</description>
    </item>
    <item>
      <title>You (probably) do want `final` classes?</title>
      <link>https://www.foonathan.net/2016/05/final2/</link>
      <pubDate>Sun, 29 May 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/05/final2/</guid>
      <description>&lt;p&gt;In the previous post I&amp;rsquo;ve discussed the C++11 &lt;code&gt;final&lt;/code&gt; keyword and how it can be used.&#xA;I also gave a guideline that you shouldn&amp;rsquo;t use &lt;code&gt;final&lt;/code&gt; on non-polymorphic classes.&#xA;My reasoning was as follows:&lt;/p&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;For some classes - like policy classes or any other class where you might want to have the &lt;a href=&#34;http://en.cppreference.com/w/cpp/language/ebo&#34;&gt;EBO&lt;/a&gt; - making them &lt;code&gt;final&lt;/code&gt; can be harmful.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;For other classes - those which aren&amp;rsquo;t used polymorphically - &lt;code&gt;final&lt;/code&gt; is unnecessary.&#xA;Every (good) C++ developer is taught early on that you shouldn&amp;rsquo;t use a class in a polymorphic inheritance hierarchy if it doesn&amp;rsquo;t have any &lt;code&gt;virtual&lt;/code&gt; functions.&#xA;&lt;code&gt;Public&lt;/code&gt; inheritance there makes no sense and is harmful.&#xA;Everybody knows that, the &lt;code&gt;final&lt;/code&gt; is just there to enforce it.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;li&gt;&#xA;&lt;p&gt;There are only little use cases for &lt;code&gt;final&lt;/code&gt; in polymorphic hierarchies.&#xA;So in general you don&amp;rsquo;t need it.&lt;/p&gt;&#xA;&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p&gt;This has spawned a discussion both on reddit and in the blog comments,&#xA;so I decided to write this follow-up to unify the discussion and write about each argument.&lt;/p&gt;</description>
    </item>
    <item>
      <title>You (probably) don&#39;t want `final` classes</title>
      <link>https://www.foonathan.net/2016/05/final/</link>
      <pubDate>Fri, 27 May 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/05/final/</guid>
      <description>&lt;p&gt;C++11 introduced the &lt;code&gt;final&lt;/code&gt; &amp;ldquo;keyword&amp;rdquo;.&#xA;It can be used to mark member functions and classes as &lt;code&gt;final&lt;/code&gt;,&#xA;meaning that they cannot be overridden in derived classes/be base classes.&lt;/p&gt;&#xA;&lt;p&gt;In this post I&amp;rsquo;ll take a closer look and explain why I consider the use of &lt;code&gt;final&lt;/code&gt; classes problematic in some cases.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Issue driven development</title>
      <link>https://www.foonathan.net/2016/05/issue-driven-development/</link>
      <pubDate>Sat, 21 May 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/05/issue-driven-development/</guid>
      <description>&lt;p&gt;A few weeks ago I &lt;a href=&#34;https://twitter.com/foonathan&#34;&gt;tweeted&lt;/a&gt; the following:&lt;/p&gt;&#xA;&lt;blockquote class=&#34;twitter-tweet&#34; data-lang=&#34;en&#34;&gt;&lt;p lang=&#34;en&#34; dir=&#34;ltr&#34;&gt;I&amp;#39;m now doing issue driven development using Gogs.&lt;br&gt;&lt;br&gt;It is *really* great, I can now measure how much I&amp;#39;ve done and plan better.&lt;/p&gt;&amp;mdash; Jonathan Müller (@foonathan) &lt;a href=&#34;https://twitter.com/foonathan/status/721411294595821568&#34;&gt;April 16, 2016&lt;/a&gt;&lt;/blockquote&gt;&#xA;&lt;script async src=&#34;//platform.twitter.com/widgets.js&#34; charset=&#34;utf-8&#34;&gt;&lt;/script&gt;&#xA;&lt;p&gt;I was requested to give a review about it:&lt;/p&gt;&#xA;&lt;blockquote class=&#34;twitter-tweet&#34; data-lang=&#34;en&#34;&gt;&lt;p lang=&#34;en&#34; dir=&#34;ltr&#34;&gt;. &lt;a href=&#34;https://twitter.com/irrequietus&#34;&gt;@irrequietus&lt;/a&gt; I&amp;#39;ll file an issue. :D&lt;/p&gt;&amp;mdash; Jonathan Müller (@foonathan) &lt;a href=&#34;https://twitter.com/foonathan/status/721411828421627904&#34;&gt;April 16, 2016&lt;/a&gt;&lt;/blockquote&gt;&#xA;&lt;script async src=&#34;//platform.twitter.com/widgets.js&#34; charset=&#34;utf-8&#34;&gt;&lt;/script&gt;&#xA;&lt;p&gt;This is basically the workflow I&amp;rsquo;m doing for issue driven development.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Standardese - a (work-in-progress) nextgen Doxygen</title>
      <link>https://www.foonathan.net/2016/05/standardese-nextgen-doxygen/</link>
      <pubDate>Fri, 06 May 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/05/standardese-nextgen-doxygen/</guid>
      <description>&lt;p&gt;Documentation is essential.&#xA;Without knowing what certain functions/classes/&amp;hellip; do, it is very difficult to use &lt;em&gt;any&lt;/em&gt; code properly.&lt;/p&gt;&#xA;&lt;p&gt;Tools can help to provide a documentation.&#xA;They can extract information from the source code and combine it with manually written information to generate documentation in a human readable output format.&lt;/p&gt;&#xA;&lt;p&gt;There is a problem though: The current tools for C++ documentation aren&amp;rsquo;t that great.&#xA;This post explains why and provides a (work-in-progress) solution.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How I have beaten Boost.Pool #4: About abstractions and algorithms</title>
      <link>https://www.foonathan.net/2016/04/boosting-pools-4/</link>
      <pubDate>Mon, 18 Apr 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/04/boosting-pools-4/</guid>
      <description>&lt;blockquote&gt;&#xA;&lt;p&gt;And apparently also about alliterations.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;!--excerpt--&gt;&#xA;&lt;p&gt;The last posts showed low-level techniques like ensuring inlining or removing branches.&lt;/p&gt;&#xA;&lt;p&gt;But those techniques alone were not sufficient.&lt;/p&gt;&#xA;&lt;p&gt;In this series, I&amp;rsquo;ll explain my changes and share some lessons about optimization I&amp;rsquo;ve learned in the process of beating Boost.Pool.&#xA;The final post shows how to apply those techniques when designing your abstractions and the importance of smart algorithms.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How I have beaten Boost.Pool #3: Branches are bad</title>
      <link>https://www.foonathan.net/2016/04/boosting-pools-3/</link>
      <pubDate>Wed, 13 Apr 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/04/boosting-pools-3/</guid>
      <description>&lt;blockquote&gt;&#xA;&lt;p&gt;Yes, exaggerated title.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;!--excerpt--&gt;&#xA;&lt;p&gt;Branches and conditional jumps are essential for every program, you cannot write anything but the most trivial code without them.&#xA;Yet they sometimes have a certain overhead and can lead to problems in performance critical code paths.&lt;/p&gt;&#xA;&lt;p&gt;It is often faster if they weren&amp;rsquo;t there.&#xA;But how can you do that?&lt;/p&gt;&#xA;&lt;p&gt;In this series, I&amp;rsquo;ll explain my changes and share some lessons about optimization I&amp;rsquo;ve learned in the process of beating Boost.Pool.&#xA;This time its all about branches and a more detailed information about the &lt;code&gt;detail::small_free_memory_list&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>(Awesome?) Allocator Additions - Thoughts regarding allocator proposals</title>
      <link>https://www.foonathan.net/2016/04/allocator-proposals/</link>
      <pubDate>Mon, 04 Apr 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/04/allocator-proposals/</guid>
      <description>&lt;p&gt;The &lt;a href=&#34;http://www.open-std.org/jtc1/sc22/wg21/docs/papers/&#34;&gt;C++ Standards Committee Papers&lt;/a&gt; of the &lt;a href=&#34;http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/#mailing2016-03&#34;&gt;post-Jacksonville mailing&lt;/a&gt; were recently published.&#xA;There are few quite interesting ones that deal with the &lt;a href=&#34;http://en.cppreference.com/w/cpp/concept/Allocator&#34;&gt;STL&amp;rsquo;s allocator model&lt;/a&gt;:&#xA;&lt;a href=&#34;http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0177r2.html&#34;&gt;P0177R1 - Cleaning up allocator_traits&lt;/a&gt;, &lt;a href=&#34;http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0178r0.html&#34;&gt;P0178R0 - Allocators and swap&lt;/a&gt;(actually from February) and &lt;a href=&#34;http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0310r0.pdf&#34;&gt;P0310R0 - Splitting node and array allocation in allocators&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In this post, I&amp;rsquo;d like to discuss those with you and explain why I really hope some of them they will accepted.&#xA;The first parts are also a follow-up to &lt;a href=&#34;https://www.foonathan.net/blog/2015/10/05/allocatorawarecontainer-propagation-pitfalls.html&#34;&gt;AllocatorAwareContainer: Introduction and pitfalls of propagate_on_container_XXX defaults&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How I have beaten Boost.Pool #2: Inlining is key</title>
      <link>https://www.foonathan.net/2016/03/boosting-pools-2/</link>
      <pubDate>Tue, 29 Mar 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/03/boosting-pools-2/</guid>
      <description>&lt;p&gt;Calling a function has a certain overhead.&#xA;Registers must be saved, a new stack frame pushed,&amp;hellip;&#xA;For small functions this overhead is more than the actual implementation of the function!&lt;/p&gt;&#xA;&lt;p&gt;For those, it is much better if the compiler would copy-paste the implementation directly into the call site.&#xA;This is what inlining does.&lt;/p&gt;&#xA;&lt;p&gt;Luckily, the compiler is usually able to do this optimization.&#xA;Or can it?&lt;/p&gt;&#xA;&lt;p&gt;In this series, I&amp;rsquo;ll explain my changes and share some lessons about optimization I&amp;rsquo;ve learned in the process of beating Boost.Pool.&#xA;This time I&amp;rsquo;m going to cover inlining.&#xA;I&amp;rsquo;m going to share some of guidelines I&amp;rsquo;ve learned and also going to give you a look into some of &lt;a href=&#34;https://github.com/foonathan/memory&#34;&gt;memory`s&lt;/a&gt; internal code and design.&lt;/p&gt;</description>
    </item>
    <item>
      <title>How I have beaten Boost.Pool #1: Introduction and profiling results</title>
      <link>https://www.foonathan.net/2016/03/boosting-pools-1/</link>
      <pubDate>Fri, 18 Mar 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/03/boosting-pools-1/</guid>
      <description>&lt;p&gt;When I&amp;rsquo;ve released &lt;a href=&#34;https://www.foonathan.net/blog/2016/02/23/memory-0.5.html&#34;&gt;memory 0.5&lt;/a&gt;, a guy on reddit &lt;a href=&#34;https://www.reddit.com/r/cpp/comments/478ff5/foonathanblog_memory_05_better_build_system/d0c7nx5&#34;&gt;asked&lt;/a&gt; how my library compared to &lt;a href=&#34;http://www.boost.org/doc/libs/1_60_0/libs/pool/doc/html/&#34;&gt;Boost.Pool&lt;/a&gt;.&#xA;I provided a feature comparison and also quickly profiled both Boost&amp;rsquo;s and my implementation.&#xA;Sadly, Boost.Pool did beat my library - in most cases.&lt;/p&gt;&#xA;&lt;p&gt;So over the last weeks, I&amp;rsquo;ve took care of my performance problems and rewrote my implementations.&#xA;So in version &lt;a href=&#34;https://github.com/foonathan/memory/releases/tag/v0.5-1&#34;&gt;0.5-1&lt;/a&gt; they are basically still using the same algorithm, but now my library is equal or faster than Boost.Pool.&lt;/p&gt;&#xA;&lt;p&gt;In this series, I&amp;rsquo;ll explain my changes and share some lessons about optimization I&amp;rsquo;ve learned doing them.&#xA;The first part is an introduction to the different allocation algorithms used here and gives an overview about the profiling results.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Performing arbitrary calculations with the Concept TS</title>
      <link>https://www.foonathan.net/2016/03/computational-concepts/</link>
      <pubDate>Thu, 10 Mar 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/03/computational-concepts/</guid>
      <description>&lt;p&gt;Last Tuesday I took a closer look at the &lt;a href=&#34;http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/n4553.pdf&#34;&gt;Concept TS&lt;/a&gt;.&#xA;This followed a discussion about the power and usefulness of concepts regarding a replacement for TMP (shout-out to &lt;a href=&#34;https://twitter.com/irrequietus&#34;&gt;@irrequietus&lt;/a&gt; and &lt;a href=&#34;https://twitter.com/Manu343726&#34;&gt;@Manu343726&lt;/a&gt;).&#xA;So after compiling the GCC trunk that has concept support, I&amp;rsquo;ve specifically looked in a way to use concepts alone for doing arbitrary calculations.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;Attention: This is completely pointless.&#xA;You&amp;rsquo;ve been warned.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;For that, I tried to implement a &lt;code&gt;Prime_number&lt;/code&gt; concept that checks whether a given number is a prime number.&#xA;It should use only concepts and &lt;code&gt;require&lt;/code&gt; to do the calculation.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Tutorial: Easily supporting CMake install and find_package()</title>
      <link>https://www.foonathan.net/2016/03/cmake-install/</link>
      <pubDate>Thu, 03 Mar 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/03/cmake-install/</guid>
      <description>&lt;p&gt;As of &lt;a href=&#34;https://www.foonathan.net/blog/2016/02/23/memory-0.5.html&#34;&gt;version 0.5&lt;/a&gt; my &lt;a href=&#34;https://github.com/foonathan/memory&#34;&gt;memory library&lt;/a&gt; now provides support for system-wide installation and &lt;a href=&#34;https://cmake.org&#34;&gt;CMake&lt;/a&gt;&amp;rsquo;s &lt;code&gt;find_package()&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Because I&amp;rsquo;ve spent hours of trial and error to come up with it, I&amp;rsquo;ll document it here.&#xA;In this post, I will show you how to install your library so that it can be used easily by other projects.&#xA;In particular, the system will be able to handle multiple installed versions and multiple configurations.&lt;/p&gt;&#xA;&lt;p&gt;Throughout this post, I&amp;rsquo;ll be assuming a 3.x CMake version and an already existing CMake project.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Memory 0.5: Better build system, Low-level Allocators, BlockAllocator &amp; Your Feedback is needed</title>
      <link>https://www.foonathan.net/2016/02/memory-0.5/</link>
      <pubDate>Tue, 23 Feb 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/02/memory-0.5/</guid>
      <description>&lt;p&gt;I thought the last release has taken a long time, this one took even longer for less changes!&#xA;But now &lt;a href=&#34;https://github.com/foonathan/memory&#34;&gt;foonathan/memory&lt;/a&gt; is finally released.&#xA;This time things get low-level to allow a better high-level.&lt;/p&gt;&#xA;&lt;p&gt;&lt;em&gt;&lt;a href=&#34;https://github.com/foonathan/memory&#34;&gt;foonathan/memory&lt;/a&gt; is a library providing various memory allocators and adapter classes.&#xA;Those allocators use a new &lt;code&gt;RawAllocator&lt;/code&gt; concept that is simpler than STL&amp;rsquo;s &lt;code&gt;Allocator&lt;/code&gt; and allows better control over the allocation aspect.&#xA;Adapters and traits ensure compatibility with the existing model,&#xA;allowing usage in STL or other containers.&lt;/em&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Implementation Challenge: A count leading zeroes function</title>
      <link>https://www.foonathan.net/2016/02/implementation-challenge-2/</link>
      <pubDate>Thu, 11 Feb 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/02/implementation-challenge-2/</guid>
      <description>&lt;p&gt;When doing arithmetic in a programming language there is the arcane art of optimizing with the help of bit-wise operations.&#xA;Of course I&amp;rsquo;m talking about Bit Hacks.&lt;/p&gt;&#xA;&lt;p&gt;On a readability and maintainability ranking from 1 to &lt;code&gt;awk&lt;/code&gt; Bit Hacks reach a level of Brainfuck.&#xA;Yet they can be an incredibly low-level optimization useful to tweak the last bit of performance out of an operation but are difficult to get right and 100% portable.&lt;/p&gt;&#xA;&lt;p&gt;In this post we&amp;rsquo;ll take a look at a rather easy function - &lt;code&gt;clz(x)&lt;/code&gt; that will return the number of leading zero bits in an &lt;code&gt;unsigned&lt;/code&gt; integer type &lt;code&gt;x&lt;/code&gt;.&#xA;In particular I&amp;rsquo;ll show you how to properly wrap GCC&amp;rsquo;s &lt;code&gt;__builtin_clz()&lt;/code&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>One of C&#43;&#43; most underrated features: Namespace aliases</title>
      <link>https://www.foonathan.net/2016/01/namespace-alias/</link>
      <pubDate>Tue, 26 Jan 2016 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2016/01/namespace-alias/</guid>
      <description>&lt;p&gt;About two months ago I wrote the following &lt;a href=&#34;https://www.redit.com/r/cpp&#34;&gt;r/cpp&lt;/a&gt; comment:&lt;/p&gt;&#xA;&lt;div class=&#34;reddit-embed&#34; data-embed-media=&#34;www.redditmedia.com&#34; data-embed-parent=&#34;true&#34; data-embed-live=&#34;true&#34; data-embed-created=&#34;2016-01-26T10:31:38.484Z&#34;&gt;&lt;a href=&#34;https://www.reddit.com/r/cpp/comments/3u701q/functionalplus_helps_you_write_concise_and/cxcphlf&#34;&gt;Comment&lt;/a&gt; from discussion &lt;a href=&#34;https://www.reddit.com/r/cpp/comments/3u701q/functionalplus_helps_you_write_concise_and/&#34;&gt;FunctionalPlus: helps you write concise and readable C++ code.&lt;/a&gt;.&lt;/div&gt;&lt;script async src=&#34;https://www.redditstatic.com/comment-embed.js&#34;&gt;&lt;/script&gt;&#xA;&lt;p&gt;In the thread a new library was presented.&#xA;One user complained about the long namespace name,&#xA;(s)he got the above replies. Judging by the number of upvotes, people seemed to agree with my comment.&#xA;In this blog post I am going to elaborate it.&lt;/p&gt;&#xA;&lt;p&gt;But first, let me tell you a little story about me.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Implementation Challenge: Traits for Concepts with optional functionality</title>
      <link>https://www.foonathan.net/2015/12/implementation-challenge-1/</link>
      <pubDate>Tue, 15 Dec 2015 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2015/12/implementation-challenge-1/</guid>
      <description>&lt;p&gt;Traits classes are very powerful.&#xA;They allow to associate information and functionality with arbitrary classes in a non-intrusive way.&#xA;This makes it possible to use any type in a certain template as long as all access is done through the traits and there is an appropriate specialization.&lt;/p&gt;&#xA;&lt;p&gt;The default specialization often just forwards to a member function.&#xA;But for some functionality the types don&amp;rsquo;t necessarily need to provide it, it&amp;rsquo;s optional.&#xA;Then the traits define a default implementation that is used as a fallback.&#xA;In this post, I will show you how to implement such traits classes.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Controlling overload resolution #4: SFINAE</title>
      <link>https://www.foonathan.net/2015/11/overload-resolution-4/</link>
      <pubDate>Mon, 30 Nov 2015 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2015/11/overload-resolution-4/</guid>
      <description>&lt;p&gt;Overload resolution is one of C++ most complicated things and yet it works most of the time without the need to think about it.&#xA;In this mini-series, I will show you how to control this complex machinery so it is even more powerful and completely under your control.&lt;/p&gt;&#xA;&lt;p&gt;The fourth post shows you a weirdly named and powerful alternative to tag dispatching: SFINAE.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Controlling overload resolution #3: Tag dispatching</title>
      <link>https://www.foonathan.net/2015/11/overload-resolution-3/</link>
      <pubDate>Mon, 16 Nov 2015 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2015/11/overload-resolution-3/</guid>
      <description>&lt;p&gt;Overload resolution is one of C++ most complicated things and yet it works most of the time without the need to think about it.&#xA;In this mini-series, I will show you how to control this complex machinery so it is even more powerful and completely under your control.&lt;/p&gt;&#xA;&lt;p&gt;The third post shows you the power of tag dispatching to select from multiple implementations of a (templated) function. This allows powerful optimization for types with special properties.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Controlling overload resolution #2: Improving error messages for failed overload resolution</title>
      <link>https://www.foonathan.net/2015/11/overload-resolution-2/</link>
      <pubDate>Mon, 02 Nov 2015 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2015/11/overload-resolution-2/</guid>
      <description>&lt;p&gt;Overload resolution is one of C++ most complicated things and yet it works most of the time without the need to think about it.&#xA;In this mini-series, I will show you how to control this complex machinery so it is even more powerful and completely under your control.&lt;/p&gt;&#xA;&lt;p&gt;The second post shows you a simple way to improve the error messages when overload resolution fails and how to customize it completely.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Controlling overload resolution #1: Preventing implicit conversions</title>
      <link>https://www.foonathan.net/2015/10/overload-resolution-1/</link>
      <pubDate>Fri, 16 Oct 2015 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2015/10/overload-resolution-1/</guid>
      <description>&lt;p&gt;Overload resolution is one of C++ most complicated things and yet it works most of the time without the need to think about it.&#xA;In this mini-series, I will show you how to control this complex machinery so it is even more powerful and completely under your control.&lt;/p&gt;&#xA;&lt;p&gt;The first post shows you how to delete candidates and how you can use that to prevent implicit conversions.&lt;/p&gt;</description>
    </item>
    <item>
      <title>AllocatorAwareContainer: Introduction and pitfalls of propagate_on_container_XXX defaults</title>
      <link>https://www.foonathan.net/2015/10/allocatorawarecontainer-propagation-pitfalls/</link>
      <pubDate>Mon, 05 Oct 2015 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2015/10/allocatorawarecontainer-propagation-pitfalls/</guid>
      <description>&lt;p&gt;While I was writing the &lt;a href=&#34;https://memory.foonathan.net/classfoonathan_1_1memory_1_1std__allocator.html&#34;&gt;std_allocator adapter&lt;/a&gt; of &lt;a href=&#34;https://github.com/foonathan/memory&#34;&gt;foonathan/memory&lt;/a&gt; I&amp;rsquo;ve learned some not so well-known facts about the STL &lt;code&gt;Allocator&lt;/code&gt; and &lt;code&gt;AllocatorAwareContainer&lt;/code&gt; concepts I&amp;rsquo;d like to share.&#xA;Let&amp;rsquo;s take a deep breath and dive in into an aspect of the STL containers that isn&amp;rsquo;t that well covered: Allocator storage.&lt;/p&gt;&#xA;&lt;p&gt;I will explain the comparison properties of Allocators, show the C++11 &lt;code&gt;propagate_on_container_XXX&lt;/code&gt; traits and how the combination of the two can lead to an unnecessary pessimization and a probably not widely known case of undefined behavior.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Memory 0.4: Polishing, Error handling, Storage, Traits, Documentation and more</title>
      <link>https://www.foonathan.net/2015/09/memory-0.4/</link>
      <pubDate>Sat, 12 Sep 2015 00:00:00 +0000</pubDate>
      <guid>https://www.foonathan.net/2015/09/memory-0.4/</guid>
      <description>&lt;p&gt;It took a really long time - three months minus one day - but I have finally finished version 0.4 of &lt;a href=&#34;https://github.com/foonathan/memory&#34;&gt;foonathan/memory&lt;/a&gt;.&#xA;The release contains a lot of changes and has more than doubled the number of commits.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
