C++ 用 std::get<> 访问元组
#include <iostream> #include <tuple> int main() { // Creating a tuple std::tuple<int, double, std::string> myTuple(42, 3.14, "Hello"); // Accessing elements using std::get<> int intValue = std::get<0>(myTuple); double doubleValue = std::get<1>(myTuple); std::string stringValue = std::get<2>(myTuple); // Displaying the values std::cout << "First element: " << intValue << std::endl; std::cout << "Second element: " << doubleValue << std::endl; std::cout << "Third element: " << stringValue << std::endl; return 0; }
标签:std,myTuple,get,int,C++,元组 From: https://www.cnblogs.com/music-liang/p/17896940.html