
On 12/12/2012 2:50 AM, Yakov Galka wrote:
On Sun, Dec 9, 2012 at 3:13 PM, Rob Stewart <robertstewart@comcast.net>wrote:
- char const * data() - size_t length() I propose the alias size().
string_ref isn't a container like string, so I prefer just length().
I propose adding size() and throwing length() away. Really.
1. According to the standard, string is not a container either. 2. initializer_list, which is semantically very similar to string_ref, does use .size(). 3. Leaving the scope of the standard, Boost.Range uses boost::size(x) for ranges. I.e. size is a property of a range, not a container. 4. I always found string::length() to be an inconsistency in the standard library. I guess the reason for its existence is purely historical.
+1 I've got template code that currently takes, string's and vector<char>'s and uses size. With string_ref being a natural candidate, I'd hope it would work out of the box. Jeff