What is std::pair?(什么是 std::pair?)
问题描述
std::pair 有什么用,我为什么要使用它,boost::compressed_pair 有什么好处?
std::pair 是一种将两个值组合为一个对象的数据类型.std::map 将其用作密钥,值对.
在您学习时pair,您可以查看 tuple.它就像 pair ,但用于对任意数量的值进行分组.tuple 是 TR1 的一部分,许多编译器已经将它包含在他们的标准库实现中.
此外,请参阅 Pete Becker 所著《C++ 标准库扩展:教程和参考》一书的第 1 章元组",ISBN-13:9780321412997,以获得详尽的解释.>
What is std::pair for, why would I use it, and what benefits does boost::compressed_pair bring?
std::pair is a data type for grouping two values together as a single object. std::map uses it for key, value pairs.
While you're learning pair, you might check out tuple. It's like pair but for grouping an arbitrary number of values. tuple is part of TR1 and many compilers already include it with their Standard Library implementations.
Also, checkout Chapter 1, "Tuples," of the book The C++ Standard Library Extensions: A Tutorial and Reference by Pete Becker, ISBN-13: 9780321412997, for a thorough explanation.
这篇关于什么是 std::pair?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:什么是 std::pair?
基础教程推荐
- 初始化列表*参数*评估顺序 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- CString 到 char* 2021-01-01
