ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
[TOC] ## 元组 关于元组的使用有三个核心的函数: 1. `std::make_tuple`: 构造元组 2. `std::get`: 获得元组某个位置的值 3. `std::tie`: 元组拆包 ## 示例 ``` map<string, tuple<int, int, string>> student; student["a"] = make_tuple(1, 1, "aaa"); student["c"] = make_tuple(2, 2, "bbb"); for (auto [key,val] : student) { auto [i1, i2, s1] = val; cout << key << ":" << i1 << " " << i2 << " " << s1 << "\n"; } // output: // a:1 1 aaa // c:2 2 bbb ```