I need to initialize a very large multidimensional std::array data std::array :
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 you try to create an instance, g ++ 4.8.2 throttles: it consumes all available memory and does not return. That is, the compiler freezes, and I never get the executable. Why is this? Please note that clang ++ has no problems.
Note. I fully understand that multiple data on the stack can overflow it. What is the best way to initialize it on the heap? I think creating a space link (for allocated memory) would be a better way, but I can't understand the syntax.
source share