Last Update:
Five Awesome C++ Papers for the Q1 2021 and C++23 Status
Between 2018 and 2020, I released several articles with top 5 proposals just around a new ISO C++ meeting happened. Since March 2020, this pattern broke as the meeting went online. Why not restart the series? :) We can look at the recent papers from a whole Quarter.
Let’s start!
Disclaimer: the view presented here is mine and does not represent the opinion of the ISO C++ Committee.
The Online Meetings
Until March 2020, the ISO Committee met face to face two or three times per year. The gatherings took place in various locations, mainly in Europe and the USA. Have a look at my few previous reports:
- Five Awesome C++ Papers for the Prague ISO Meeting and C++20 Status
- Five Awesome C++ Papers for the Belfast ISO Meeting and C++20 Status
- Five Awesome C++ Papers for Cologne ISO Meeting
Since March 2020, due to pandemics, the meeting went entirely online. In the last year, around 200 virtual calls were organized! As you can see, the Committee is alive and working already on C++23 and C++20 fixes :)
Have a look at valuable summaries from Herb Sutter:
- Trip report: Autumn ISO C++ standards meeting (virtual)
- Trip report: Winter 2021 ISO C++ standards meeting (virtual)
If you want to know more about the online process, have a look at this document which describes how the ISO Committee works right now:
P2145R1: Evolving C++ Remotely
Upcoming Meetings
Due to the global pandemic situation, ISO postponed all the face-to-face meetings, but hopefully, they will return in 2022. The next place for the conference is in New York, NY, USA.
Here’s the plan for the meetings at the ISO C++ website: Upcoming Meetings, Past Meetings: Standard C++
Status of C++23
The C++20 Standard is already published (Dec 2020) and since mid 2020 C++ Experts started thw work on C++23. The papers and voting is now asynchoronous. Thus far the following features were accepted:
- Literal suffix for (signed)
size_t
- we can now writeauto i = 0zu
which createssize_t
variable. - Make
()
more optional for lambdas - no need to use()
with lambdas with a capture and mutable:[&var] mutable {}
. This also applies to trailing return type and other specifiers. - Stacktrace library - additional debugging information, similar to other languages like Python, C# or Java.
<stdatomic.h>
std::is_scoped_enum
contains()
forbasic_string
/basic_string_view
std::to_underlying
- yep, this is almost the same unitility that Scott Meyers proposed in his Effective Modern C++ Book :) Item 10, on scoped enums.std::visit
for classes derived fromstd::variant
- Relaxing requirements for
time_point<>::clock
As always, you can see their status on this great cppreference page:
And here’s the plan for C++23:
To boldly suggest an overall plan for C++23
Awesome Papers
Let’s now have a look at some recent papers listed for the First Quarter of 2021.
Here are the links for:
Deducing this
The main idea behind this proposal looks simple:
We propose a new mechanism for specifying or deducing the value category of the expression that a member-function is invoked on.
In short: this will make simplify the code where you want to share code between const and non-const member functions or other value categories.
I wrote about this issue a few months before: How to Share Code with Const and Non-Const Functions in C++ - C++ Stories.
Yet, it’s not that easy as it touches the language, function overloading, and matching. That’s why a lot of critical paths have to be examined and solved first.
Here’s a sample syntax that we currently aim for:
struct X {
void foo(this X const& self, int i);
It’s the 6th iteration of this proposal; the work continues, so hopefully, there’s a chance that it will land in C++23.
Simple Statistical Functions
The proposal would be a pure library addition with the following functionalities:
- Mean
- Quantile
- Mode
- Skewness
- Kurtosis
- Variance
- Standard Deviation
These functions are necessary for Machine Learning, and they were identified as a valuable addition via the SG19 - Machine Learning Group. Other programming languages like Python, Rust, MATLAB, Julia, and many others already support similar functionalities.
The functions would support ranges and even parallel execution, so there are a couple of design decisions to work in the Standard fully.
String Split
Superior String Splitting - P2210
With this proposal, we’ll get a handy way of running a split on the contiguous input range.
Currently the following code won’t compile in C++20:
std::string s = "1.2.3.4";
auto ints =
s | views::split('.')
| views::transform([](auto v){
int i = 0;
from_chars(v.begin(), v.end(), &i);
return i;
})
It’s a bit counterintuitive as you pass a contiguous range, but then views::split
yields only forward iterators…
You can also read more in a separate article on that topic: Barry Revzin: Implementing a better views::split.
Missing constexpr
in std::optional
and std::variant
Thanks to various enhancements for C++20, we can now use constexpr
in a lot of cases. This also includes constexpr std::vector
or constexpr std::string
! This proposal makes important suggestions that thanks to those constexpr
features, we can easily make std::optional
and std::variant
also ready for constexpr
!
You can play with demo for optional
and also a separate demo for variant
.
Zip
This proposal continues the discussion on bringing a set of Zip-like views into the Standard Library. The plan is to introduce the following views:
zip
,zip_transform
,adjacent
,adjacent_transform
This follows the plan on making the current C++20 implementation of ranges compatible with RangeV3 and even more powerful, as described in A Plan for C++23 Ranges.
Your Turn
What are your favorite features that might be included in the next Standard?
I've prepared a valuable bonus for you!
Learn all major features of recent C++ Standards on my Reference Cards!
Check it out here: