Phil Endecott wrote:
Peter Dimov
wrote: Krystian Stasiowski wrote:
- Empty class specialization for N = 0: Implemented
I don't like this change. A special case for close to zero benefit that changes the semantics of data() to not be unique per instance.
I would hope to see close to the same semantics as std::array
, which I believe allows data() to return nullptr.
nullptr is invalid here, because the string is null-terminated.
Storing the size (as capacity - size) in the last char for N < 256 will have more impact, but I'm not sure that it too is worth the added complexity.
Why the last char, rather than always having the size (of whatever appropriate type) first? Is the idea that this makes data() and c_str() essentially no-ops?
The idea here is that you win one byte by reusing the last byte of the storage as the size, overlapping it with the null terminator in the size() == N case (because capacity - size becomes 0).