Multi-dimensional vector initialization

后端 未结 3 1476
南笙
南笙 2020-12-28 22:28

I have following std::vector declaration:

std::vector > > m_input;

I am initializing

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-28 23:04

    If you can assert that your vector dimensions are going to be of a fixed length, then why not use std::array?

    For example:

    std:array, 100>, 100>

    That way you can take advantage of all the memory being contiguously allocated (as hinted at by Viktor_Sehr in the comments), without the added implementation woes of accessing a 1-dimensional array in a 3-dimensional way.

提交回复
热议问题