tuple in C++
Level 4221 keystrokes
Stores a string, an int and a double in one tuple, reads them with get<index>, then unpacks them with a structured binding.
C++ code
// A tuple holds a fixed number of values of different types1tuple<string, int, double> person("Alice", 25, 5.5);// get<0> returns the first element: Alice2cout << get<0>(person) << endl;// The index is a compile-time constant: 253cout << get<1>(person) << endl;// Third element: 5.54cout << get<2>(person) << endl;5 // Structured binding copies the three elements into named variables6auto [name, age, height] = person;// Prints Alice, 257cout << name << ", " << age << endl;Output
Alice 25 5.5 Alice, 25
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this C++ code and how often they appear.
<× 24,× 7;× 6"× 4(× 4)× 4>× 4.× 1[× 1]× 1