Fixes
Let's get started with the major fixes and improvements in C++17.
We'll cover the following
We can argue what is a fix in a language standard and what is not.
Ahead, there are three things that might look like a fix for something that was missing or not working in the previous rules.
New auto Rules For Direct-list-initialisation
Since C++11
, there’s been a strange problem where
auto x = { 1 };
is deduced as std::initializer_list<int>
. Such behaviour is not intuitive as in most cases you
should expect it to work like int x { 1 };
.
Brace initialization is the preferred pattern in modern C++, but such exceptions make the feature weaker.
With the new Standard, we can fix this so that it will deduce int
.
To make this happen, we need to understand two ways of initialization - copy and direct:
Get hands-on with 1400+ tech skills courses.