Compiler hang when initializing large std::arrays

前端 未结 3 1923
清歌不尽
清歌不尽 2021-01-12 16:21

I need to initialize a very large multidimensional std::array of data:

class Thing;

class World
{
public:
    World() : space{nullptr} {};
             


        
3条回答
  •  暖寄归人
    2021-01-12 16:44

    As you are using unique_ptr it looks like you are looking for a sparse 3d-matrix like type. For implementing a sparse matrix you could have a look at What is the best way to create a sparse array in C++? and as an implementation detail you could use Boost Multi-index for implementing fast access to all dimensions.

提交回复
热议问题