C++23: More Small Changes -- Sandor Dargo
In this post, we continue discovering the changes introduced by C++23. We are going to look into three (and a half) small changes, each affecting constructors of some standard library types. We’re going to see how new constructors for container types, a new range constructor for
string_view and some default template arguments for pair.
C++23: More Small Changes
by Sandor Dargo
From the article:
As of C++20, almost all container-like objects (containers and container-adaptors) can be initialized with a pair of iterators.
std::vector<int> v{42, 51, 66}; std::list<int> l(v.begin(), v.end());All of them, except forstd::stackandstd::queue. They don’t provide such overloads. If you want to initialize them with a pair of iterators, you need an intermediarystd::initiailizer_list.
std::vector<int> v{42, 51, 66}; // std::queue<int> q1(v.begin(), v.end()); // DOESN'T COMPILE! std::queue<int> q2({v.begin(), v.end()});This inconsistency, at first, looks like a small inconvenience. But its effects are much deeper. While using the
stackorqueueon its own is not a big burden, if you want to offer functionality that works with all container-like objects, you have a higher price to pay.Due to the lack of an iterator-pair-based constructor, you either have to ...

Last year saw a proliferation of talks and articles about safety in C++. Lucian Radu Teodorescu gives an overview of these and presents a unified perspective on safety.
A new episode of the series about SObjectizer and message passing:
Sometimes the small changes between two C++ standards really bite you. Today's post is about when I got bitten by a change to aggregates in C++20.