1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <utility>
#include <string>
int main() {
std::pair<int, std::string> myPair(100, "C++");
std::cout << "First element: " << std::get<0>(myPair) << std::endl;
std::cout << "Second element: " << std::get<1>(myPair) << std::endl;
// Modifying elements using std::get
std::get<1>(myPair) = "Modern C++";
std::cout << "Modified second element: " << std::get<1>(myPair) << std::endl;
return 0;
}
Back to std_get