Let's get the party started. What name do you suggest and why?
The alternative that I prefer for the suffix is "_view", as in "string_view" and "basic_string_view". It captures the functionality well and signals a need to actually read the specs to figure out what it is.
On Thu, Jan 10, 2013 at 9:06 AM, Olaf van der Spek <olafv...@gmail.com> wrote:
Let's get the party started. What name do you suggest and why?
My problem with "string_ref" is that "reference" has a very specific meaning in the context of C++, and this proposal does not provide a C++ reference to a string. There have already been several examples on the Boost list of people being badly misled by the "_ref" suffix, and much effort wasted straightening them out.
The alternative that I prefer for the suffix is "_view", as in "string_view" and "basic_string_view". It captures the functionality well and signals a need to actually read the specs to figure out what it is.
On Thu, Jan 10, 2013 at 2:37 PM, Jeffrey Yasskin <jyas...@googlers.com> wrote:
> On Thu, Jan 10, 2013 at 8:31 AM, Beman Dawes <bda...@acm.org> wrote:
>> My problem with the "basic_string_" prefix for the template version is that
>> the type provides a generic view (or reference, if you prefer) of a string,
>> not a view or reference of a basic_string. Thus I prefer
>> "generic_string_view" or "generic_string_ref".
>
> I somewhat agree that the standard was wrong to use "basic_*" as the
> "templated version of" prefix, but that's what the standard picked. Is
> there a strong enough reason that string_{ref,view} should be
> inconsistent?
The point is that since the standard library uses "basic_" as the
prefix for its templated string class, string_{ref,view} has to use a
different prefix since it doesn't provide a {ref,view} of a
basic_string. Instead it provides a {ref,view} of any string that
consists of contiguous characters, and happens to provide an interface
that overlaps the basic_string interface.
So we could call it {generic,contiguous, whatever}_string_{ref,view}
as long as "whatever" isn't "basic".
On Thu, Jan 10, 2013 at 4:27 PM, Vicente J. Botet Escriba
<vicent...@wanadoo.fr> wrote:
> After checking the proposal it seems that string_ref could not be used to
> modify the reference string. If this is the case +1 for string_view.
Me too. The first time I saw the name, I guess it can potentially
modified the referred string, but it can not, by design. *_view may
not be the best choice, but, at least, it's clearer than *_ref.
On Thu, Jan 10, 2013 at 9:06 AM, Olaf van der Spek <olafv...@gmail.com> wrote:Let's get the party started. What name do you suggest and why?
My problem with "string_ref" is that "reference" has a very specific meaning in the context of C++, and this proposal does not provide a C++ reference to a string. There have already been several examples on the Boost list of people being badly misled by the "_ref" suffix, and much effort wasted straightening them out.
The alternative that I prefer for the suffix is "_view", as in "string_view" and "basic_string_view". It captures the functionality well and signals a need to actually read the specs to figure out what it is.
Another suggestion (which maybe was briefly mentioned before?), why
not just std::substring? The "sub" gives quite a clue that it is just
referencing a part of something else, not the owner of the string.
And I think everyone would be comfortable with the concept that a
std::string could convert to a substring that spans the entire string.