The C++ Stories Weekly Newsletter

Join ~11000 developers who read about Modern C++, news reports, tools, and more! A new email every Monday.
Bonuses included! C++23/C++20/C++17 ref cards and more!

The above field is supplemented with consent to receive a newsletter containing information and marketing content about the cppstories.com portal from Bartłomiej Filipek codebf based in Krakow. The consent may be withdrawn at any time. See the full Privacy Policy.


See the latest articles:

Adjacency Matrix and std::mdspan, C++23

Updated:

In graph theory, an adjacency matrix is a square matrix used to represent a finite (and usually dense) graph. The elements of the matrix indicate whether pairs of vertices are adjacent or not, and in weighted graphs, they store the edge weights. In many beginner-level tutorials, adjacency matrices are implemented using vector of vectors (nested dynamic arrays), but this approach has inefficiencies due to multiple memory allocations.

READ MORE...

How to use std::span from C++20

Updated:

In this article, we’ll look at std::span, which has been available since C++20. This “view” type is more generic than string_view and can help work with arbitrary contiguous collections. Updated in Feb 2025: added section about returning spans and C++26 improvements (.at() and creatoion from initializer list). A Motivating Example   Here’s an example that illustrates the primary use case for std::span:

READ MORE...

Improving Code Safety in C++26: Managers and Dangling References

Updated:

In this blog post, we’ll explore ways to improve the safety of a simple configuration manager. We’ll handle common pitfalls like dangling references and excessive stack usage. Additionally, we’ll see how C++26 helps enforce safer coding practices with stricter diagnostics and improved handling of large objects. Let’s go. Step 1: The Buggy Implementation   Below is a simple example of a manager object that stores various configs in a map and provides a method to retrieve them.

READ MORE...

8 More C++23 Examples

Updated:

In this article, you’ll see eight larger examples that illustrate the changes in C++23. C++23 brings a ton of cool features, as you can see in my two previous articles (here and here). So far, we explored each new addition one by one, but I’d like to share more examples that combine multiple features.

READ MORE...

C++23 Library Features and Reference Cards

Updated:

In this blog post, you’ll see all C++23 library features! Each with a short description and additional code example. Prepare for a ride! For language features please see the previous article: C++23 Language Features and Reference Cards - C++ Stories Want your own copy to print?   If you like, I prepared PDF I packed both language and the Standard Library features.

READ MORE...

C++23 Language Features and Reference Cards

Updated:

C++23 Language Features   In this blog post, you’ll see all C++23 language features! Each with short description and additional code example. Prepare for a ride! For library features please see the next article: C++23 Library Features and Reference Cards - C++ Stories Want your own copy to print?   If you like, I prepared PDF I packed both language and the Standard Library features.

READ MORE...

Around the World in C++: Exploring Time Zones with std::chrono

Updated:

While most time zones use simple hour offsets from UTC, some regions have chosen unusual time differences. In this blog post, we’ll explore how we can discover such zones using C++20’s chrono library. We’ll use GCC 14.2 as it fully supports C++20 chrono and also std::print from C++23. First Attempt: Basic Zone Iteration   C++20 introduced comprehensive time zone support through the <chrono> library.

READ MORE...

What is the current time around the world? Utilizing std::chrono with time zones in C++23

Updated:

In this blog post, we will explore handling dates using std::chrono, including time zones. We’ll utilize the latest features of the library to retrieve the current time across various time zones, taking into account daylight saving time changes as well. Additionally, we will incorporate new capabilities introduced in C++23, such as enhanced printing functions and more.

READ MORE...

C++ String Conversion: Exploring std::from_chars in C++17 to C++26

Updated:

With the introduction of C++17, the C++ Standard Library expanded its capabilities for converting text to numbers with the addition of std::from_chars. This low-level, high-performance API offers significant advantages over previous methods, such as atoi and stringstream. In this article, we will explore the evolution of string conversion routines from C++17 through C++26, highlighting key improvements like constexpr support and enhanced error handling.

READ MORE...

Enum Class Improvements for C++17, C++20 and C++23

Updated:

The evolution of the C++ language continues to bring powerful features that enhance code safety, readability, and maintainability. Among these improvements, we got changes and additions to enum class functionalities across C++17, C++20, and C++23. In this blog post, we’ll explore these advancements, focusing on initialization improvements in C++17, the introduction of the using enum keyword in C++20, and the std::to_underlying utility in C++23.

READ MORE...