Open Source Your Knowledge, Become a Contributor
Technology knowledge has to be shared and made accessible for free. Join the movement.
is a new C++ language feature shipping with C++17.
It gives us the ability to declare multiple variables initialized from a
With C++11/14 you could use
to bind the elements of a pair or tuple to variables:
const auto tuple = std::make_tuple(1, 'a', 2.3); //... // first declare the variables int i; char c; double d; // now we can unpack the tuple std::tie(i, c, d) = tuple;
With C++17 this becomes much easier:
const auto tuple = std::make_tuple(1, 'a', 2.3); // ... const auto [ i, c, d ] = tuple;