This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Implement N3762 string_view: a non-owning reference to a string.
- From: David Kastrup <dak at gnu dot org>
- To: libstdc++ at gcc dot gnu dot org
- Date: Mon, 18 Nov 2013 15:49:17 +0100
- Subject: Re: Implement N3762 string_view: a non-owning reference to a string.
- Authentication-results: sourceware.org; auth=none
- References: <5285A634 dot 7070907 at verizon dot net> <CAGNvRgDT+f3bvRCJQHnxom43KvXVihPp0v9cUuhoO9jrP8JQ1g at mail dot gmail dot com>
Daniel Krügler <daniel.kruegler@gmail.com> writes:
> 2013/11/15 Ed Smith-Rowland <3dw4rd@verizon.net>:
>> Greetings,
>>
>> As the title says. It's a pretty simple class" a non-mutating read-only
>> view into a const CharT* or a basic_string.
>>
>> Built and tested on x86_64-linux.
>>
>> OK?
>
> Sorry, if this is documented somewhere, but is this intended to implement
>
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3762.html
>
> ? I don't think that your implementation is valid, because it maps an
> empty string view into a NULL data pointer. But according to the
> specification of data() the return type, this isn't feasible:
>
> <quote>
> constexpr const charT* data() const noexcept;
>
> Returns: A non-null pointer p such that p + i == &operator[](i) for
> each i in [0,size()).
> </quote>
Well, the "for each" qualifier is empty. So the "such that" clause is
trivially true. That does not help with "non-null pointer" probably.
But note that it would be fine to use a different pointer to unmapped
memory.
--
David Kastrup