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';
}

Official C++ 23 documentation

More language basics commands

All language basics commands · C++ 23 cheatsheet

Was this page helpful?