fenbf / cppstories-discussions

4 stars 1 forks source link

2023/h1-cpp-papers23/ #121

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

Five Awesome C++ Papers for the H1 2023 - C++26, Varna and More - C++ Stories

Last week the ISO committee met in Varna to discuss some of the first batch of C++26 features. It’s an excellent occasion to shed some light on the latest status and interesting C++ proposals. Let’s start! By the way: This will be my first blog post with the #cpp26 tag!

https://www.cppstories.com/2023/h1-cpp-papers23/

rmerriam commented 1 year ago

Re: P0843 static_vector/inplace_vector

I like this version of vector. The negative is there are now 3 versions of contiguous containers which increases complexity and will increase confusion. IMO std::array should have been static_vector. Or am I missing something?

What is the difference between std::array<int, 10> and std::static_vector<int, 10> except the former must contain 10 ints while the latter may contain only 5 ints?

2kaud commented 1 year ago

What are your favorite proposals that could be included in the next C++ Standard

1) with a do loop allow scope of defined local variables to extend to the end of the while statement. eg

do (bool b {}) {
    // body here
} (while !b);

This removes the need to define b in it's own block around the do loop. Currently you need

{
    bool b {};
    do {
        // body here
    } (while !b);
}

2) Allow multiple different type definitions in one statement. eg

int a,b : bool c, d;

which can be used in say a for loop

for (int i : double d; .....)

This can currently be done using auto, structured bindings and pair/tuple but it's 'very awkward'

for (auto [i, d] { std::pair { 1, 3.14 } }; ;);

3) From within a for/do/while/switch to be able to break out of not just the current level but also out of enclosed level(s) as well without using a forward goto statement or flags etc.

4) Non-locking thread-safe versions of std::queue, std::stack etc and also a new thread-safe circular queue container.

5) Full support for csv and json data format.

2kaud commented 1 year ago

C++23 hasn't yet been ratified and already there are 4 DR's in C++26! So the C++23 standard is going to be published knowing that there are defects with it. Surely it would be better to incorporate these known DR's into C++23 - even if that might mean delaying C++23 by a couple of months. Surely it can't involve that much extra effort to incorporate these into C++23 as the wording etc is now already there for C++26.

fenbf commented 1 year ago

Thanks for the comments @2kaud . From my perspective, DRs are usually implemented against older versions of the standard, so compilers can implement them on the fly. It's best to stick to the schedule and release every three years, rather than add some delays to the whole process.

rokoDev commented 1 year ago

I don't know weather it has been approved or not but i would glad to hear that we can use structured bindings with parameter packs: https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1061r2.html