C++ 23 · Language basics
Unpack a pair or struct
Name the parts of a pair, tuple or struct in one declaration.
for (const auto& [name, score] : scores) {
std::cout << name << ": " << score << '\n';
}
C++ 23 · Language basics
Name the parts of a pair, tuple or struct in one declaration.
for (const auto& [name, score] : scores) {
std::cout << name << ": " << score << '\n';
}
Was this page helpful?