C++introcpp17

Structured bindings

Unpack a pair, tuple, struct, or array into named variables in one declaration.

auto [a, b] = ... destructures aggregates into named locals, so map iteration, multiple returns, and tuple access read like plain variables instead of .first/std::get.

Unpack a std::pair

C++intro
0ms
apples x5local qty now 15pair still 5
Reference · output compiled offline, not runnable in-browser

Plain auto [name, qty] copies the pair, so qty += 10 makes local qty now 15 while entry.second stays 5 — proof the bound names are independent locals, not aliases into the original object.