Here are a list of C++20 features I want to use in interfaces (header files):
concepts, reason: simplify code that uses enable_if and make it more readable
expected, reason: using today through a header file I vendored (tl_expected in ros) but it would be nice to just use it through the stl
operator<=>, reason: simplifying comparison overloads
ranges, reason: composable algorithmic code, I’m already using this sort of through a library called flux. Sadly it is implemented using C++20 so I can’t use flux in the public interface of ROS packages. This one heavily depends on the concepts feature.
Designated initializers is a C++20 feature that made it into C so unless you use -Wpedantic you can join me today and use it.
I thought I spelled out what features I wanted because you asked but noticed you also wanted reasons. Here are some reasons.
I’ve heard several people say they’d like to use PMR in their algorithmic code. I listed the features I know I want to use in the code I write and maintain. I’m not entirely convinced PMR is a good change in C++.
Here is a list of C++23 features I want to use as soon as possible:
deducing this, reason: simplifies code where you previously had to specify lvalue/rvalue overloads, simplifies CRTP
operator[] and mdspan, reason: ergonomic image transform code
4 Likes