std::array 静态数组
(C++11引入的固定大小数组)
一、优点
二、基本用法
std::array<int, 5> arr1 = {1, 2, 3, 4, 5}; std::array<int, 5> arr2{6, 7, 8, 9, 10};int firstElement = arr1[0]; int secondElement = arr1.at(1);std::size_t size = arr1.size();for (auto it = arr1.begin(); it!= arr1.end(); ++it) { std::cout << *it << " "; }bool isEqual = (arr1 == arr2); bool isNotEqual = (arr1!= arr2); bool lessThan = (arr1 < arr2); // 等等其他比较操作
三、与其他容器和传统数组的转换
四、属性和方法
五、应用场景
小结:
Last updated