On 30/11/2018 20:43, Olaf van der Spek wrote:
Not really: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1227r0.html
Isn’t that proposed definition of ssize() essentially identical to // member function constexpr difference_type ssize() const { return std::distance(begin(), end()); } // or moral equivalent, for containers that can implement it // more efficiently another way. // non-member function in std:: template <class C> constexpr auto ssize(const C& c) { return distance(begin(c), end(c)); } // or calling member ssize() if it exists The above seems "better" in that it allows a container intended exclusively for small sizes to use a difference_type smaller than ptrdiff_t. (In the text it explains why it's a bad idea for a container using uint16_t sizes with more than 32767 elements to use int16_t as a difference_type, but as I understand it that's already undefined behaviour -- size_type is required to be larger than difference_type and difference_type should be able to express std::distance(begin(), end()) or some algorithms will break.)