r/programming • • 2d ago

Pattern Matching for C++29 (proposal)

https://mpark.github.io/programming/2026/11/30/pattern-matching-for-cpp29/
16 Upvotes

6 comments sorted by

20

u/PudgeNikita 2d ago

honestly it was kind of surprising for me to learn that the "standard" way to do pattern matching in C++ was the mess which std::visit is. sucks for the compile times, compile errors, and you can only return one value from the visit rather than do control flow relative to the block you "call" it in. really weird situation for a feature which is almost ubiquotously loved in the languages which have it

0

u/ingressstatue 1d ago edited 1d ago

One reason why it is taking so long, is that pattern matching, and many other features, are harder to add to systems programming languages than other programming languages. Rust is famous for showing that it can be done; but even in Rust, it took many years, and several rounds of improvements ("match ergonomics", for instance), and there are still a few strange semantics of pattern matching and other issues in Rust. The issues discussed in the blog post titled "a Rust match made in hell" at fasterthanlime, is not typically encountered outside systems programming languages, since those typically just have garbage collection and not RAII.

This C++ proposal is verbose, and its syntax and semantics have questionable decisions in my opinion in several regards, despite pattern matching being a large improvement over std::visit. But, with all due respect to everyone, Reddit is famous for inducing brainrot, among other issues.

Also, Reddit censorship, administrators, moderators, promoted members, etc. are generally reminiscent of Jeffrey Epstein, Ghislaine Maxwell (Reddit moderator?), Robert Maxwell (Israeli top agent), Harvey Weinstein, Jared Kushner, Victoria Nuland, etc. Reddit brainrot is abysmal, also for technical state of matters, but not even close to being one of the worst issues.

17

u/jonte 1d ago

haha, wtf. that took an unexpected turn.

2

u/Zymoox 14h ago

Thats because OP is a bot with a one day old account

4

u/lonelyroom-eklaghor 1d ago

Discovered pattern-matching a while ago. Everytime I try to code in C++, I get confused and have to look at the docs, regardless of the feature.

Atp, there should be sub-documentations on different aspects of C++