<p dir="ltr"><br>
On Nov 3, 2014 7:35 AM, "Marshall Clow" <<a href="mailto:mclow.lists@gmail.com">mclow.lists@gmail.com</a>> wrote:<br>
><br>
><br>
> On Nov 2, 2014, at 10:35 AM, David Blaikie <<a href="mailto:dblaikie@gmail.com">dblaikie@gmail.com</a>> wrote:<br>
><br>
>><br>
>> On Nov 2, 2014 7:49 AM, "Marshall Clow" <<a href="mailto:mclow.lists@gmail.com">mclow.lists@gmail.com</a>> wrote:<br>
>> ><br>
>> > Author: marshall<br>
>> > Date: Sun Nov  2 09:35:32 2014<br>
>> > New Revision: 221101<br>
>> ><br>
>> > URL: <a href="http://llvm.org/viewvc/llvm-project?rev=221101&view=rev">http://llvm.org/viewvc/llvm-project?rev=221101&view=rev</a><br>
>> > Log:<br>
>> > Mark string_view::to_string as const. Fixes PR21428<br>
>> ><br>
>> > Modified:<br>
>> >     libcxx/trunk/include/experimental/string_view<br>
>> >     libcxx/trunk/test/experimental/string.view/string.view.ops/to_string.pass.cpp<br>
>> ><br>
>> > Modified: libcxx/trunk/include/experimental/string_view<br>
>> > URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/string_view?rev=221101&r1=221100&r2=221101&view=diff">http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/string_view?rev=221101&r1=221100&r2=221101&view=diff</a><br>
>> > ==============================================================================<br>
>> > --- libcxx/trunk/include/experimental/string_view (original)<br>
>> > +++ libcxx/trunk/include/experimental/string_view Sun Nov  2 09:35:32 2014<br>
>> > @@ -349,7 +349,8 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS<br>
>> ><br>
>> >          template<class _Allocator = allocator<_CharT> ><br>
>> >          _LIBCPP_INLINE_VISIBILITY<br>
>> > -        basic_string<_CharT, _Traits, _Allocator> to_string( const _Allocator& __a = _Allocator())<br>
>> > +        basic_string<_CharT, _Traits, _Allocator><br>
>> > +        to_string( const _Allocator& __a = _Allocator()) const<br>
>> >          { return basic_string<_CharT, _Traits, _Allocator> ( begin(), end(), __a ); }<br>
>> ><br>
>> >          size_type copy(_CharT* __s, size_type __n, size_type __pos = 0) const<br>
>> ><br>
>> > Modified: libcxx/trunk/test/experimental/string.view/string.view.ops/to_string.pass.cpp<br>
>> > URL: <a href="http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/experimental/string.view/string.view.ops/to_string.pass.cpp?rev=221101&r1=221100&r2=221101&view=diff">http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/experimental/string.view/string.view.ops/to_string.pass.cpp?rev=221101&r1=221100&r2=221101&view=diff</a><br>
>> > ==============================================================================<br>
>> > --- libcxx/trunk/test/experimental/string.view/string.view.ops/to_string.pass.cpp (original)<br>
>> > +++ libcxx/trunk/test/experimental/string.view/string.view.ops/to_string.pass.cpp Sun Nov  2 09:35:32 2014<br>
>><br>
>> Perhaps I'm missing something, but neither of these test changes appear to test the code that was changed - they look like they're testing for the conversion operator, not the to_string member function?<br>
><br>
><br>
> David -<br>
><br>
> It doesn’t show in the diff, but there are calls to to_string later in this file.</p>
<p dir="ltr">Oh, awesome. Thanks for the explanation.</p>
<p dir="ltr">> The updated tests fail w/o the “const” in <string_view>, and pass with it.<br>
><br>
>     {<br>
>     const std::experimental::basic_string_view<CharT> sv1 ( s );<br>
>     String                                            str1 = (String) sv1;<br>
>     <br>
>     assert ( sv1.size() == str1.size ());<br>
>     assert ( std::char_traits<CharT>::compare ( sv1.data(), str1.data(),  sv1.size()) == 0 );<br>
><br>
> #if __cplusplus >= 201103L<br>
>     auto str2 = sv1.to_string(min_allocator<CharT>());<br>
>     assert ( sv1.size() == str2.size ());<br>
>     assert ( std::char_traits<CharT>::compare ( sv1.data(), str2.data(), sv1.size()) == 0 );<br>
> #endif<br>
>     }<br>
><br>
> — Marshall<br>
><br>
><br>
</p>