|
Boost Users : |
Subject: Re: [Boost-users] [container] vector::resize() - value-initialization vs default-initialization
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2014-04-16 08:13:01
El 16/04/2014 13:29, Adam Romanek escribió:
> Hi!
>
> 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?
The documentation is wrong, value initialization was used. Do you think
something like:
"if T's default constructor throws" -> "if T's value/default
initialization throws" is clear enough?
> 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.
I somehow updated the documentation of the wrong overload.
default_init_t overloads "default initialize" the new value.
resize(size_type n) value initializes the new value.
Thanks for reporting this. I'll try to fix this for Boost 1.56.
> Finally,
> @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
> environments.
Thanks for your feedback. If Boost.Container does not offer anything
different from standard containers, then there is no room for this
library. So if you have more ideas to add, please suggest them.
If you don't ming, a single ticket with the comments of your post will
be enough to do all the changes.
Best,
Ion
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net