On 04.12.19 19:30, Andrey Semashev via Boost wrote:
On 2019-12-04 18:24, Alexander Grund via Boost wrote:
I would hope to see close to the same semantics as std::array
, which I believe allows data() to return nullptr. I don't think so:
"There is a special case for a zero-length array (|N == 0|). In that case, array.begin() == array.end(), which is some unique value. The effect of calling front() or back() on a zero-sized array is undefined." from https://en.cppreference.com/w/cpp/container/array
IMO this excludes nullptr as that won't be unique
I don't think iterators from different instances of a container are comparable. IOW, "unique" means distinct from any possible values of valid iterators obtained from this particular container instance.
That might not apply to pointers, though. I don't remember whether there are any guarantees wrt. data() of a zero-sized array, for example. You are right: "If size() is 0, data() may or may not return a null pointer." https://en.cppreference.com/w/cpp/container/array/data