New C++26 features to make use of today
The latest C++ Standard has recently been finalized and compiler support, especially in Clang, is progressing rapidly. (The code in this article was tested on Clang 23 with -std=c++2c, while all of the...
View ArticleString interpolation in C++26
This bite-sized article explores the latest Standard’s support for Python-style f-strings (having a literal f prefix) in C++. This may seem like a strange feature to add, but if you use Python, chances...
View ArticleLanguage-level assertions in C++26
Assertions (run-time checks of a Boolean condition) have been around since the beginnings of the C language, and are of course available to C++ from the <cassert> header. Starting with the latest...
View ArticleWriting a generic input function (2)
This article continues the theme of writing functions that parse user input, in this case numerical only (both integral and floating-point). In another article the use of from_chars() (in Modern C++’s...
View ArticleWriting a generic input function (1)
Having the <print> header available to us in C++23, we no longer have to rely on using the stream insertion operator with std::cout and other stream output objects. This article attempts to find...
View ArticleReflection in C++26 (P2996)
This article is intended to summarize the state of play in the upcoming C++26 Standard as regards reflection, which is where information (metadata) about the source code is made available for use at...
View ArticleNew floating-point types in C++23
In common with the C language we have been used to having the float, double and long double types available since the first versions of C++. (Did you know that long double often uses 80 bits of...
View ArticleMove Semantics in Modern C++ (4)
In previous articles we’ve discussed how to make objects “move-aware” so that moves are more efficient than copies, and also how to forward objects efficiently between different scopes. In this article...
View ArticleMove Semantics in Modern C++ (3)
In the previous two articles we looked at how to transfer “move-aware” objects, such as std::string, between variables, and also how to create a Movable class which logs all copy and move operations...
View ArticleMove Semantics in Modern C++ (2)
Now that we’ve looked at how std::move() can be applied to Standard Library types, such as std::string, in this article we’re going to look at creating our own “move-aware” type. We want it to have at...
View ArticleMove Semantics in Modern C++ (1)
The title for this mini-series may seem to be ambitious for two reasons: move semantics have been available for a long time (since C++11 in fact, so not very “Modern”), and it is a large subject (there...
View ArticleOperator Overloading in Modern C++ (3)
Having looked at how to overload common math operators in previous articles, in this article we’re going to look at how to overload some “special” operators (unary * and ->) as well as increment and...
View ArticleOperator Overloading in Modern C++ (2)
Having looked at how to create a class representing a three-dimensional vector in the previous article, we’re going to look at how to add more operator-related functionality to it. We’ll start off with...
View ArticleOperator Overloading in Modern C++ (1)
OO (or OOP) has previously been commonly used to mean “Object-Oriented (Programming)”, but there is another use of the acronym OO which is: “Operator Overloading”. Simply put this involves creating...
View ArticleAdditional Unicode support in C++
Unicode is so prevalent these days that it is difficult to imagine any modern programming language not supporting it. C++ has made a number of attempts to provide language and library support for...
View ArticleC++ Concurrency 101
Utilizing the potential of multi-core CPUs as found in virtually all modern hardware can only be achieved by writing multi-threaded programs. Code which is multi-threaded allows multiple threads to run...
View ArticleWhen to use std::string_view
C++17 brought us the class std::string_view in the standard library, which was touted as a lightweight, non-owning string-like entity which could be passed cheaply as a function parameter. In this...
View ArticleMaking algorithms faster
It is possible to write poor-quality code in any programming language, and this often stems from sub-optimal algorithms being used. Most of the execution time in modern software is spent in loops, so...
View ArticleHow could Reflection be applied to Modern C++?
Reflection is commonplace in other contemporary programming languages, but support for it in C++ is virtually non-existent. In this article we’re going to summarize what reflection is and how existing...
View ArticlePattern Matching is coming to Modern C++
Pattern matching is a commonly used idiom in other contemporary programming languages, such as Rust or Haskell, and is a way to inspect and deconstruct value(s) based on their type(s). Unlike...
View Article