Talk:cpp/container/vector bool
std::vector<bool> does not seem to have emplace() or emplace_back() methods. This is subject to LWG issue http://cplusplus.github.io/LWG/lwg-defects.html#2187. 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)
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. 170.148.69.140 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 23.3.6.1[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)
Type returned when dereferencing iterators
Can it be clarified what to expect when a `const_iterator` or an `iterator` is dereferenced? I suppose (without reading The Good Book) that the behaviour is similar to the explicitly mentioned `operator[]`, but I think in that case it's worth spelling it out maybe in the same sentence where `operator[]` shows.
198.129.118.226 16:07, 17 January 2020 (PST) Hamlet