<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Pierre Gradot</title>
		<link>https://gradot.dev/blog/</link>
		<description>Recent content on Pierre Gradot</description>
		<generator>Hugo</generator>
		<language>en-us</language>
		
		
		
		
			<lastBuildDate>Tue, 06 Oct 2026 11:13:06 +0200</lastBuildDate>
		
			<atom:link href="https://gradot.dev/blog/index.xml" rel="self" type="application/rss+xml" />
			<item>
				<title>PID, TID, TGID and Why Processes and Threads Don&#39;t Really Exist in Linux</title>
				<link>https://gradot.dev/blog/posts/2026/pid-tid-linux/</link>
				<pubDate>Tue, 06 Oct 2026 11:13:06 +0200</pubDate>
				<guid>https://gradot.dev/blog/posts/2026/pid-tid-linux/</guid>
				<description>&lt;p&gt;We&amp;rsquo;ve all learned that a process has an ID (the so-called PID for &lt;strong&gt;P&lt;/strong&gt;rocess &lt;strong&gt;ID&lt;/strong&gt;entifier), that a process can have one or more threads, and that each thread also has an ID (the so-called TID for &lt;strong&gt;T&lt;/strong&gt;hread &lt;strong&gt;ID&lt;/strong&gt;entifier). At least, this is what we have been taught in computer science classes, and what we read in books and blogs.&lt;/p&gt;&#xA;&lt;p&gt;How surprised would you be to learn that processes and even threads don&amp;rsquo;t really exist in Linux?&lt;/p&gt;</description>
			</item>
			<item>
				<title>User-Defined Deduction Guides for Class Templates in C&#43;&#43;</title>
				<link>https://gradot.dev/blog/posts/2025/cpp-template-deducation-guide/</link>
				<pubDate>Mon, 25 Aug 2025 10:10:00 +0200</pubDate>
				<guid>https://gradot.dev/blog/posts/2025/cpp-template-deducation-guide/</guid>
				<description>&lt;p&gt;I remember when I first got serious about modern C++. It was in 2017, my company was starting a new project from scratch, and we chose the latest standard: C++17, which had just been released. Diving into all the modern features of C++, I remember one feature that left me particularly puzzled: &lt;a href=&#34;https://en.cppreference.com/w/cpp/language/ctad.html#User-defined_deduction_guides&#34;&gt;user-defined deduction guides&lt;/a&gt;. They are used to influence &lt;a href=&#34;https://en.cppreference.com/w/cpp/language/class_template_argument_deduction.html&#34;&gt;CTAD (Class Template Argument Deduction)&lt;/a&gt;, which was a major feature of C++17. I was puzzled because I couldn&amp;rsquo;t understand why anyone would ever need to write such a guide by hand&amp;hellip;&lt;/p&gt;</description>
			</item>
			<item>
				<title>How to Fix &#34;Low Disk Space on `/boot`&#34; on Linux</title>
				<link>https://gradot.dev/blog/posts/2025/linux-boot-partition-full/</link>
				<pubDate>Sun, 15 Jun 2025 10:54:12 +0200</pubDate>
				<guid>https://gradot.dev/blog/posts/2025/linux-boot-partition-full/</guid>
				<description>&lt;p&gt;One day, you power up your computer, wait for Linux to boot, log in&amp;hellip; and this message pops up:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;https://gradot.dev/blog/posts/2025/linux-boot-partition-full/1-low-disk-space-on-boot.png&#34; alt=&#34;low disk space on boot&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;You might decide to ignore it, or you might think this is an issue worth looking into. And you’d be right!&lt;/p&gt;&#xA;&lt;p&gt;However, clicking &amp;ldquo;Examine&amp;rdquo; doesn&amp;rsquo;t really tell you how to fix the issue. It &amp;ldquo;just&amp;rdquo; shows you the disk usage analysis of the &lt;code&gt;/boot&lt;/code&gt; partition:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;https://gradot.dev/blog/posts/2025/linux-boot-partition-full/2-disk-usage-analyzer-before.png&#34; alt=&#34;disk usage analyzer before cleanup&#34;&gt;&lt;/p&gt;</description>
			</item>
			<item>
				<title>clang-tidy, const &amp; (N)RVO</title>
				<link>https://gradot.dev/blog/posts/2025/cpp-clang-tidy-const-nrvo/</link>
				<pubDate>Sun, 01 Jun 2025 21:33:00 +0100</pubDate>
				<guid>https://gradot.dev/blog/posts/2025/cpp-clang-tidy-const-nrvo/</guid>
				<description>&lt;p&gt;Almost one year ago, clang-tidy threw an unexpected and unfamiliar message in my face: &lt;code&gt;warning: constness of &#39;str&#39; prevents automatic move [performance-no-automatic-move]&lt;/code&gt; (documented &lt;a href=&#34;https://clang.llvm.org/extra/clang-tidy/checks/performance/no-automatic-move.html&#34;&gt;here&lt;/a&gt;). The offending code looked something like this:&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;auto&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;build_path&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;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;amp;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;basedir&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;index&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;&#x9;&lt;span class=&#34;k&#34;&gt;const&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;auto&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;str&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;fmt&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;format&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;{}/output/{}&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;basedir&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;index&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;&#x9;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#x9;&lt;span class=&#34;n&#34;&gt;fmt&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;{}&lt;/span&gt;&lt;span class=&#34;se&#34;&gt;\n&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&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;&#x9;&lt;span class=&#34;c1&#34;&gt;// ... do some work with &amp;#39;str&amp;#39;...&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#x9;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&#x9;&lt;span class=&#34;k&#34;&gt;return&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;str&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;;&lt;/span&gt; &lt;span class=&#34;c1&#34;&gt;// &amp;lt;-- the warning was here&#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;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;I didn’t have time to investigate, so I wrote down a note, swore I would look into it later, and just forgot&amp;hellip; Until today. I thought it would be simple. It was not. Because, as always, C++ is full of surprises.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Manually Install WiFi Drivers on Linux</title>
				<link>https://gradot.dev/blog/posts/2025/linux-driver-wifi/</link>
				<pubDate>Sun, 16 Mar 2025 19:22:58 +0100</pubDate>
				<guid>https://gradot.dev/blog/posts/2025/linux-driver-wifi/</guid>
				<description>&lt;p&gt;On December 24th, 2024, Debian had a gift for me: it installed Linux kernel 6.11.10, and suddenly the WiFi module of my laptop stopped working. I quickly found a workaround (selecting an older kernel with GRUB during boot) and hoped that the problem would be fixed by the next kernel update or by a firmware update from my laptop&amp;rsquo;s manufacturer. Sadly, kernel 6.12 arrived and nothing changed. I finally took some time to really investigate the issue.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Resizing Partitions on Linux</title>
				<link>https://gradot.dev/blog/posts/2024/resize-fs/</link>
				<pubDate>Thu, 29 Aug 2024 20:00:00 +0100</pubDate>
				<guid>https://gradot.dev/blog/posts/2024/resize-fs/</guid>
				<description>&lt;p&gt;Sometimes, you need to resize your partitions on Linux. And this may not be as easy as you think&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;When I installed Debian on my work computer a few months ago, the wizard suggested creating 2 separate partitions: one for root (with the OS itself), another for home (with my personal data). Alas! The suggested sizes (that I naively accepted) were highly unsuitable and a month later, the root partition (only 40 GB) was full. I had to resize them. It turns out that now, 5 months later, the home is full (I really generate a lot of data for my current project). It&amp;rsquo;s time to resize my partitions again but this time I will keep track of the entire procedure in this article. Who knows when I will have to resize them one more time&amp;hellip;&lt;/p&gt;</description>
			</item>
			<item>
				<title>CMake on STM32 | Episode 8: building with Docker</title>
				<link>https://gradot.dev/blog/posts/2024/cmake-on-stm32-docker/</link>
				<pubDate>Mon, 18 Mar 2024 20:00:00 +0100</pubDate>
				<guid>https://gradot.dev/blog/posts/2024/cmake-on-stm32-docker/</guid>
				<description>&lt;p&gt;In this episode, we will use Docker to set up and manage our build environment.&lt;/p&gt;&#xA;&lt;p&gt;The embedded world doesn&amp;rsquo;t always embrace the latest software development techniques. I acknowledged this in the previous &lt;a href=&#34;https://gradot.dev/blog/posts/2024/cmake-on-stm32-unit-tests/&#34;&gt;episode about unit tests&lt;/a&gt;. Four years ago, when I started this series, I was totally unaware of Docker for instance. Since then, I have used it for non-embedded projects and I think it could have solved some issues I encountered in the past. I would like to share my experience and demonstrate that it can perfectly fit in an MCU project.&lt;/p&gt;</description>
			</item>
			<item>
				<title>CMake on STM32 | Episode 7: unit tests</title>
				<link>https://gradot.dev/blog/posts/2024/cmake-on-stm32-unit-tests/</link>
				<pubDate>Thu, 15 Feb 2024 20:00:00 +0100</pubDate>
				<guid>https://gradot.dev/blog/posts/2024/cmake-on-stm32-unit-tests/</guid>
				<description>&lt;p&gt;It&amp;rsquo;s been almost four years, and it&amp;rsquo;s about time to revive this series on CMake and STM32 (or MCUs in general, STM32 just serves as a tangible example).&lt;/p&gt;&#xA;&lt;p&gt;Funny enough, I&amp;rsquo;m not working with microcontrollers anymore&amp;hellip; This is a very recent change in my professional career, even if I think I will probably work again with MCUs sooner or later. However, I still use CMake to build C++ projects! The real reason to resume this series is my desire to write an article about Docker for builds. In 2020, I had never used Docker at all. Today, I use it very often, and I&amp;rsquo;m convinced it could have solved some build and environment issues back then.&lt;/p&gt;</description>
			</item>
			<item>
				<title>vtables under the surface | Episode 3 - How virtual functions are actually called</title>
				<link>https://gradot.dev/blog/posts/2024/vtables-3-construction-and-call/</link>
				<pubDate>Sun, 07 Jan 2024 20:00:00 +0100</pubDate>
				<guid>https://gradot.dev/blog/posts/2024/vtables-3-construction-and-call/</guid>
				<description>&lt;p&gt;In this episode, we will see how invoking a virtual function in C++ translates into assembly instructions. We will see how our class instance is constructed and how it relates to the vtable. Then, we will see how this vtable is used to call the appropriate function.&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;If you have actually built the project and analyzed the binary in the previous episode, don&amp;rsquo;t forget to remove the &lt;code&gt;-fno-rtti&lt;/code&gt; option and to rebuild the project. I will use this binary as a reference here.&lt;/p&gt;&#xA;&lt;/blockquote&gt;</description>
			</item>
			<item>
				<title>vtables under the surface | Episode 2 - ELF files</title>
				<link>https://gradot.dev/blog/posts/2024/vtables-2-elf/</link>
				<pubDate>Sat, 06 Jan 2024 20:00:00 +0100</pubDate>
				<guid>https://gradot.dev/blog/posts/2024/vtables-2-elf/</guid>
				<description>&lt;p&gt;In this episode, we will explore what vtables mean in terms of bytes within ELF files.&lt;/p&gt;&#xA;&lt;h2 id=&#34;build-output&#34;&gt;Build Output&lt;/h2&gt;&#xA;&lt;p&gt;On Linux, GCC produces ELF files as the result of the compilation process. In our project, the file is &lt;code&gt;a.out&lt;/code&gt;, and we can use the &lt;code&gt;file&lt;/code&gt; command to get details about it:&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-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;$ file a.out &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;a.out: ELF 64-bit LSB pie executable, x86-64, version &lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;SYSV&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;, dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID&lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;sha1&lt;span class=&#34;o&#34;&gt;]=&lt;/span&gt;a87e1cb2356338a14f1a9aa2fef85fb7036bee65, &lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; GNU/Linux 3.2.0, not stripped&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If the compiler has generated vtables for &lt;code&gt;Base&lt;/code&gt; and &lt;code&gt;Derived&lt;/code&gt;, there must be corresponding symbols and bytes in the binary.&lt;/p&gt;</description>
			</item>
			<item>
				<title>vtables under the surface | Episode 1 - Concepts</title>
				<link>https://gradot.dev/blog/posts/2024/vtables-1-concepts/</link>
				<pubDate>Fri, 05 Jan 2024 20:00:00 +0100</pubDate>
				<guid>https://gradot.dev/blog/posts/2024/vtables-1-concepts/</guid>
				<description>&lt;p&gt;If you&amp;rsquo;ve been around C++ for a while, you&amp;rsquo;ve likely come across the terms &amp;ldquo;vtable&amp;rdquo;, &amp;ldquo;virtual table&amp;rdquo; or &amp;ldquo;&lt;a href=&#34;https://en.wikipedia.org/wiki/Virtual_method_table&#34;&gt;virtual method table&lt;/a&gt;&amp;rdquo;. Vtables are not part of the C++ standard, even though this concept pops up almost immediately when you try to understand how virtual functions actually work in C++. Indeed, vtables are the most common implementation of polymorphism in C++.&lt;/p&gt;&#xA;&lt;p&gt;You may also have already encountered a cryptic compilation error like &amp;ldquo;undefined reference to &lt;code&gt;vtable for MyClass&lt;/code&gt;&amp;rdquo;. This may have left you perplexed because you didn&amp;rsquo;t explicitly create anything named &amp;ldquo;vtable&amp;rdquo; in your code. This error signals that, under the hood, the compiler generates vtables to handle virtual functions. If you&amp;rsquo;re curious about this error, here is a &lt;a href=&#34;https://stackoverflow.com/questions/3065154/undefined-reference-to-vtable&#34;&gt;good discussion&lt;/a&gt; on Stack Overflow (the &lt;a href=&#34;https://stackoverflow.com/a/57504289&#34;&gt;second answer&lt;/a&gt; is particularly enlightening).&lt;/p&gt;</description>
			</item>
			<item>
				<title>Just in case: Debian Bookworm comes with a buggy GCC</title>
				<link>https://gradot.dev/blog/posts/2023/bookworm-buggy-gcc/</link>
				<pubDate>Fri, 15 Dec 2023 10:10:00 +0100</pubDate>
				<guid>https://gradot.dev/blog/posts/2023/bookworm-buggy-gcc/</guid>
				<description>&lt;p&gt;Last month, I embarked on a new project. I set up a new computer with the latest Debian version, installed my favorite tools, and was all set to code. My first task was to migrate all the repositories from C++14 to C++20. While it might seem as straightforward as updating all the &lt;code&gt;CMakeLists.txt&lt;/code&gt; to replace &lt;code&gt;set (CMAKE_CXX_STANDARD 14)&lt;/code&gt; with &lt;code&gt;set (CMAKE_CXX_STANDARD 20)&lt;/code&gt;, reality proved otherwise (and I knew it would).&lt;/p&gt;</description>
			</item>
			<item>
				<title>CPM.cmake to make CMake&#39;s FetchContent easier</title>
				<link>https://gradot.dev/blog/posts/2022/cmake-cpm/</link>
				<pubDate>Wed, 28 Dec 2022 10:10:00 +0200</pubDate>
				<guid>https://gradot.dev/blog/posts/2022/cmake-cpm/</guid>
				<description>&lt;p&gt;Scrolling through my list of starred projects on GitHub, I saw a tool I had forgotten, &lt;a href=&#34;https://github.com/cpm-cmake/CPM.cmake&#34;&gt;CPM.cmake&lt;/a&gt;, and decided that it was time to try it!&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;CPM.cmake&lt;/code&gt; (or just &lt;code&gt;CPM&lt;/code&gt;) describes itself as &amp;ldquo;a cross-platform CMake script that adds dependency management capabilities to CMake&amp;rdquo;. It&amp;rsquo;s in fact a wrapper around &lt;a href=&#34;https://cmake.org/cmake/help/latest/module/FetchContent.html&#34;&gt;CMake&amp;rsquo;s FetchContent module&lt;/a&gt; that makes it much easier to download packages.&lt;/p&gt;&#xA;&lt;p&gt;To demonstrate its usage, I will build a project that depends on 3 libraries from GitHub: the famous &lt;a href=&#34;https://github.com/catchorg/Catch2&#34;&gt;Catch2&lt;/a&gt; and &lt;a href=&#34;https://github.com/fmtlib/fmt&#34;&gt;fmt&lt;/a&gt;, and the probably not-as-famous-as-it-deserves &lt;a href=&#34;https://github.com/eliaskosunen/scnlib&#34;&gt;scnlib&lt;/a&gt;.&lt;/p&gt;</description>
			</item>
			<item>
				<title>The SYSTEM property from CMake 3.25</title>
				<link>https://gradot.dev/blog/posts/2022/cmake-system-property/</link>
				<pubDate>Fri, 09 Dec 2022 10:10:00 +0100</pubDate>
				<guid>https://gradot.dev/blog/posts/2022/cmake-system-property/</guid>
				<description>&lt;p&gt;CMake 3.25 introduced a new property called &lt;code&gt;SYSTEM&lt;/code&gt;. It will help us handle warnings from 3rd party libraries. Let&amp;rsquo;s see how!&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-issue-with-a-minimal-example-project&#34;&gt;The issue (with a minimal example project)&lt;/h2&gt;&#xA;&lt;p&gt;Here is a minimal example project to reproduce the issue. It simply prints something with the great &lt;a href=&#34;https://github.com/fmtlib/fmt&#34;&gt;&lt;code&gt;fmt&lt;/code&gt;&lt;/a&gt; library:&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;cp&#34;&gt;#include&lt;/span&gt; &lt;span class=&#34;cpf&#34;&gt;&amp;lt;fmt/core.h&amp;gt;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;&#xA;&lt;/span&gt;&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;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;main&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;n&#34;&gt;fmt&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;print&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;The answer is {}&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;42&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;The library is fetched from GitHub thanks to CMake&amp;rsquo;s &lt;a href=&#34;https://cmake.org/cmake/help/latest/module/FetchContent.html&#34;&gt;&lt;code&gt;FetchContent&lt;/code&gt; module&lt;/a&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-cmake&#34; data-lang=&#34;cmake&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;cmake_minimum_required&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;VERSION&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;3.25&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#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;nb&#34;&gt;project&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;CMake_SYSTEM&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#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;err&#34;&gt;&#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;c&#34;&gt;# Set C++ standard&#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;nb&#34;&gt;set&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;CMAKE_CXX_STANDARD&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;20&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#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;nb&#34;&gt;set&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;CMAKE_CXX_STANDARD_REQUIRED&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;ON&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#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;nb&#34;&gt;set&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;CMAKE_CXX_EXTENSIONS&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;OFF&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#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;err&#34;&gt;&#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;c&#34;&gt;# Fetch fmt from GitHub&#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;nb&#34;&gt;include&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;FetchContent&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#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;err&#34;&gt;&#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;nb&#34;&gt;FetchContent_Declare&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;s&#34;&gt;fmt&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;s&#34;&gt;GIT_REPOSITORY&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;https://github.com/fmtlib/fmt.git&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;s&#34;&gt;GIT_TAG&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;9.1.0&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;&lt;span class=&#34;err&#34;&gt;&#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;err&#34;&gt;&#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;nb&#34;&gt;FetchContent_MakeAvailable&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;fmt&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#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;err&#34;&gt;&#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;c&#34;&gt;# Create executable&#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;nb&#34;&gt;add_executable&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;nv&#34;&gt;PROJECT_NAME&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;main.cpp&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#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;err&#34;&gt;&#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;nb&#34;&gt;target_compile_options&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;nv&#34;&gt;PROJECT_NAME&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;PRIVATE&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;-Wall&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;-Wextra&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;-pedantic&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;-Wswitch-enum&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#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;err&#34;&gt;&#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;nb&#34;&gt;target_link_libraries&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;nv&#34;&gt;PROJECT_NAME&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;PRIVATE&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;fmt&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;&lt;span class=&#34;err&#34;&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The project can be built with:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Let&#39;s try C&#43;&#43;20 | Erase elements in a container with std::erase()</title>
				<link>https://gradot.dev/blog/posts/2021/cpp20-std-erase/</link>
				<pubDate>Wed, 15 Dec 2021 11:51:33 +0100</pubDate>
				<guid>https://gradot.dev/blog/posts/2021/cpp20-std-erase/</guid>
				<description>&lt;p&gt;Imagine you have a vector of integers and you want to remove all zeros. It sounds like a simple task, right? Well, before C++20, it wasn&amp;rsquo;t that obvious. Let&amp;rsquo;s see how C++20 makes things easier.&lt;/p&gt;&#xA;&lt;h2 id=&#34;before&#34;&gt;Before&lt;/h2&gt;&#xA;&lt;p&gt;Since the beginning of C++, there is a &lt;a href=&#34;https://en.cppreference.com/w/cpp/algorithm/remove&#34;&gt;free function named &lt;code&gt;std::remove()&lt;/code&gt;&lt;/a&gt;. Young padawans may naively use it like this:&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;cp&#34;&gt;#include&lt;/span&gt; &lt;span class=&#34;cpf&#34;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;&#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;cp&#34;&gt;#include&lt;/span&gt; &lt;span class=&#34;cpf&#34;&gt;&amp;lt;vector&amp;gt;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;&#xA;&lt;/span&gt;&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;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;main&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;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;n&#34;&gt;data&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;{&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;12&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;654&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;4587&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;42&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;for&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;auto&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&#34;nl&#34;&gt;e&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;data&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;n&#34;&gt;std&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;cout&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;e&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;sc&#34;&gt;&amp;#39;\t&amp;#39;&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;n&#34;&gt;std&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;cout&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;sc&#34;&gt;&amp;#39;\n&amp;#39;&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;remove&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;data&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&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;data&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&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;mi&#34;&gt;0&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;&#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;for&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;auto&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&#34;nl&#34;&gt;e&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;data&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;n&#34;&gt;std&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;cout&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;e&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;sc&#34;&gt;&amp;#39;\t&amp;#39;&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;They would get this weird result:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Let&#39;s try C&#43;&#43;20 | std::cmp_* functions</title>
				<link>https://gradot.dev/blog/posts/2021/cpp20-std-cmp/</link>
				<pubDate>Wed, 22 Sep 2021 14:51:48 +0200</pubDate>
				<guid>https://gradot.dev/blog/posts/2021/cpp20-std-cmp/</guid>
				<description>&lt;p&gt;Today, I have discovered a very simple (but yet very efficient and useful) feature from C++20: &lt;a href=&#34;https://en.cppreference.com/w/cpp/utility/intcmp&#34;&gt;the &lt;code&gt;std::cmp_*&lt;/code&gt; functions&lt;/a&gt;. They allow you to compare 2 integers, which can have different signedness, without getting bitten by implicit conversions.&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s have a look at this piece of code:&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;cp&#34;&gt;#include&lt;/span&gt; &lt;span class=&#34;cpf&#34;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;&#xA;&lt;/span&gt;&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;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;main&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;kt&#34;&gt;int&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;o&#34;&gt;-&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;6&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;kt&#34;&gt;unsigned&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;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;3&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;    &#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;if&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;a&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&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;n&#34;&gt;std&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;cout&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;OK: a is lower than b&lt;/span&gt;&lt;span class=&#34;se&#34;&gt;\n&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&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;p&#34;&gt;}&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;else&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;cout&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;Oopsi!&lt;/span&gt;&lt;span class=&#34;se&#34;&gt;\n&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&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;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;Yes, you&amp;rsquo;ve guessed right: it prints &amp;ldquo;&lt;em&gt;Oopsi!&lt;/em&gt;&amp;rdquo;.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Forbid a particular specialization of a template</title>
				<link>https://gradot.dev/blog/posts/2021/cpp-forbid-template-specialization/</link>
				<pubDate>Mon, 11 Jan 2021 09:47:05 +0100</pubDate>
				<guid>https://gradot.dev/blog/posts/2021/cpp-forbid-template-specialization/</guid>
				<description>&lt;p&gt;Let&amp;rsquo;s imagine a simple template function that performs basic numerical computations:&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;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;n&#34;&gt;T&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;f&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;n&#34;&gt;t&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;mi&#34;&gt;2&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;*&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;t&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;3&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;Nothing seems wrong with this function. You can use it on several types: &lt;code&gt;f(15)&lt;/code&gt; returns 33 and &lt;code&gt;T&lt;/code&gt; is &lt;code&gt;int&lt;/code&gt;, &lt;code&gt;f(2.3)&lt;/code&gt; returns 7.6 and &lt;code&gt;T&lt;/code&gt; is &lt;code&gt;double&lt;/code&gt;, etc. If &lt;code&gt;T&lt;/code&gt; is not a type that supports addition and multiplication, you get a compiler error. Example with &lt;code&gt;f(&amp;quot;hello&amp;quot;)&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;code&gt;error: invalid operands to binary expression (&#39;int&#39; and &#39;const char *&#39;)&lt;/code&gt;&lt;/p&gt;&#xA;&lt;/blockquote&gt;</description>
			</item>
			<item>
				<title>Let&#39;s try C&#43;&#43;20 | std::is_constant_evaluated()</title>
				<link>https://gradot.dev/blog/posts/2020/cpp20-is-constant-evaluated/</link>
				<pubDate>Mon, 28 Dec 2020 17:35:02 +0100</pubDate>
				<guid>https://gradot.dev/blog/posts/2020/cpp20-is-constant-evaluated/</guid>
				<description>&lt;p&gt;&lt;code&gt;std::is_constant_evaluated()&lt;/code&gt; is one of the many new small features of C++20. &lt;a href=&#34;http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0595r2.html&#34;&gt;Specified in &lt;code&gt;P0595R2&lt;/code&gt;&lt;/a&gt;, this function is available in the &lt;code&gt;&amp;lt;type_traits&amp;gt;&lt;/code&gt; header. Here is its description from &lt;a href=&#34;https://en.cppreference.com/w/cpp/types/is_constant_evaluated&#34;&gt;cppreference&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;&lt;code&gt;constexpr bool is_constant_evaluated() noexcept;&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;Detects whether the function call occurs within a constant-evaluated context. Returns &lt;code&gt;true&lt;/code&gt; if the evaluation of the call occurs within the evaluation of an expression or conversion that is manifestly constant-evaluated; otherwise returns &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;This sounds pretty straightforward.&lt;/p&gt;&#xA;&lt;h2 id=&#34;benefits-for-constexpr-functions&#34;&gt;Benefits for &lt;code&gt;constexpr&lt;/code&gt; functions&lt;/h2&gt;&#xA;&lt;p&gt;This may be very interesting for &lt;code&gt;constexpr&lt;/code&gt; functions. You probably know that you have no guarantee that a &lt;code&gt;constexpr&lt;/code&gt; function is really executed at compile-time. This depends on how the function is called:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Let&#39;s try C&#43;&#43;20 | using enum</title>
				<link>https://gradot.dev/blog/posts/2020/cpp20-using-enum/</link>
				<pubDate>Tue, 22 Dec 2020 15:47:37 +0100</pubDate>
				<guid>https://gradot.dev/blog/posts/2020/cpp20-using-enum/</guid>
				<description>&lt;p&gt;Proposal &lt;a href=&#34;http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1099r5.html&#34;&gt;P1099R5&lt;/a&gt; by Gašper Ažman and Jonathan Müller adds the possibility to write &lt;code&gt;using enum my_enum;&lt;/code&gt; so that the names inside the enumeration &lt;code&gt;my_enum&lt;/code&gt; can be used directly, without being preceded by &lt;code&gt;my_enum::&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s consider an enumeration like this:&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;enum&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;class&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;EnumWithALongName&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;FirstValue&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;SecondValue&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;YetAnotherValue&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;Until C++17, you had to write their fully qualified names to use the enumerators. Sometimes, it would make code quite verbose:&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;void&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;process&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;EnumWithALongName&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;value&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;switch&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;value&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;case&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;EnumWithALongName&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;:::&lt;/span&gt;&lt;span class=&#34;nl&#34;&gt;FirstValue&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;// stuff&#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;k&#34;&gt;case&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;EnumWithALongName&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;nl&#34;&gt;SecondValue&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;// more stuff&#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;k&#34;&gt;case&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;EnumWithALongName&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;::&lt;/span&gt;&lt;span class=&#34;nl&#34;&gt;YetAnotherValue&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;// OK, I got it, we are dealing with EnumWithALongName...&#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;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;Thanks to C++20, we can now write:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Let&#39;s try C&#43;&#43;20 | explicit(bool)</title>
				<link>https://gradot.dev/blog/posts/2020/cpp20-explicit-bool/</link>
				<pubDate>Mon, 07 Dec 2020 08:52:43 +0100</pubDate>
				<guid>https://gradot.dev/blog/posts/2020/cpp20-explicit-bool/</guid>
				<description>&lt;p&gt;From the many changes of C++20, let&amp;rsquo;s focus today on &lt;code&gt;explicit(bool)&lt;/code&gt;. This feature is described in &lt;a href=&#34;http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0892r2.html&#34;&gt;P0892R2&lt;/a&gt;. The &lt;a href=&#34;https://en.cppreference.com/w/cpp/language/explicit&#34;&gt;&lt;code&gt;explicit&lt;/code&gt; keyword&lt;/a&gt; avoids implicit conversions by unexpectedly calling a constructor. With C++20, it is now possible to have a boolean condition as a &amp;ldquo;parameter&amp;rdquo; to the keyword.&lt;/p&gt;&#xA;&lt;h2 id=&#34;how-it-works&#34;&gt;How it works&lt;/h2&gt;&#xA;&lt;p&gt;This simple code makes it easy to understand how &lt;code&gt;explicit(bool)&lt;/code&gt; works:&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;kt&#34;&gt;bool&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ENABLE_EXPLICIT&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;false&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;&#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;Foo&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;explicit&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;ENABLE_EXPLICIT&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;Foo&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;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;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;n&#34;&gt;Foo&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;mi&#34;&gt;1&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 code compiles fine, but change &lt;code&gt;ENABLE_EXPLICIT&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt; and you will get an error with clang-10.0.0:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Let&#39;s try C&#43;&#43;20 | Range-based for statements with initializer</title>
				<link>https://gradot.dev/blog/posts/2020/cpp20-range-for-initializer/</link>
				<pubDate>Mon, 30 Nov 2020 07:38:47 +0100</pubDate>
				<guid>https://gradot.dev/blog/posts/2020/cpp20-range-for-initializer/</guid>
				<description>&lt;p&gt;&lt;a href=&#34;https://github.com/tkoeppe&#34;&gt;Thomas Köppe&lt;/a&gt; wrote the proposal &lt;a href=&#34;http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0614r1.html&#34;&gt;P0614R1&lt;/a&gt; to describe a new feature called &amp;ldquo;&lt;em&gt;Range-based for statements with initializer&lt;/em&gt;&amp;rdquo;. This document has been approved as part of the C++20 standard.&lt;/p&gt;&#xA;&lt;p&gt;The document is pretty straightforward since the feature is quite simple. If you have heard of &lt;a href=&#34;https://skebanga.github.io/if-with-initializer/&#34;&gt;if statement with initializer&lt;/a&gt; from C++17, then you have probably already guessed what &amp;ldquo;range-based for statements with initializer&amp;rdquo; means.&lt;/p&gt;&#xA;&lt;p&gt;To understand this new feature, let&amp;rsquo;s say we want some code to print all the elements of a collection. The first idea would be to use a &lt;a href=&#34;https://en.cppreference.com/w/cpp/language/range-for&#34;&gt;range-based for loop&lt;/a&gt;. But let&amp;rsquo;s add another requirement: we want to print the index of the element in the collection. Let&amp;rsquo;s write some code before and after C++20 and compare them.&lt;/p&gt;</description>
			</item>
			<item>
				<title>std::optional from C&#43;&#43;17 vs custom type for optional value</title>
				<link>https://gradot.dev/blog/posts/2020/cpp-optional-vs-custom-type/</link>
				<pubDate>Wed, 25 Nov 2020 16:57:35 +0100</pubDate>
				<guid>https://gradot.dev/blog/posts/2020/cpp-optional-vs-custom-type/</guid>
				<description>&lt;p&gt;C++17 has introduced a very useful &lt;a href=&#34;https://en.cppreference.com/w/cpp/utility/optional&#34;&gt;template class, &lt;code&gt;std::optional&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The class template &lt;code&gt;std::optional&lt;/code&gt; manages an optional contained value, i.e. a value that may or may not be present.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;I have been using this feature a lot since 2017, even for a simple optional integer. Today, I got curious: is this template type efficient compared to an equivalent type that I would write myself to achieve the same behavior?&lt;/p&gt;&#xA;&lt;p&gt;Good question, thank you 😆&lt;/p&gt;</description>
			</item>
			<item>
				<title>Let&#39;s try C&#43;&#43;20 | Compare objects</title>
				<link>https://gradot.dev/blog/posts/2020/cpp20-compare-objects/</link>
				<pubDate>Fri, 06 Nov 2020 11:51:21 +0100</pubDate>
				<guid>https://gradot.dev/blog/posts/2020/cpp20-compare-objects/</guid>
				<description>&lt;h1 id=&#34;lets-try-c20--comparisons&#34;&gt;Let&amp;rsquo;s try C++20 | comparisons&lt;/h1&gt;&#xA;&lt;p&gt;C++20 comes with new possibilities to compare objects.&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s start with this simple code where we try to compare 2 objects of user-defined type:&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;cp&#34;&gt;#include&lt;/span&gt; &lt;span class=&#34;cpf&#34;&gt;&amp;lt;iostream&amp;gt;&lt;/span&gt;&lt;span class=&#34;cp&#34;&gt;&#xA;&lt;/span&gt;&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;struct&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;Foo&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;const&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;value&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;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;main&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;n&#34;&gt;Foo&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;mi&#34;&gt;42&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;Foo&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;mi&#34;&gt;66&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;&#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;cout&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&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;boolalpha&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;cout&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&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; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;sc&#34;&gt;&amp;#39;\n&amp;#39;&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;cout&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&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; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;sc&#34;&gt;&amp;#39;\n&amp;#39;&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;&#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;cout&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;a&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;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; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;sc&#34;&gt;&amp;#39;\n&amp;#39;&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;cout&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;a&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;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; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;sc&#34;&gt;&amp;#39;\n&amp;#39;&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;&#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;cout&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;a&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&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;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;sc&#34;&gt;&amp;#39;\n&amp;#39;&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;cout&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;a&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;=&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;lt;&amp;lt;&lt;/span&gt; &lt;span class=&#34;sc&#34;&gt;&amp;#39;\n&amp;#39;&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;This code doesn&amp;rsquo;t compile, no matter which version of C++ you are using. Indeed, none of these operators are implicitly defined by the compiler and we get 6 errors (one per operator):&lt;/p&gt;</description>
			</item>
			<item>
				<title>Let&#39;s try C&#43;&#43;20 | virtual constexpr functions</title>
				<link>https://gradot.dev/blog/posts/2020/cpp20-virtual-constexpr/</link>
				<pubDate>Sat, 31 Oct 2020 12:01:16 +0100</pubDate>
				<guid>https://gradot.dev/blog/posts/2020/cpp20-virtual-constexpr/</guid>
				<description>&lt;p&gt;Once, I wondered if we could have &lt;code&gt;virtual constexpr&lt;/code&gt; functions. It is now possible with C++20 so let&amp;rsquo;s try!&lt;/p&gt;&#xA;&lt;h2 id=&#34;a-piece-of-personal-experience&#34;&gt;A Piece of Personal Experience&lt;/h2&gt;&#xA;&lt;p&gt;Two years ago, I had several classes with a common point: base classes had a pure virtual function to request derived classes to return a constant. Something like this:&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;struct&lt;/span&gt; &lt;span class=&#34;nc&#34;&gt;Memory&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;// Capacity in bytes&#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;k&#34;&gt;virtual&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;unsigned&lt;/span&gt; &lt;span class=&#34;kt&#34;&gt;int&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;capacity&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;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&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;It was the base class for drivers to communicate with a particular memory chip. Each subclass would return the size of the actual memory it handles. For instance, for the &lt;a href=&#34;https://www.microchip.com/wwwproducts/en/25LC160C&#34;&gt;Microchip&amp;rsquo;s 25LC160C EEPROM&lt;/a&gt;:&lt;/p&gt;</description>
			</item>
			<item>
				<title>Let&#39;s try C&#43;&#43;20 | std::span</title>
				<link>https://gradot.dev/blog/posts/2020/cpp20-std-span/</link>
				<pubDate>Wed, 28 Oct 2020 08:38:56 +0100</pubDate>
				<guid>https://gradot.dev/blog/posts/2020/cpp20-std-span/</guid>
				<description>&lt;p&gt;Eventually, I have decided to try C++20 😀&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s start with &lt;code&gt;std::span&lt;/code&gt;!&lt;/p&gt;&#xA;&lt;h2 id=&#34;what-is-a-span&#34;&gt;What is a Span?&lt;/h2&gt;&#xA;&lt;p&gt;Here is the definition given by &lt;a href=&#34;https://en.cppreference.com/w/cpp/container/span&#34;&gt;cppreference&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;The class template &lt;code&gt;span&lt;/code&gt; describes an object that can refer to a contiguous sequence of objects with the first element of the sequence at position zero.&lt;/p&gt;&#xA;&lt;/blockquote&gt;&#xA;&lt;p&gt;Spans are sometimes called &amp;ldquo;views&amp;rdquo; because they don&amp;rsquo;t own the sequence of objects.&lt;/p&gt;&#xA;&lt;p&gt;If you are familiar with &lt;code&gt;std::string_view&lt;/code&gt; from C++17, then you can easily understand the concept of spans. &lt;code&gt;std::string_view&lt;/code&gt;s are somehow spans on sequences of characters. The main difference is that spans can modify the objects while string views can&amp;rsquo;t modify the characters.&lt;/p&gt;</description>
			</item>
			<item>
				<title>Sharing strings between C and Python through byte buffers</title>
				<link>https://gradot.dev/blog/posts/2020/c-python-sharing-strings/</link>
				<pubDate>Wed, 17 Jun 2020 16:40:29 +0200</pubDate>
				<guid>https://gradot.dev/blog/posts/2020/c-python-sharing-strings/</guid>
				<description>&lt;p&gt;If you use a buffer of bytes to share strings between C (or C++) and Python, you may end up with weird results, because both languages do not represent strings the same way.&lt;/p&gt;&#xA;&lt;p&gt;I got bitten lately and here is what I have learnt.&lt;/p&gt;&#xA;&lt;h2 id=&#34;c-strings&#34;&gt;C strings&lt;/h2&gt;&#xA;&lt;p&gt;If you have used C to handle strings once in your lifetime, then you have run into one of the most painful things in C: null-terminated strings 😑&lt;/p&gt;</description>
			</item>
			<item>
				<title>CMake on STM32 | Episode 6: add C&#43;&#43; specific compiler options</title>
				<link>https://gradot.dev/blog/posts/2020/cmake-on-stm32-cpp-options/</link>
				<pubDate>Mon, 04 May 2020 23:28:52 +0200</pubDate>
				<guid>https://gradot.dev/blog/posts/2020/cmake-on-stm32-cpp-options/</guid>
				<description>&lt;p&gt;In &lt;a href=&#34;https://gradot.dev/blog/posts/2020/cmake-on-stm32-cpp-ready/&#34;&gt;episode 4, we started to use C++&lt;/a&gt; but we didn&amp;rsquo;t (*) add C++ specific compiler options. In this episode we will see how to do this. Because guess what: C++ and C are different languages and compiling C code with C++ specific options may &lt;em&gt;not&lt;/em&gt; be a good idea 😄&lt;/p&gt;&#xA;&lt;h2 id=&#34;generator-expression&#34;&gt;Generator expression&lt;/h2&gt;&#xA;&lt;p&gt;(*) This isn&amp;rsquo;t completely true: to fix a linker error I suggested to add &lt;code&gt;-fno-exceptions&lt;/code&gt; and this is clearly a C++ specific option. I didn&amp;rsquo;t show any CMake code but if you tried on your computer, I suppose you simply added it like this and compilation went fine:&lt;/p&gt;</description>
			</item>
			<item>
				<title>CMake on STM32 | Episode 5: additional clean files</title>
				<link>https://gradot.dev/blog/posts/2020/cmake-on-stm32-clean-files/</link>
				<pubDate>Sat, 02 May 2020 17:54:45 +0200</pubDate>
				<guid>https://gradot.dev/blog/posts/2020/cmake-on-stm32-clean-files/</guid>
				<description>&lt;p&gt;In this episode, we will see that some files generated during the build are not deleted during the clean process and we will solve this issue with CMake, of course.&lt;/p&gt;&#xA;&lt;h2 id=&#34;what-is-cleaned&#34;&gt;What is cleaned?&lt;/h2&gt;&#xA;&lt;p&gt;Once the build is done, we can have a look at the content of the output directory:&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-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;λ &lt;span class=&#34;nb&#34;&gt;pwd&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;D:&lt;span class=&#34;se&#34;&gt;\c&lt;/span&gt;make_stm32&lt;span class=&#34;se&#34;&gt;\c&lt;/span&gt;make-build-debug&#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;λ cmake --build .&#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;o&#34;&gt;[&lt;/span&gt; 76%&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt; Building C object CMakeFiles/nucleo-f413zh.out.dir/BSP/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c.obj&#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;o&#34;&gt;[&lt;/span&gt; 80%&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt; Building C object CMakeFiles/nucleo-f413zh.out.dir/BSP/Src/main.c.obj&#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;o&#34;&gt;[&lt;/span&gt; 84%&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt; Building C object CMakeFiles/nucleo-f413zh.out.dir/BSP/Src/stm32f4xx_hal_msp.c.obj&#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;o&#34;&gt;[&lt;/span&gt; 88%&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt; Building C object CMakeFiles/nucleo-f413zh.out.dir/BSP/Src/stm32f4xx_it.c.obj&#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;o&#34;&gt;[&lt;/span&gt; 92%&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt; Building C object CMakeFiles/nucleo-f413zh.out.dir/BSP/Src/system_stm32f4xx.c.obj&#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;o&#34;&gt;[&lt;/span&gt; 96%&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt; Building ASM object CMakeFiles/nucleo-f413zh.out.dir/BSP/startup_stm32f413xx.s.obj&#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;o&#34;&gt;[&lt;/span&gt;100%&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt; Linking C executable nucleo-f413zh.out&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;   text    data     bss     dec     hex filename&#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;m&#34;&gt;7564&lt;/span&gt;      &lt;span class=&#34;m&#34;&gt;20&lt;/span&gt;    &lt;span class=&#34;m&#34;&gt;2668&lt;/span&gt;   &lt;span class=&#34;m&#34;&gt;10252&lt;/span&gt;    280c nucleo-f413zh.out&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;mingw32-make&lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;2&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt;: Leaving directory &lt;span class=&#34;s1&#34;&gt;&amp;#39;D:/cmake_stm32/cmake-build-debug&amp;#39;&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;o&#34;&gt;[&lt;/span&gt;100%&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt; Built target nucleo-f413zh.out&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;mingw32-make&lt;span class=&#34;o&#34;&gt;[&lt;/span&gt;1&lt;span class=&#34;o&#34;&gt;]&lt;/span&gt;: Leaving directory &lt;span class=&#34;s1&#34;&gt;&amp;#39;D:/cmake_stm32/cmake-build-debug&amp;#39;&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;λ ls -l&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;total &lt;span class=&#34;m&#34;&gt;632&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-rw-r--r-- &lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; z19100018 &lt;span class=&#34;m&#34;&gt;1049089&lt;/span&gt;   &lt;span class=&#34;m&#34;&gt;1427&lt;/span&gt; avr.  &lt;span class=&#34;m&#34;&gt;29&lt;/span&gt; 12:17 cmake_install.cmake&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-rw-r--r-- &lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; z19100018 &lt;span class=&#34;m&#34;&gt;1049089&lt;/span&gt;  &lt;span class=&#34;m&#34;&gt;53118&lt;/span&gt; mai    &lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; 12:26 CMakeCache.txt&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;drwxr-xr-x &lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; z19100018 &lt;span class=&#34;m&#34;&gt;1049089&lt;/span&gt;      &lt;span class=&#34;m&#34;&gt;0&lt;/span&gt; mai    &lt;span class=&#34;m&#34;&gt;2&lt;/span&gt; 15:13 CMakeFiles/&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-rw-r--r-- &lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; z19100018 &lt;span class=&#34;m&#34;&gt;1049089&lt;/span&gt;  &lt;span class=&#34;m&#34;&gt;42893&lt;/span&gt; mai    &lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; 12:42 Makefile&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-rw-r--r-- &lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; z19100018 &lt;span class=&#34;m&#34;&gt;1049089&lt;/span&gt;   &lt;span class=&#34;m&#34;&gt;7584&lt;/span&gt; mai    &lt;span class=&#34;m&#34;&gt;2&lt;/span&gt; 15:13 nucleo-f413zh.bin&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-rw-r--r-- &lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; z19100018 &lt;span class=&#34;m&#34;&gt;1049089&lt;/span&gt;  &lt;span class=&#34;m&#34;&gt;11154&lt;/span&gt; mai    &lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; 12:42 nucleo-f413zh.cbp&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-rw-r--r-- &lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; z19100018 &lt;span class=&#34;m&#34;&gt;1049089&lt;/span&gt;  &lt;span class=&#34;m&#34;&gt;21433&lt;/span&gt; mai    &lt;span class=&#34;m&#34;&gt;2&lt;/span&gt; 15:13 nucleo-f413zh.hex&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-rw-r--r-- &lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; z19100018 &lt;span class=&#34;m&#34;&gt;1049089&lt;/span&gt; &lt;span class=&#34;m&#34;&gt;203655&lt;/span&gt; mai    &lt;span class=&#34;m&#34;&gt;2&lt;/span&gt; 15:13 nucleo-f413zh.map&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-rw-r--r-- &lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; z19100018 &lt;span class=&#34;m&#34;&gt;1049089&lt;/span&gt; &lt;span class=&#34;m&#34;&gt;289884&lt;/span&gt; mai    &lt;span class=&#34;m&#34;&gt;2&lt;/span&gt; 15:13 nucleo-f413zh.out&#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;λ ls -l CMakeFiles&lt;span class=&#34;se&#34;&gt;\n&lt;/span&gt;ucleo-f413zh.out.dir&lt;span class=&#34;se&#34;&gt;\B&lt;/span&gt;SP&lt;span class=&#34;se&#34;&gt;\S&lt;/span&gt;rc&lt;span class=&#34;se&#34;&gt;\&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;total &lt;span class=&#34;m&#34;&gt;52&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-rw-r--r-- &lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; z19100018 &lt;span class=&#34;m&#34;&gt;1049089&lt;/span&gt; &lt;span class=&#34;m&#34;&gt;18416&lt;/span&gt; mai    &lt;span class=&#34;m&#34;&gt;2&lt;/span&gt; 15:13 main.c.obj&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-rw-r--r-- &lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; z19100018 &lt;span class=&#34;m&#34;&gt;1049089&lt;/span&gt; &lt;span class=&#34;m&#34;&gt;14956&lt;/span&gt; mai    &lt;span class=&#34;m&#34;&gt;2&lt;/span&gt; 15:13 stm32f4xx_hal_msp.c.obj&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-rw-r--r-- &lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; z19100018 &lt;span class=&#34;m&#34;&gt;1049089&lt;/span&gt;  &lt;span class=&#34;m&#34;&gt;6224&lt;/span&gt; mai    &lt;span class=&#34;m&#34;&gt;2&lt;/span&gt; 15:13 stm32f4xx_it.c.obj&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;-rw-r--r-- &lt;span class=&#34;m&#34;&gt;1&lt;/span&gt; z19100018 &lt;span class=&#34;m&#34;&gt;1049089&lt;/span&gt;  &lt;span class=&#34;m&#34;&gt;7916&lt;/span&gt; mai    &lt;span class=&#34;m&#34;&gt;2&lt;/span&gt; 15:13 system_stm32f4xx.c.obj&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Yes, it was 15:13 when I built the project. Let&amp;rsquo;s clean it and see what files are still here and what files have been deleted.&lt;/p&gt;</description>
			</item>
			<item>
				<title>CMake on STM32 | Episode 4: get ready for C&#43;&#43;</title>
				<link>https://gradot.dev/blog/posts/2020/cmake-on-stm32-cpp-ready/</link>
				<pubDate>Sat, 02 May 2020 17:49:43 +0200</pubDate>
				<guid>https://gradot.dev/blog/posts/2020/cmake-on-stm32-cpp-ready/</guid>
				<description>&lt;p&gt;I have been using C++ for the last 4 years&amp;hellip; there is no way I get back to C! This episode is not about explaining why I think C++ is better than C. It is simply about running C++ on STM32 with CMake. By the way: we will make LEDs blink!&lt;/p&gt;&#xA;&lt;h2 id=&#34;adding-user-code-in-code-generated-by-stm32cubemx&#34;&gt;Adding user code in code generated by STM32CubeMX&lt;/h2&gt;&#xA;&lt;p&gt;If we change the MCU configuration with STM32CubeMX and generate the code again, the previous files are overwritten. How can we create our own program if everything is erased each time the code is generated?&lt;/p&gt;</description>
			</item>
			<item>
				<title>CMake on STM32 | Episode 3: handle warnings in 3rd party files</title>
				<link>https://gradot.dev/blog/posts/2020/cmake-on-stm32-warnings/</link>
				<pubDate>Fri, 01 May 2020 13:23:57 +0200</pubDate>
				<guid>https://gradot.dev/blog/posts/2020/cmake-on-stm32-warnings/</guid>
				<description>&lt;p&gt;Something funny happens sometimes with 3rd party files: they generate warnings when compiled with your project settings. If you have quality indicators about the build health (automatically updated by Jenkins maybe), this is quite annoying. If you compile with an option such as &lt;a href=&#34;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html&#34;&gt;&lt;code&gt;-Werror&lt;/code&gt;&lt;/a&gt; to treat warnings as errors, this is a blocking issue.&lt;/p&gt;&#xA;&lt;p&gt;In this article, we will add compiler options that will raise warnings in ST&amp;rsquo;s generated files and we will ask CMake to suppress these warnings but only for these files.&lt;/p&gt;</description>
			</item>
			<item>
				<title>CMake on STM32 | Episode 2: build with CLion</title>
				<link>https://gradot.dev/blog/posts/2020/cmake-on-stm32-clion/</link>
				<pubDate>Wed, 29 Apr 2020 19:21:36 +0200</pubDate>
				<guid>https://gradot.dev/blog/posts/2020/cmake-on-stm32-clion/</guid>
				<description>&lt;p&gt;In this article, you will learn how to build a CMake project for STM32 and download the software to the MCU with &lt;a href=&#34;https://www.jetbrains.com/clion/&#34;&gt;CLion, JetBrains&amp;rsquo; IDE for C &amp;amp; C++&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;In &lt;a href=&#34;https://gradot.dev/blog/posts/2020/cmake-on-stm32-beginning/&#34;&gt;episode 1&lt;/a&gt;, we got a BSP along with the &lt;code&gt;CMakeLists.txt&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;p&gt;&lt;img src=&#34;https://gradot.dev/blog/posts/2020/cmake-on-stm32-clion/01-alt-text.png&#34; alt=&#34;Alt Text&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;Finally, we built the software from the command line.&lt;/p&gt;&#xA;&lt;p&gt;To be honest, in my everyday life, I don&amp;rsquo;t use the command line. I use instead CLion because it is much more comfortable&amp;hellip; Let&amp;rsquo;s try it!&lt;/p&gt;</description>
			</item>
			<item>
				<title>CMake on STM32 | Episode 1: the beginning</title>
				<link>https://gradot.dev/blog/posts/2020/cmake-on-stm32-beginning/</link>
				<pubDate>Tue, 28 Apr 2020 17:35:25 +0200</pubDate>
				<guid>https://gradot.dev/blog/posts/2020/cmake-on-stm32-beginning/</guid>
				<description>&lt;p&gt;This article is the first of a series dealing with &lt;a href=&#34;https://cmake.org/&#34;&gt;CMake&lt;/a&gt; and &lt;a href=&#34;https://www.st.com/en/microcontrollers-microprocessors/stm32-32-bit-arm-cortex-mcus.html&#34;&gt;STM32 microcontrollers&lt;/a&gt;. In fact, it is more about CMake on MCUs but I had to pick one for the examples.&lt;/p&gt;&#xA;&lt;h2 id=&#34;why-cmake-why-stm32&#34;&gt;Why CMake? Why STM32?&lt;/h2&gt;&#xA;&lt;p&gt;CMake is becoming the &lt;em&gt;de-facto&lt;/em&gt; standard tool to build C and C++ projects. It is becoming so popular that it will probably be &lt;a href=&#34;https://www.qt.io/blog/2019/08/07/technical-vision-qt-6&#34;&gt;the build tool for Qt6&lt;/a&gt;:&lt;/p&gt;&#xA;&lt;blockquote&gt;&#xA;&lt;p&gt;For Qt 6, we aim to use CMake as a standard 3rd party build system to build Qt itself. CMake is by far the most widely used build system in the C++ world, and better integration with it is sorely needed.&lt;/p&gt;&#xA;&lt;/blockquote&gt;</description>
			</item>
	</channel>
</rss>
