r/cpp • u/adityazero • Sep 20 '26
CppCon At cppcon WG21 had a whiteboard asking attendees what they would like to have in C++29
some of the ones I remember was:
- contracts
- profiles
- delete moar stuff
I'm curious what folks here expect. Also if someone remembers rest of the list, that'd be great.
60
Upvotes
View all comments
Show parent comment
1
u/ts826848 Sep 20 '26
I think you might be thinking of something else? Pattern matching is a runtime operation so I don't think
if constexprwould help and while you can use concepts in astd::visitvisitor that does not get you the full generality of pattern matching.But in any case pattern matching is sort of like a combination of
switchandstd::visiton steroids.switchandstd::visitare compare to pattern matching for simpler uses (albeit at an ergonomic cost for the latter), but neither is particularly great at more complex cases like deconstructing nested data types or cases where guard clauses might be handy.Pattern matching pairs particularly well with variants, and it would go a long way to making
std::variantless of a pain to use.Rust's enums/
matchare a good example, though both features have a long lineage in other functional languages like MLs and Haskell.I think P2688 is the current pattern matching proposal? Not entirely sure what to make of the GitHub issue