Talk:cpp/container/vector bool


std::vector<bool> does not seem to have emplace() or emplace_back() methods. This is subject to LWG issue It seems like the methods are going to be added in C++14. I don't think they should be a part of this page for now. Ericwf (talk) 17:26, 19 March 2014 (PDT)

they are in C++14, paragraph 23.3.7[vector.bool]/1. Thanks for pointing it out, I'll add them. --Cubbi (talk) 19:22, 19 March 2014 (PDT)

[edit] Disputing claim that non-contiguous storage is endorsed.

The C++11 Standard says "There is no requirement that the data be stored as a contiguous allocation of bool values. A space-optimized representation of bits is recommended instead." I do not believe that this endorses a non-contiguous memory layout, which is what the current cppreference page claims, it's just contrasting the equivalent of `bool[n]` where each element might occupy at least a byte, with compacted each-bit-stores-an-element storage. 20:46, 19 October 2014 (PDT)

Yes, I think you are correct. The standard wording that enforces contiguous storage (introduced in C++03) for vectors is found in[vector.overview]/1: "The elements of a vector are stored contiguously, meaning that if v is a vector<T, Allocator> where T is some type other than bool, then it obeys the identity &v[n] == &v[0] + n for all 0 <= n < v.size().". and it isn't written in terms of Allocator::allocate() calls, but rather in terms of pointer arithmetic. --Cubbi (talk) 06:15, 20 October 2014 (PDT)