Index: include/string =================================================================== --- include/string +++ include/string @@ -4040,100 +4040,101 @@ // operator + +// append template +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) { - basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); - typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size(); - typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size(); - __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz); - __r.append(__rhs.data(), __rhs_sz); + basic_string<_CharT, _Traits, _Allocator> __r = __lhs; + __r.append(__rhs); return __r; } template +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> -operator+(const _CharT* __lhs , const basic_string<_CharT,_Traits,_Allocator>& __rhs) +operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) { - basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator()); - typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = _Traits::length(__lhs); - typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size(); - __r.__init(__lhs, __lhs_sz, __lhs_sz + __rhs_sz); - __r.append(__rhs.data(), __rhs_sz); + basic_string<_CharT, _Traits, _Allocator> __r = __lhs; + __r.append(__rhs); return __r; -} +} // append +// append move template +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> -operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Allocator>& __rhs) +operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, + const basic_string<_CharT, _Traits, _Allocator>& __rhs) { - basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator()); - typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = __rhs.size(); - __r.__init(&__lhs, 1, 1 + __rhs_sz); - __r.append(__rhs.data(), __rhs_sz); - return __r; + __lhs.append(__rhs); + return _VSTD::move(__lhs); } template -inline +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> -operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, const _CharT* __rhs) +operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs) { - basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); - typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size(); - typename basic_string<_CharT, _Traits, _Allocator>::size_type __rhs_sz = _Traits::length(__rhs); - __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + __rhs_sz); - __r.append(__rhs, __rhs_sz); - return __r; + __lhs.append(__rhs); + return _VSTD::move(__lhs); } template +inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> -operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs) +operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, + basic_string<_CharT, _Traits, _Allocator>&& __rhs) { - basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); - typename basic_string<_CharT, _Traits, _Allocator>::size_type __lhs_sz = __lhs.size(); - __r.__init(__lhs.data(), __lhs_sz, __lhs_sz + 1); - __r.push_back(__rhs); - return __r; -} - -#ifndef _LIBCPP_CXX03_LANG + __lhs.append(__rhs); + return _VSTD::move(__lhs); +} // append move +// insert move template inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> -operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) +operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, + basic_string<_CharT, _Traits, _Allocator>&& __rhs) { - return _VSTD::move(__lhs.append(__rhs)); + __rhs.insert(0, __lhs); + return _VSTD::move(__rhs); } template inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> -operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) +operator+(const _CharT* __lhs, basic_string<_CharT,_Traits,_Allocator>&& __rhs) { - return _VSTD::move(__rhs.insert(0, __lhs)); -} + __rhs.insert(0, __lhs); + return _VSTD::move(__rhs); +} // insert move +// insert 0 template inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> -operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, basic_string<_CharT, _Traits, _Allocator>&& __rhs) +operator+(const _CharT* __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) { - return _VSTD::move(__lhs.append(__rhs)); -} + basic_string<_CharT, _Traits, _Allocator> __r = __rhs; + __r.insert(0, __lhs); + return __r; +} // insert 0 +// insert begin template inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> -operator+(const _CharT* __lhs , basic_string<_CharT,_Traits,_Allocator>&& __rhs) +operator+(_CharT __lhs, const basic_string<_CharT, _Traits, _Allocator>& __rhs) { - return _VSTD::move(__rhs.insert(0, __lhs)); -} + basic_string<_CharT, _Traits, _Allocator> __r(__rhs.get_allocator()); + __r.insert(__r.begin(), __lhs); + return __r; +} // insert begin +// insert begin move template inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> @@ -4141,16 +4142,20 @@ { __rhs.insert(__rhs.begin(), __lhs); return _VSTD::move(__rhs); -} +} // intert begin move +// push back template inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> -operator+(basic_string<_CharT, _Traits, _Allocator>&& __lhs, const _CharT* __rhs) +operator+(const basic_string<_CharT, _Traits, _Allocator>& __lhs, _CharT __rhs) { - return _VSTD::move(__lhs.append(__rhs)); -} + basic_string<_CharT, _Traits, _Allocator> __r(__lhs.get_allocator()); + __r.push_back(__rhs); + return __r; +} // push back +// push back move template inline _LIBCPP_INLINE_VISIBILITY basic_string<_CharT, _Traits, _Allocator> @@ -4158,9 +4163,9 @@ { __lhs.push_back(__rhs); return _VSTD::move(__lhs); -} +} // push back move -#endif // _LIBCPP_CXX03_LANG +// XXX: I don't think this should be just for _LIBCPP_CXX03_LANG // swap Index: test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/test_neg_one.pass.cpp =================================================================== --- test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/test_neg_one.pass.cpp +++ test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/test_neg_one.pass.cpp @@ -93,7 +93,7 @@ input_iterator(str+size+1), ios, err, v); assert(iter.base() == str+size); - assert(err == ios.goodbit); + assert(err == ios.goodbit); // XXX: This fails but I cannot figure out why. T expected = -value; assert(v == expected); }