Is the use of std::vector objects in C++ acceptable, or should I use an alternative?

后端 未结 7 1006
有刺的猬
有刺的猬 2020-11-29 09:29

I\'m working with a user-defined quantity of bits (I\'m holding a three-dimensional array of bits, so the size increases cubically - assume no less then 512 bits), and need

7条回答
  •  佛祖请我去吃肉
    2020-11-29 09:42

    There's nothing wrong with vector, except that it isn't equivalent to a vector were T is the integer type equivalent to bool. This only shows in performance (CPUs only access bytes at a time, where in a vector every element is stored in one bit) and memory access (a reference to a first element of a vector is not equivalent to an array like with any other vector.

    It is part of the Standard, unfortunately: see section 23.3.7 (C++0x FDIS).

提交回复
热议问题