c++ - C++ 是否提供与 pair<T1, T2> 相当的 "triple"模板?

标签 c++ stl std-pair

<分区>

C++ 有类似 std::pair 的东西吗?但有 3 个元素?

例如:

#include <triple.h>
triple<int, int, int> array[10];

array[1].first = 1;
array[1].second = 2;
array[1].third = 3;

最佳答案

您可能正在寻找 std::tuple :

#include <tuple>

....

std::tuple<int, int, int> tpl;

std::get<0>(tpl) = 1;
std::get<1>(tpl) = 2;
std::get<2>(tpl) = 3;

关于c++ - C++ 是否提供与 pair<T1, T2> 相当的 "triple"模板?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23637765/

相关文章:

c++ - std::pair 的这个 const 引用是如何工作的?

c++ - std::pair<U,V> 对齐控制

c++ - 在构造函数中初始化成员时,是否应该在成员上使用 std::move?

c++ - SSE 的条件语句

c++ - Boost spirit x3 解析器不适用于多个属性

c++ - 在不同的线程中播放声音

c++ - vector<bool>::push_back GCC 3.4.3 中的错误?

c++ - STL 列表 - 如何通过其对象字段查找列表元素

c++ - 从集合中的任意索引获取元素

c++ - 在 pair.first 上使用 std::move 是否会使 pair.second 无效?