Boost logo

Boost Users :

Subject: [Boost-users] [container] vector::resize() - value-initialization vs default-initialization
From: Adam Romanek (romanek.adam_at_[hidden])
Date: 2014-04-16 07:29:25


first, I'd like to focus on Boost 1.54. The documentation of
boost::container::vector::resize(size_type) says the elements are
*default constructed* [1]. The same applies to the respective
constructor: boost::container::vector(size_type n). This is a
significant deviation from what C++11 std::vector::resize(size_type)
does as it *value-initializes* the new elements.

Is the documentation of Boost.Container wrong in this case? Or the
behavior of the container differs from the one defined by the standard?

On the other hand in Boost 1.55 I see some changes related to the way
elements are constructed (not mentioned in the release note). A new
constructor and resize() method were added taking default_init_t to
indicate default construction of new elements is desired. However, the
documentation of boost::container::resize(size_type new_size,
default_init_t) says the new elements are value initialized [2]. Note
that the documentation of the respective constructor is correct and says
the elements are default constructed. I also assume that the addition of
the new constructor/resize method changed the behavior of the original
constructor/resize method to be compliant with std::vector.

@Ion: thanks for your good work on this library. I use it more and more
often as it provides great features, useful especially in C++03

If you want me to file any tickets on the above-mentioned issues please
just say so.

Adam Romanek


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at