[libcxx] r221101 - Mark string_view::to_string as const. Fixes PR21428

David Blaikie dblaikie at gmail.com
Sun Nov 2 08:35:06 PST 2014


On Nov 2, 2014 7:49 AM, "Marshall Clow" <mclow.lists at gmail.com> wrote:
>
> Author: marshall
> Date: Sun Nov  2 09:35:32 2014
> New Revision: 221101
>
> URL: http://llvm.org/viewvc/llvm-project?rev=221101&view=rev
> Log:
> Mark string_view::to_string as const. Fixes PR21428
>
> Modified:
>     libcxx/trunk/include/experimental/string_view
>
libcxx/trunk/test/experimental/string.view/string.view.ops/to_string.pass.cpp
>
> Modified: libcxx/trunk/include/experimental/string_view
> URL:
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/string_view?rev=221101&r1=221100&r2=221101&view=diff
>
==============================================================================
> --- libcxx/trunk/include/experimental/string_view (original)
> +++ libcxx/trunk/include/experimental/string_view Sun Nov  2 09:35:32 2014
> @@ -349,7 +349,8 @@ _LIBCPP_BEGIN_NAMESPACE_LFTS
>
>          template<class _Allocator = allocator<_CharT> >
>          _LIBCPP_INLINE_VISIBILITY
> -        basic_string<_CharT, _Traits, _Allocator> to_string( const
_Allocator& __a = _Allocator())
> +        basic_string<_CharT, _Traits, _Allocator>
> +        to_string( const _Allocator& __a = _Allocator()) const
>          { return basic_string<_CharT, _Traits, _Allocator> ( begin(),
end(), __a ); }
>
>          size_type copy(_CharT* __s, size_type __n, size_type __pos = 0)
const
>
> Modified:
libcxx/trunk/test/experimental/string.view/string.view.ops/to_string.pass.cpp
> URL:
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
>
==============================================================================
> ---
libcxx/trunk/test/experimental/string.view/string.view.ops/to_string.pass.cpp
(original)
> +++
libcxx/trunk/test/experimental/string.view/string.view.ops/to_string.pass.cpp
Sun Nov  2 09:35:32 2014

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?

> @@ -24,8 +24,8 @@ template<typename CharT>
>  void test ( const CharT *s ) {
>      typedef std::basic_string<CharT> String ;
>      {
> -    std::experimental::basic_string_view<CharT> sv1 ( s );
> -    String                                      str1 = (String) sv1;
> +    const std::experimental::basic_string_view<CharT> sv1 ( s );
> +    String                                            str1 = (String)
sv1;
>
>      assert ( sv1.size() == str1.size ());
>      assert ( std::char_traits<CharT>::compare ( sv1.data(),
str1.data(),  sv1.size()) == 0 );
> @@ -38,8 +38,8 @@ void test ( const CharT *s ) {
>      }
>
>      {
> -    std::experimental::basic_string_view<CharT> sv1;
> -    String                                      str1 = (String) sv1;
> +    const std::experimental::basic_string_view<CharT> sv1;
> +    String                                            str1 = (String)
sv1;
>
>      assert ( sv1.size() == str1.size ());
>      assert ( std::char_traits<CharT>::compare ( sv1.data(), str1.data(),
sv1.size()) == 0 );
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141102/9a6b16b6/attachment.html>


More information about the cfe-commits mailing list