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:

In-Place Construction for std::any, std::variant and std::optional

Updated:

When you read articles or reference pages for std::any, std::optional or std::variant you might notice a few helper types called in_place_* available in constructors. Why do we need such syntax? Is this more efficient than “standard” construction? Intro   Chinese version here: C++ std::any、std::variant和std::optional的原位构造(In-Place Construction)_yihuajack的博客-CSDN博客 We have the following in_place helper types:

READ MORE...

Parallel STL And Filesystem: Files Word Count Example

Updated:

Last week you might have read about a few examples of parallel algorithms. Today I have one more application that combines the ideas from the previous post. We’ll use parallel algorithms and the standard filesystem to count words in all text files in a given directory. The Case   In my previous post, there were two examples: one with iterating over a directory and counting the files sizes and the next one about counting words in a string.

READ MORE...

A Wall of Your std::optional Examples

Updated:

Two weeks ago I asked you for help: I wanted to build a wall of examples of std::optional. I’m very grateful that a lot of you responded and I could move forward with the plan! You’re amazing! Let’s dive in the examples my readers have sent me! A Reminder   To remind, I asked for some real-life examples of std::optional.

READ MORE...

Show me your code: std::optional

Updated:

Show me your code! I’d like to run a little experiment. Let’s build a wall of examples of std::optional! Intro   In the last three articles of my C++17 STL series I’ve been discussing how to use std::optional. I can talk and talk… or write and write… but I’m wondering how do you use this wrapper type?

READ MORE...

Error Handling and std::optional

Updated:

In my last two posts in the C++17 STL series, I covered how to use std::optional. This wrapper type (also called “vocabulary type”) is handy when you’d like to express that something is ‘nullable’ and might be ‘empty’. For example, you can return std::nullopt to indicate that the code generated an error… but it this the best choice?

READ MORE...

Using C++17 std::optional

Updated:

Let’s take a pair of two types <YourType, bool> - what can you do with such composition? In this article, I’ll describe std:optional - a new helper type added in C++17. It’s a wrapper for your type and a flag that indicates if the value is initialized or not. Let’s see where it can be useful and how you can use it.

READ MORE...

Refactoring with C++17 std::optional

Updated:

There are many situations where you need to express that something is “optional” - an object that might contain a value or not. You have several options to implement such case, but with C++17 there’s probably the most helpful way: std::optional. For today I’ve prepared one refactoring case where you can learn how to apply this new C++17 feature.

READ MORE...