更新时间:2022-11-23 20:06:09
主要区别在于 std :: array< T,N>
不会衰减到指向 T [N]
将位于的第一个元素的指针,和,您可以获取 std :: array< T,N> :: array的值副本代码>.
The principal differences are that std::array<T, N>
doesn't decay to a pointer to the first element where T[N]
would, and you can take a value copy of a std::array<T, N>
.
std :: array
还提供了一些有用的功能,例如字典比较运算符.
std::array
also offers some useful functions, such as lexicographical comparison operators.
但是,由于 N
必须是可在编译时评估的常量表达式,因此 std :: vector< T>
通常是首选.
But because N
has to be a compile time evaluable constant expression, std::vector<T>
is often the preferred choice.