std::vector<T> foo(100) initialises every element with the default value for T. Does boost::multi_array<T, 2> foo(boost::extents[10][10]) do the same?
1 Answer
It does, using std::allocator::construct() by default.
1 Comment
alfC
That is right, and
construct calls new(p) U(); which initializes to zero even for trivial types. I think this choice is a mistake for trivial types for performance and debuggability reasons (it is not possible to detect initialized memory because of this forced initialization).