r/cpp • u/pavel_v • Apr 16 '26
C++26: Structured bindings in conditions
https://www.sandordargo.com/blog/2026/04/15/cpp26-structured-bindings-condition
60
Upvotes
r/cpp • u/pavel_v • Apr 16 '26
View all comments
7
u/fdwr fdwr@github 🔍 Apr 16 '26 edited Apr 16 '26
What?.. 🤔 I'm sure I've used this before inside
ifstatements. (goes and checks...) Ah, I usedif (auto [x, y] = ...), notif (auto& [x, y] = ...)which indeed fails. That's cool to see related things being more consistent now (though, on the matter of consistency, why in the world did they abuse array notation[]to introduce a heterogeneous tuple instead of the usual{}or(), likeif (auto {a, z} = ...)- sigh).