When and How Variables are Initialized? - Part 2 -- Sandor Dargo
During the last two weeks, we saw a bug related to uninitialized values and undefined behaviour, we listed the different kinds of initializations in C++ and we started to more detailed discovery with copy-initialization. This week, we continue this discovery with direct-, list- and aggregate-initialization.
When and How Variables are Initialized? - Part 2
by Sandor Dargo
From the article:
Direct-initialization initializes an object from an explicit set of constructor arguments. Different syntaxes invoke direct initialization such as
T object(<at least one arg>);,T(<at least one arg>);ornew T(<at least one arg>);but it might also happen when you use curly braces (T object{oneArg};). Additional use cases are static casts, constructor initializer lists and values taken by value in lambda captures.While at first glance this might obvious there are some catches.
Take this expression:
T object{ arg };. In this case,objectis directly initialized only if it’s a non-class type, otherwise, we talk about list-initialization. But if you use the parentheses syntax (T object(arg)then there is no such distinction between class and non-class types, in both cases, direct-initialization is performed. Also,T object{ arg1, arg2 };would never be direct-initialized, that’s always an aggregate-initialization.In the expression
[arg]() {}, the generated lambda members will not be copy-initialized, but they will be directly initialized.

The safety of C++ has become a hot topic recently. Herb Sutter discusses the language’s current problems and potential solutions.
A new episode of the series about SObjectizer and message passing:
A new episode of the series about SObjectizer and message passing:
Last week, I attended the spring 2024 meeting of the ISO C++ standardization committee in Tokyo, Japan. This was the third meeting for the upcoming C++26 standard and my first meeting as assistant chair of SG 9, the study group for ranges.
A new episode of the series about SObjectizer and message passing:
A new episode of the series about SObjectizer and message passing:
I delivered a keynote, C++ and the Next 30 Years, at the 2024 CPP-Summit conference in Beijing, China. Experiencing the culture, the people, and the landscape was tremendous. In this post I’ll cover some of the points in my future-looking C++ talk and share my experience giving a talk for the first time in China.
In C++, shadowing occurs when a name in one scope hides an identical name in another scope, sparking debate over its merit. This article explores scenarios where shadowing can either protect code integrity or hinder its evolution, highlighting its dual nature and impact on code maintenance. Join Raymond as he unravels the complexities of shadowing in C++, revealing its intricate balance between benefit and drawback.