In order to being able to perform this common task elegantly, structured bindings were introduced in C++17. Using structured bindings, multiple variables can be initialized at once using auto and a bracket initializer list. As with the auto keyword in general, you can apply control over whether the variables should be mutable references, forward references, const references, or values by using the corresponding modifier. In the following example a structured binding of const references is constructed:
const auto& [name, id, kill_license] = make_bond(); std::cout << name << ", " << id << ", " << kill_license << '\n'; // Output: James, 7, true
Structured bindings can also be used to extract the individual members of a tuple ...