diff options
author | Marshall Clow <mclow.lists@gmail.com> | 2016-03-09 17:51:43 +0000 |
---|---|---|
committer | Marshall Clow <mclow.lists@gmail.com> | 2016-03-09 17:51:43 +0000 |
commit | e96f8b52d92ee7d1d13a7a0e1f22a15c2bc52f5b (patch) | |
tree | dc99cfa5c6fb707def0c4b2e6865effe3d745d0e /libcxx/include | |
parent | a1d6a6f1de5b453a5839d204a732fc9eb1b707ab (diff) | |
download | bcm5719-llvm-e96f8b52d92ee7d1d13a7a0e1f22a15c2bc52f5b.tar.gz bcm5719-llvm-e96f8b52d92ee7d1d13a7a0e1f22a15c2bc52f5b.zip |
Implement LWG#2583: There is no way to supply an allocator for basic_string(str, pos)
llvm-svn: 263036
Diffstat (limited to 'libcxx/include')
-rw-r--r-- | libcxx/include/string | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/libcxx/include/string b/libcxx/include/string index a4537793b4d..6f5089c17fa 100644 --- a/libcxx/include/string +++ b/libcxx/include/string @@ -98,8 +98,10 @@ public: basic_string(const basic_string& str); basic_string(basic_string&& str) noexcept(is_nothrow_move_constructible<allocator_type>::value); - basic_string(const basic_string& str, size_type pos, size_type n = npos, + basic_string(const basic_string& str, size_type pos, // LWG#2583 const allocator_type& a = allocator_type()); + basic_string(const basic_string& str, size_type pos, size_type n, // LWG#2583 + const Allocator& a = Allocator()); basic_string(const value_type* s, const allocator_type& a = allocator_type()); basic_string(const value_type* s, size_type n, const allocator_type& a = allocator_type()); basic_string(size_type n, value_type c, const allocator_type& a = allocator_type()); @@ -1397,7 +1399,9 @@ public: basic_string(size_type __n, value_type __c); _LIBCPP_INLINE_VISIBILITY basic_string(size_type __n, value_type __c, const allocator_type& __a); - basic_string(const basic_string& __str, size_type __pos, size_type __n = npos, + basic_string(const basic_string& __str, size_type __pos, size_type __n, + const allocator_type& __a = allocator_type()); + basic_string(const basic_string& __str, size_type __pos, const allocator_type& __a = allocator_type()); template<class _InputIterator> _LIBCPP_INLINE_VISIBILITY @@ -2223,6 +2227,20 @@ basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __st } template <class _CharT, class _Traits, class _Allocator> +basic_string<_CharT, _Traits, _Allocator>::basic_string(const basic_string& __str, size_type __pos, + const allocator_type& __a) + : __r_(__a) +{ + size_type __str_sz = __str.size(); + if (__pos > __str_sz) + this->__throw_out_of_range(); + __init(__str.data() + __pos, __str_sz - __pos); +#if _LIBCPP_DEBUG_LEVEL >= 2 + __get_db()->__insert_c(this); +#endif +} + +template <class _CharT, class _Traits, class _Allocator> template <class _InputIterator> typename enable_if < |