更新时间:2022-11-23 20:10:32
主要区别在于 std :: array< T,N>
不会衰减到指向第一个元素的指针,其中 T [N]
将和作为 std :: array< T,N>的值副本。
。
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.