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++17/C++20 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:

See My New Book: C++ Initialization Story

Updated:

I’m happy to announce that my new book on C++ Initialization is published! Have a look at the background story and how to get it. Note: Initially, the book was called “Data Member Initialization in Modern C++”, but in September 2022, I updated it heavily and changed the title. About the book   As for my other books, I used the Leanpub platform for the PDF/Epub generation.

READ MORE...

20+ Ways to Init a String, Looking for Sanity

Updated:

C++ is famous… or infamous for its complex initialization syntax. In this article, I’ll show you around 20 ways to initialize simple std::string variables. Can we somehow make it easier to understand? Default values   Have a look: void foo() { std::string str0; std::string str1 {}; } We have two local variables (with automatic storage duration), str0 is default initialized, while str1 is value initialized.

READ MORE...

5 Curious C++ Lambda Examples: Recursion, constexpr, Containers and More

Updated:

In this blog post I’ll show you a couple of interesting examples with lambda expressions. Do you know how to write a recursive lambda? Store them in a container? Or invoke at compile time? See in the article. Updated in August 2022: Added C++23 improvements. 1. Recursive Lambda with std::function   Writing a recursive function is relatively straightforward: inside a function definition, you can call the same function by its name.

READ MORE...

Custom types and std::format from C++20

Updated:

std::format is a large and powerful addition in C++20 that allows us to format text into strings efficiently. It adds Python-style formatting with safety and ease of use. This article will show you how to implement custom formatters that fit into this new std::format architecture. Quick Introduction to std::format   Here’s the Hello World example:

READ MORE...

C++20 Ranges Algorithms - sorting, sets, other and C++23 updates

Updated:

This article is the third and the last one in the mini-series about ranges algorithms. We’ll look at some sorting, searching, and remaining algorithms. We’ll also have a glimpse of cool C++23 improvements in this area. Let’s go. Before we start   Key observations for std::ranges algorithms: Ranges algorithms are defined in the <algorithm> header, while the ranges infrastructure and core types are defined in the <ranges> header.

READ MORE...