r/cpp • • Apr 16 '26

C++26: Structured bindings in conditions

https://www.sandordargo.com/blog/2026/04/15/cpp26-structured-bindings-condition
60 Upvotes

27 comments sorted by

View all comments

Show parent comment

8

u/jedwardsol const & Apr 16 '26

You can put whatever you like after the ;

if (const auto& [result, error_message] = foo(n); isPrime(result.real) &&  result.imaginary == 0.5 )