Are std::vector elements guaranteed to be contiguous?

前端 未结 7 2213
不知归路
不知归路 2020-11-22 03:41

My question is simple: are std::vector elements guaranteed to be contiguous? In order word, can I use the pointer to the first element of a std::vector as a C-array?

<
7条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-22 04:05

    Yes, the elements of a std::vector are guaranteed to be contiguous.

提交回复
热议问题