
2013/2/12 Andrew Hundt <athundt@gmail.com>
On Tue, Feb 12, 2013 at 3:02 PM, Krzysztof Czainski <1czajnik@gmail.com
wrote:
2013/2/12 Nevin Liber <nevin@eviloverlord.com>
On 12 February 2013 09:10, Krzysztof Czainski <1czajnik@gmail.com> wrote:
However, I'd rather there was a new member function for "noinit" pushing/resizing. Just like the emplace* family of functions was added, while the push* family was left alone ;-)
Anyway, personally I'm only interested in features, that can be added for C++03 ;-) And noinit_push*/noinit_resize (enabled_if< is_pod<value_type> ) are things I have use cases for.
Could you explain a little more about why emplace_back is not sufficient? I believe it includes rvalue reference emulation for C++03.
Sure: struct X { int a; double b; } typedef boost::container::vector<X> V; // or varray<X,5> or some other container ;-) V v; v.emplace_back(); // unnecessarily zero-initializes memory v.back().a = 1; v.back().b = 3.14; If emplace_back() didn't zero-initialize PODs, it would be inconsistent with std containers, and therefore surprising, so I suggest a new function for this. Same for resize(). Or perhaps if not a new member function, maybe an overload for a noinit tag, used like so: v.emplace_back( noinit ); With noinit defined in the library something like: struct noinit_t {}; noinit_t const noinit = {}; Regards, Kris