example1_creating_and_using.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include <iostream>
#include <tuple>

int main() {
    // Create a tuple with an int, a double, and a std::string
    std::tuple<int, double, std::string> myTuple(1, 3.14, "Hello");

    // Accessing the elements of the tuple
    std::cout << "First: " << std::get<0>(myTuple) << std::endl;
    std::cout << "Second: " << std::get<1>(myTuple) << std::endl;
    std::cout << "Third: " << std::get<2>(myTuple) << std::endl;

    return 0;
}
Back to std_tuple