1. std::vector
std::vector是C++的默认动态数组,其与array最大的区别在于vector的数组是动态的,即其大小可以在运行时更改。...用移动语义以 other 的内容替换内容(即从 other 移动 other 中的数据到此容器中)。
之后 other 在合法但未指定的状态。...具体的示例如下:
std::vector nums1 {3, 1, 4, 6, 5, 9};
std::vector nums2;
std::vector nums3;...减少大小到2
//c = {1, 2}
c.resize(6, 4); //将其size增加大小到6,填充值为4";
//c = {1, 2, 4, 4, 4,4}
swap
swap函数的主要作用是交换两个...::swap(std::vector)
std::swap(std::vector)函数是为std::vector特化std::swap 算法。