Boost logo

Boost :

Subject: Re: [boost] Heads up - string_ref landing
From: Yakov Galka (ybungalobill_at_[hidden])
Date: 2012-12-12 02:50:29


On Sun, Dec 9, 2012 at 3:13 PM, Rob Stewart <robertstewart_at_[hidden]>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.

-- 
Yakov

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk