c++ - Compiler hang when initializing large std::arrays -
i need initialize large multidimensional std::array of data:
class thing; class world { public: world() : space{nullptr} {}; ~world() = default; private: static unsigned int const size = 1000; std::array<std::array<std::array<std::unique_ptr<thing>, size>, size>, size> space; }; if try instantiate this, g++ 4.8.2 chokes: consumes available memory , not return. is, compiler hangs , never executable. why this? note clang++ has no trouble.
note: realize putting data on stack can overflow it. what best way initialize on heap? think making space reference (to allocated memory) best way, can't figure syntax out.
ok, can't explain nuance of why g++ puking on this, until work out, consider member declaration:
std::vector<std::array<std::array<std::unique_ptr<thing>,size>,size>> space; and in constructor initializer list:
world() : space{size} that should @ least compiling , move heap. note: better 64bit process. i'm going have hunt find out why g++ doing suspect doing.
Comments
Post a Comment