Mark string_view::to_string as const. Fixes PR21428
authorMarshall Clow <mclow.lists@gmail.com>
Sun, 2 Nov 2014 15:35:32 +0000 (15:35 +0000)
committerMarshall Clow <mclow.lists@gmail.com>
Sun, 2 Nov 2014 15:35:32 +0000 (15:35 +0000)
llvm-svn: 221101

libcxx/include/experimental/string_view
libcxx/test/experimental/string.view/string.view.ops/to_string.pass.cpp

index b0382e5..1870615 100644 (file)
@@ -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
index e69cb95..6387ac2 100644 (file)
@@ -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 );