且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

T [N]和std :: array< T,N>之间的差异

更新时间: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.