From patchwork Mon Jul 1 16:24:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 256173 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id C9A9A2C007C for ; Tue, 2 Jul 2013 02:24:37 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; q=dns; s=default; b=t+wOvvGu2ClkdGEKOG+eWpYFvfr719EaVD4NMrTvLN+ hCx3rTewrh+GVpffIS/y9lmpnXy8OzJnxG/GOLPZ/g3khEmyyxd9dJBzs1dcmGhW KCePBtam9y3/0Cf/YDlddPrFcreT5WKIKcf9VX+I3hCl2UF8QyhNXJoVHVXRmRvs = DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:content-type; s=default; bh=X02hKFPdHezRzUWigzKoG5ze7YE=; b=fzuTeNbSR23z8e5ej 2XvVdjUdCl6oGwQBhCoLwIxWGFseeADdmAob2PH0NqwChx2Wq1y82monwONHPmve jg1i3Dfh/GJP0KR/cDlPHAy7vKyhknQdiQsHQAyW4+jFRz6Un6pa+oADDTaL3SwF tC2zI/fXkIKLkyuDxzlxy448Uw= Received: (qmail 3648 invoked by alias); 1 Jul 2013 16:24:29 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 3631 invoked by uid 89); 1 Jul 2013 16:24:29 -0000 X-Spam-SWARE-Status: No, score=-5.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_MED, RCVD_IN_HOSTKARMA_NO, RCVD_IN_HOSTKARMA_YE, RP_MATCHES_RCVD, SPF_PASS, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Mon, 01 Jul 2013 16:24:26 +0000 Received: from ucsinet22.oracle.com (ucsinet22.oracle.com [156.151.31.94]) by userp1040.oracle.com (Sentrion-MTA-4.3.1/Sentrion-MTA-4.3.1) with ESMTP id r61GI4Qx023872 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 1 Jul 2013 16:18:04 GMT Received: from aserz7022.oracle.com (aserz7022.oracle.com [141.146.126.231]) by ucsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r61GOMYp016309 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 1 Jul 2013 16:24:23 GMT Received: from abhmt108.oracle.com (abhmt108.oracle.com [141.146.116.60]) by aserz7022.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id r61GOM35014987; Mon, 1 Jul 2013 16:24:22 GMT Received: from poldo4.casa (/79.36.29.136) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 01 Jul 2013 09:24:21 -0700 Message-ID: <51D1AD33.40803@oracle.com> Date: Mon, 01 Jul 2013 18:24:19 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130510 Thunderbird/17.0.6 MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: libstdc++ Subject: [v3] Update container::insert / emplace members to take const_iterator(s) (Part 3) X-Virus-Found: No Hi, this is the last part (for now at least!), handling std::list and ext/vstring. Tested x86_64-linux, normal/debug/profile. Thanks, Paolo. ///////////////////////// 2013-07-01 Paolo Carlini * include/bits/stl_list.h (list<>::insert(iterator, size_type, const value_type&), list<>::insert(iterator, initializer_list<>), list<>::insert(iterator, _InputIterator, _InputIterator), list<>::splice(iterator, list&&), list<>::splice(iterator, list&), list<>::splice(iterator, list&&, iterator), list<>::splice(iterator, list&, iterator), list<>::splice(iterator, list&&, iterator, iterator), list<>::splice(iterator, list&, iterator, iterator)): Adjust C++11 signatures to take const_iterator(s). * include/bits/list.tcc (list<>::insert(const_iterator, size_type, const value_type&), list<>::insert(const_iterator, _InputIterator, _InputIterator)): Define. * include/ext/vstring.h (__versa_string<>::insert(iterator, size_type, _CharT), __versa_string<>::insert(iterator, _InputIterator, _InputIterator), __versa_string<>::insert(iterator, std::initializer_list<>), __versa_string<>::replace(iterator, iterator, _InputIterator, _InputIterator), __versa_string<>:: replace(iterator, iterator, std::initializer_list<>)): Adjust C++11 signatures to take const_iterator(s). (__versa_string<>::_M_replace_dispatch): Take const_iterators. * include/ext/vstring.tcc: Likewise. * include/debug/list: Adjust. * include/profile/list: Likewise. * testsuite/23_containers/list/operations/splice/const_iterator.cc: New. * testsuite/23_containers/list/modifiers/insert/const_iterator.cc: Extend. * testsuite/ext/vstring/modifiers/insert/char/const_iterator.cc: Likewise. * testsuite/ext/vstring/modifiers/insert/wchar_t/const_iterator.cc: Likewise. * testsuite/ext/vstring/modifiers/replace/char/const_iterator.cc: Likewise. * testsuite/ext/vstring/modifiers/replace/wchar_t/const_iterator.cc: Likewise. * testsuite/23_containers/list/requirements/dr438/assign_neg.cc: Adjust dg-error line number. * testsuite/23_containers/list/requirements/dr438/ constructor_1_neg.cc: Likewise. * testsuite/23_containers/list/requirements/dr438/ constructor_2_neg.cc: Likewise. * testsuite/23_containers/list/requirements/dr438/insert_neg.cc: Likewise. Index: include/bits/list.tcc =================================================================== --- include/bits/list.tcc (revision 200579) +++ include/bits/list.tcc (working copy) @@ -107,9 +107,43 @@ return iterator(__tmp); } +#if __cplusplus >= 201103L template typename list<_Tp, _Alloc>::iterator list<_Tp, _Alloc>:: + insert(const_iterator __position, size_type __n, const value_type& __x) + { + if (__n) + { + list __tmp(__n, __x, get_allocator()); + iterator __it = __tmp.begin(); + splice(__position, __tmp); + return __it; + } + return __position._M_const_cast(); + } + + template + template + typename list<_Tp, _Alloc>::iterator + list<_Tp, _Alloc>:: + insert(const_iterator __position, _InputIterator __first, + _InputIterator __last) + { + list __tmp(__first, __last, get_allocator()); + if (!__tmp.empty()) + { + iterator __it = __tmp.begin(); + splice(__position, __tmp); + return __it; + } + return __position._M_const_cast(); + } +#endif + + template + typename list<_Tp, _Alloc>::iterator + list<_Tp, _Alloc>:: #if __cplusplus >= 201103L erase(const_iterator __position) #else Index: include/bits/stl_list.h =================================================================== --- include/bits/stl_list.h (revision 200579) +++ include/bits/stl_list.h (working copy) @@ -1113,9 +1113,11 @@ /** * @brief Inserts the contents of an initializer_list into %list - * before specified iterator. - * @param __p An iterator into the %list. + * before specified const_iterator. + * @param __p A const_iterator into the %list. * @param __l An initializer_list of value_type. + * @return An iterator pointing to the first element inserted + * (or __position). * * This function will insert copies of the data in the * initializer_list @a l into the %list before the location @@ -1124,13 +1126,31 @@ * This operation is linear in the number of elements inserted and * does not invalidate iterators and references. */ - void - insert(iterator __p, initializer_list __l) - { this->insert(__p, __l.begin(), __l.end()); } + iterator + insert(const_iterator __p, initializer_list __l) + { return this->insert(__p, __l.begin(), __l.end()); } #endif +#if __cplusplus >= 201103L /** * @brief Inserts a number of copies of given data into the %list. + * @param __position A const_iterator into the %list. + * @param __n Number of elements to be inserted. + * @param __x Data to be inserted. + * @return An iterator pointing to the first element inserted + * (or __position). + * + * This function will insert a specified number of copies of the + * given data before the location specified by @a position. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ + iterator + insert(const_iterator __position, size_type __n, const value_type& __x); +#else + /** + * @brief Inserts a number of copies of given data into the %list. * @param __position An iterator into the %list. * @param __n Number of elements to be inserted. * @param __x Data to be inserted. @@ -1147,12 +1167,16 @@ list __tmp(__n, __x, get_allocator()); splice(__position, __tmp); } +#endif +#if __cplusplus >= 201103L /** * @brief Inserts a range into the %list. - * @param __position An iterator into the %list. + * @param __position A const_iterator into the %list. * @param __first An input iterator. * @param __last An input iterator. + * @return An iterator pointing to the first element inserted + * (or __position). * * This function will insert copies of the data in the range [@a * first,@a last) into the %list before the location specified by @@ -1161,12 +1185,26 @@ * This operation is linear in the number of elements inserted and * does not invalidate iterators and references. */ -#if __cplusplus >= 201103L template> + iterator + insert(const_iterator __position, _InputIterator __first, + _InputIterator __last); #else + /** + * @brief Inserts a range into the %list. + * @param __position An iterator into the %list. + * @param __first An input iterator. + * @param __last An input iterator. + * + * This function will insert copies of the data in the range [@a + * first,@a last) into the %list before the location specified by + * @a position. + * + * This operation is linear in the number of elements inserted and + * does not invalidate iterators and references. + */ template -#endif void insert(iterator __position, _InputIterator __first, _InputIterator __last) @@ -1174,6 +1212,7 @@ list __tmp(__first, __last, get_allocator()); splice(__position, __tmp); } +#endif /** * @brief Remove element at given position. @@ -1275,7 +1314,7 @@ */ void #if __cplusplus >= 201103L - splice(iterator __position, list&& __x) + splice(const_iterator __position, list&& __x) #else splice(iterator __position, list& __x) #endif @@ -1284,18 +1323,33 @@ { _M_check_equal_allocators(__x); - this->_M_transfer(__position, __x.begin(), __x.end()); + this->_M_transfer(__position._M_const_cast(), + __x.begin(), __x.end()); } } #if __cplusplus >= 201103L void - splice(iterator __position, list& __x) + splice(const_iterator __position, list& __x) { splice(__position, std::move(__x)); } #endif +#if __cplusplus >= 201103L /** * @brief Insert element from another %list. + * @param __position Const_iterator referencing the element to + * insert before. + * @param __x Source list. + * @param __i Const_iterator referencing the element to move. + * + * Removes the element in list @a __x referenced by @a __i and + * inserts it into the current list before @a __position. + */ + void + splice(const_iterator __position, list&& __x, const_iterator __i) +#else + /** + * @brief Insert element from another %list. * @param __position Iterator referencing the element to insert before. * @param __x Source list. * @param __i Iterator referencing the element to move. @@ -1304,13 +1358,10 @@ * inserts it into the current list before @a __position. */ void -#if __cplusplus >= 201103L - splice(iterator __position, list&& __x, iterator __i) -#else splice(iterator __position, list& __x, iterator __i) #endif { - iterator __j = __i; + iterator __j = __i._M_const_cast(); ++__j; if (__position == __i || __position == __j) return; @@ -1318,17 +1369,46 @@ if (this != &__x) _M_check_equal_allocators(__x); - this->_M_transfer(__position, __i, __j); + this->_M_transfer(__position._M_const_cast(), + __i._M_const_cast(), __j); } #if __cplusplus >= 201103L + /** + * @brief Insert element from another %list. + * @param __position Const_iterator referencing the element to + * insert before. + * @param __x Source list. + * @param __i Const_iterator referencing the element to move. + * + * Removes the element in list @a __x referenced by @a __i and + * inserts it into the current list before @a __position. + */ void - splice(iterator __position, list& __x, iterator __i) + splice(const_iterator __position, list& __x, const_iterator __i) { splice(__position, std::move(__x), __i); } #endif +#if __cplusplus >= 201103L /** * @brief Insert range from another %list. + * @param __position Const_iterator referencing the element to + * insert before. + * @param __x Source list. + * @param __first Const_iterator referencing the start of range in x. + * @param __last Const_iterator referencing the end of range in x. + * + * Removes elements in the range [__first,__last) and inserts them + * before @a __position in constant time. + * + * Undefined if @a __position is in [__first,__last). + */ + void + splice(const_iterator __position, list&& __x, const_iterator __first, + const_iterator __last) +#else + /** + * @brief Insert range from another %list. * @param __position Iterator referencing the element to insert before. * @param __x Source list. * @param __first Iterator referencing the start of range in x. @@ -1340,10 +1420,6 @@ * Undefined if @a __position is in [__first,__last). */ void -#if __cplusplus >= 201103L - splice(iterator __position, list&& __x, iterator __first, - iterator __last) -#else splice(iterator __position, list& __x, iterator __first, iterator __last) #endif @@ -1353,13 +1429,29 @@ if (this != &__x) _M_check_equal_allocators(__x); - this->_M_transfer(__position, __first, __last); + this->_M_transfer(__position._M_const_cast(), + __first._M_const_cast(), + __last._M_const_cast()); } } #if __cplusplus >= 201103L + /** + * @brief Insert range from another %list. + * @param __position Const_iterator referencing the element to + * insert before. + * @param __x Source list. + * @param __first Const_iterator referencing the start of range in x. + * @param __last Const_iterator referencing the end of range in x. + * + * Removes elements in the range [__first,__last) and inserts them + * before @a __position in constant time. + * + * Undefined if @a __position is in [__first,__last). + */ void - splice(iterator __position, list& __x, iterator __first, iterator __last) + splice(const_iterator __position, list& __x, const_iterator __first, + const_iterator __last) { splice(__position, std::move(__x), __first, __last); } #endif Index: include/debug/list =================================================================== --- include/debug/list (revision 200579) +++ include/debug/list (working copy) @@ -403,28 +403,46 @@ insert(const_iterator __position, _Tp&& __x) { return emplace(__position, std::move(__x)); } - void - insert(iterator __p, initializer_list __l) + iterator + insert(const_iterator __p, initializer_list __l) { __glibcxx_check_insert(__p); - _Base::insert(__p.base(), __l); + return iterator(_Base::insert(__p.base(), __l), this); } #endif +#if __cplusplus >= 201103L + iterator + insert(const_iterator __position, size_type __n, const _Tp& __x) + { + __glibcxx_check_insert(__position); + return iterator(_Base::insert(__position.base(), __n, __x), this); + } +#else void insert(iterator __position, size_type __n, const _Tp& __x) { __glibcxx_check_insert(__position); _Base::insert(__position.base(), __n, __x); } +#endif #if __cplusplus >= 201103L template> + iterator + insert(const_iterator __position, _InputIterator __first, + _InputIterator __last) + { + __glibcxx_check_insert_range(__position, __first, __last); + return iterator(_Base::insert(__position.base(), + __gnu_debug::__base(__first), + __gnu_debug::__base(__last)), + this); + } #else template -#endif - void + void insert(iterator __position, _InputIterator __first, _InputIterator __last) { @@ -432,6 +450,7 @@ _Base::insert(__position.base(), __gnu_debug::__base(__first), __gnu_debug::__base(__last)); } +#endif private: _Base_iterator @@ -496,7 +515,7 @@ // 23.2.2.4 list operations: void #if __cplusplus >= 201103L - splice(iterator __position, list&& __x) + splice(const_iterator __position, list&& __x) #else splice(iterator __position, list& __x) #endif @@ -510,13 +529,13 @@ #if __cplusplus >= 201103L void - splice(iterator __position, list& __x) + splice(const_iterator __position, list& __x) { splice(__position, std::move(__x)); } #endif void #if __cplusplus >= 201103L - splice(iterator __position, list&& __x, iterator __i) + splice(const_iterator __position, list&& __x, const_iterator __i) #else splice(iterator __position, list& __x, iterator __i) #endif @@ -542,14 +561,14 @@ #if __cplusplus >= 201103L void - splice(iterator __position, list& __x, iterator __i) + splice(const_iterator __position, list& __x, const_iterator __i) { splice(__position, std::move(__x), __i); } #endif void #if __cplusplus >= 201103L - splice(iterator __position, list&& __x, iterator __first, - iterator __last) + splice(const_iterator __position, list&& __x, const_iterator __first, + const_iterator __last) #else splice(iterator __position, list& __x, iterator __first, iterator __last) @@ -565,14 +584,14 @@ // We used to perform the splice_alloc check: not anymore, redundant // after implementing the relevant bits of N1599. - for (_Base_iterator __tmp = __first.base(); + for (_Base_const_iterator __tmp = __first.base(); __tmp != __last.base(); ++__tmp) { _GLIBCXX_DEBUG_VERIFY(__tmp != _Base::end(), _M_message(__gnu_debug::__msg_valid_range) ._M_iterator(__first, "first") ._M_iterator(__last, "last")); - _GLIBCXX_DEBUG_VERIFY(&__x != this || __tmp != __position, + _GLIBCXX_DEBUG_VERIFY(&__x != this || __tmp != __position.base(), _M_message(__gnu_debug::__msg_splice_overlap) ._M_iterator(__tmp, "position") ._M_iterator(__first, "first") @@ -588,7 +607,8 @@ #if __cplusplus >= 201103L void - splice(iterator __position, list& __x, iterator __first, iterator __last) + splice(const_iterator __position, list& __x, + const_iterator __first, const_iterator __last) { splice(__position, std::move(__x), __first, __last); } #endif Index: include/ext/vstring.h =================================================================== --- include/ext/vstring.h (revision 200579) +++ include/ext/vstring.h (working copy) @@ -916,8 +916,33 @@ { return this->assign(__l.begin(), __l.end()); } #endif // C++11 +#if __cplusplus >= 201103L /** * @brief Insert multiple characters. + * @param __p Const_iterator referencing location in string to + * insert at. + * @param __n Number of characters to insert + * @param __c The character to insert. + * @return Iterator referencing the first inserted char. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Inserts @a __n copies of character @a __c starting at the + * position referenced by iterator @a __p. If adding + * characters causes the length to exceed max_size(), + * length_error is thrown. The value of the string doesn't + * change if an error is thrown. + */ + iterator + insert(const_iterator __p, size_type __n, _CharT __c) + { + _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend()); + const size_type __pos = __p - _M_ibegin(); + this->replace(__p, __p, __n, __c); + return iterator(this->_M_data() + __pos); + } +#else + /** + * @brief Insert multiple characters. * @param __p Iterator referencing location in string to insert at. * @param __n Number of characters to insert * @param __c The character to insert. @@ -932,12 +957,16 @@ void insert(iterator __p, size_type __n, _CharT __c) { this->replace(__p, __p, __n, __c); } +#endif +#if __cplusplus >= 201103L /** * @brief Insert a range of characters. - * @param __p Iterator referencing location in string to insert at. + * @param __p Const_iterator referencing location in string to + * insert at. * @param __beg Start of range. * @param __end End of range. + * @return Iterator referencing the first inserted char. * @throw std::length_error If new length exceeds @c max_size(). * * Inserts characters in range [beg,end). If adding characters @@ -945,26 +974,47 @@ * thrown. The value of the string doesn't change if an error * is thrown. */ -#if __cplusplus >= 201103L template> + iterator + insert(const_iterator __p, _InputIterator __beg, _InputIterator __end) + { + _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend()); + const size_type __pos = __p - _M_ibegin(); + this->replace(__p, __p, __beg, __end); + return iterator(this->_M_data() + __pos); + } #else + /** + * @brief Insert a range of characters. + * @param __p Iterator referencing location in string to insert at. + * @param __beg Start of range. + * @param __end End of range. + * @throw std::length_error If new length exceeds @c max_size(). + * + * Inserts characters in range [beg,end). If adding characters + * causes the length to exceed max_size(), length_error is + * thrown. The value of the string doesn't change if an error + * is thrown. + */ template -#endif void insert(iterator __p, _InputIterator __beg, _InputIterator __end) { this->replace(__p, __p, __beg, __end); } +#endif #if __cplusplus >= 201103L /** * @brief Insert an initializer_list of characters. - * @param __p Iterator referencing location in string to insert at. + * @param __p Const_iterator referencing location in string to + * insert at. * @param __l The initializer_list of characters to insert. + * @return Iterator referencing the first inserted char. * @throw std::length_error If new length exceeds @c max_size(). */ - void - insert(iterator __p, std::initializer_list<_CharT> __l) - { this->insert(__p, __l.begin(), __l.end()); } + iterator + insert(const_iterator __p, std::initializer_list<_CharT> __l) + { return this->insert(__p, __l.begin(), __l.end()); } #endif // C++11 /** @@ -1421,7 +1471,7 @@ template> __versa_string& - replace(iterator __i1, iterator __i2, + replace(const_iterator __i1, const_iterator __i2, _InputIterator __k1, _InputIterator __k2) { _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 @@ -1447,7 +1497,13 @@ // Specializations for the common case of pointer and iterator: // useful to avoid the overhead of temporary buffering in _M_replace. __versa_string& - replace(iterator __i1, iterator __i2, _CharT* __k1, _CharT* __k2) +#if __cplusplus >= 201103L + replace(const_iterator __i1, const_iterator __i2, + _CharT* __k1, _CharT* __k2) +#else + replace(iterator __i1, iterator __i2, + _CharT* __k1, _CharT* __k2) +#endif { _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 && __i2 <= _M_iend()); @@ -1457,8 +1513,13 @@ } __versa_string& +#if __cplusplus >= 201103L + replace(const_iterator __i1, const_iterator __i2, + const _CharT* __k1, const _CharT* __k2) +#else replace(iterator __i1, iterator __i2, const _CharT* __k1, const _CharT* __k2) +#endif { _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 && __i2 <= _M_iend()); @@ -1468,7 +1529,13 @@ } __versa_string& - replace(iterator __i1, iterator __i2, iterator __k1, iterator __k2) +#if __cplusplus >= 201103L + replace(const_iterator __i1, const_iterator __i2, + iterator __k1, iterator __k2) +#else + replace(iterator __i1, iterator __i2, + iterator __k1, iterator __k2) +#endif { _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 && __i2 <= _M_iend()); @@ -1478,8 +1545,13 @@ } __versa_string& +#if __cplusplus >= 201103L + replace(const_iterator __i1, const_iterator __i2, + const_iterator __k1, const_iterator __k2) +#else replace(iterator __i1, iterator __i2, const_iterator __k1, const_iterator __k2) +#endif { _GLIBCXX_DEBUG_PEDASSERT(_M_ibegin() <= __i1 && __i1 <= __i2 && __i2 <= _M_iend()); @@ -1502,22 +1574,24 @@ * of result exceeds max_size(), length_error is thrown. The * value of the string doesn't change if an error is thrown. */ - __versa_string& replace(iterator __i1, iterator __i2, - std::initializer_list<_CharT> __l) + __versa_string& + replace(const_iterator __i1, const_iterator __i2, + std::initializer_list<_CharT> __l) { return this->replace(__i1, __i2, __l.begin(), __l.end()); } #endif // C++11 private: template __versa_string& - _M_replace_dispatch(iterator __i1, iterator __i2, _Integer __n, - _Integer __val, std::__true_type) + _M_replace_dispatch(const_iterator __i1, const_iterator __i2, + _Integer __n, _Integer __val, std::__true_type) { return _M_replace_aux(__i1 - _M_ibegin(), __i2 - __i1, __n, __val); } template __versa_string& - _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1, - _InputIterator __k2, std::__false_type); + _M_replace_dispatch(const_iterator __i1, const_iterator __i2, + _InputIterator __k1, _InputIterator __k2, + std::__false_type); __versa_string& _M_replace_aux(size_type __pos1, size_type __n1, size_type __n2, Index: include/ext/vstring.tcc =================================================================== --- include/ext/vstring.tcc (revision 200579) +++ include/ext/vstring.tcc (working copy) @@ -81,8 +81,9 @@ template __versa_string<_CharT, _Traits, _Alloc, _Base>& __versa_string<_CharT, _Traits, _Alloc, _Base>:: - _M_replace_dispatch(iterator __i1, iterator __i2, _InputIterator __k1, - _InputIterator __k2, std::__false_type) + _M_replace_dispatch(const_iterator __i1, const_iterator __i2, + _InputIterator __k1, _InputIterator __k2, + std::__false_type) { const __versa_string __s(__k1, __k2); const size_type __n1 = __i2 - __i1; Index: include/profile/list =================================================================== --- include/profile/list (revision 200579) +++ include/profile/list (working copy) @@ -363,27 +363,43 @@ this); } - void - insert(iterator __position, initializer_list __l) + iterator + insert(const_iterator __position, initializer_list __l) { _M_profile_insert(this, __position, size()); - _Base::insert(__position.base(), __l); + return iterator(_Base::insert(__position.base(), __l), this); } #endif +#if __cplusplus >= 201103L + iterator + insert(const_iterator __position, size_type __n, const _Tp& __x) + { + _M_profile_insert(this, __position, size()); + return iterator(_Base::insert(__position.base(), __n, __x), this); + } +#else void insert(iterator __position, size_type __n, const _Tp& __x) { _M_profile_insert(this, __position, size()); _Base::insert(__position.base(), __n, __x); } +#endif #if __cplusplus >= 201103L template> + iterator + insert(const_iterator __position, _InputIterator __first, + _InputIterator __last) + { + _M_profile_insert(this, __position, size()); + return iterator(_Base::insert(__position.base(), __first, __last), + this); + } #else template -#endif void insert(iterator __position, _InputIterator __first, _InputIterator __last) @@ -391,6 +407,7 @@ _M_profile_insert(this, __position, size()); _Base::insert(__position.base(), __first, __last); } +#endif iterator #if __cplusplus >= 201103L @@ -423,7 +440,7 @@ // 23.2.2.4 list operations: void #if __cplusplus >= 201103L - splice(iterator __position, list&& __x) + splice(const_iterator __position, list&& __x) #else splice(iterator __position, list& __x) #endif @@ -431,19 +448,17 @@ #if __cplusplus >= 201103L void - splice(iterator __position, list& __x) + splice(const_iterator __position, list& __x) { this->splice(__position, std::move(__x)); } -#endif -#if __cplusplus >= 201103L void - splice(iterator __position, list& __x, iterator __i) + splice(const_iterator __position, list& __x, const_iterator __i) { this->splice(__position, std::move(__x), __i); } #endif void #if __cplusplus >= 201103L - splice(iterator __position, list&& __x, iterator __i) + splice(const_iterator __position, list&& __x, const_iterator __i) #else splice(iterator __position, list& __x, iterator __i) #endif @@ -458,8 +473,8 @@ void #if __cplusplus >= 201103L - splice(iterator __position, list&& __x, iterator __first, - iterator __last) + splice(const_iterator __position, list&& __x, const_iterator __first, + const_iterator __last) #else splice(iterator __position, list& __x, iterator __first, iterator __last) @@ -474,7 +489,8 @@ #if __cplusplus >= 201103L void - splice(iterator __position, list& __x, iterator __first, iterator __last) + splice(const_iterator __position, list& __x, + const_iterator __first, const_iterator __last) { this->splice(__position, std::move(__x), __first, __last); } #endif Index: testsuite/23_containers/list/modifiers/insert/const_iterator.cc =================================================================== --- testsuite/23_containers/list/modifiers/insert/const_iterator.cc (revision 200579) +++ testsuite/23_containers/list/modifiers/insert/const_iterator.cc (working copy) @@ -24,6 +24,9 @@ { std::list l1; int n = 0; - l1.insert(l1.cbegin(), n); - l1.insert(l1.cbegin(), 1); + std::list::iterator it = l1.insert(l1.cbegin(), n); + it = l1.insert(l1.cbegin(), 1); + it = l1.insert(l1.cbegin(), {2, 3}); + it = l1.insert(l1.cbegin(), 1, 4); + it = l1.insert(l1.cbegin(), l1.begin(), l1.end()); } Index: testsuite/23_containers/list/operations/splice/const_iterator.cc =================================================================== --- testsuite/23_containers/list/operations/splice/const_iterator.cc (revision 0) +++ testsuite/23_containers/list/operations/splice/const_iterator.cc (working copy) @@ -0,0 +1,32 @@ +// { dg-options "-std=gnu++11" } +// { dg-do compile } + +// Copyright (C) 2013 Free Software Foundation, Inc. +// +// This file is part of the GNU ISO C++ Library. This library is free +// software; you can redistribute it and/or modify it under the +// terms of the GNU General Public License as published by the +// Free Software Foundation; either version 3, or (at your option) +// any later version. + +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License along +// with this library; see the file COPYING3. If not see +// . + +#include + +void test01() +{ + std::list l1{0, 1}, l2{2, 3}; + l1.splice(l1.cbegin(), l2); + l2.splice(l2.cbegin(), std::move(l1)); + l1.splice(l1.cbegin(), l2, l2.cbegin()); + l2.splice(l2.cbegin(), std::move(l1), l1.cbegin()); + l1.splice(l1.cbegin(), l2, l2.cbegin(), l2.cend()); + l2.splice(l2.cbegin(), std::move(l1), l1.cbegin(), l1.cend()); +} Index: testsuite/23_containers/list/requirements/dr438/assign_neg.cc =================================================================== --- testsuite/23_containers/list/requirements/dr438/assign_neg.cc (revision 200579) +++ testsuite/23_containers/list/requirements/dr438/assign_neg.cc (working copy) @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1559 } +// { dg-error "no matching" "" { target *-*-* } 1651 } #include Index: testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc =================================================================== --- testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc (revision 200579) +++ testsuite/23_containers/list/requirements/dr438/constructor_1_neg.cc (working copy) @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1511 } +// { dg-error "no matching" "" { target *-*-* } 1603 } #include Index: testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc =================================================================== --- testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc (revision 200579) +++ testsuite/23_containers/list/requirements/dr438/constructor_2_neg.cc (working copy) @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1511 } +// { dg-error "no matching" "" { target *-*-* } 1603 } #include #include Index: testsuite/23_containers/list/requirements/dr438/insert_neg.cc =================================================================== --- testsuite/23_containers/list/requirements/dr438/insert_neg.cc (revision 200579) +++ testsuite/23_containers/list/requirements/dr438/insert_neg.cc (working copy) @@ -18,7 +18,7 @@ // . // { dg-do compile } -// { dg-error "no matching" "" { target *-*-* } 1511 } +// { dg-error "no matching" "" { target *-*-* } 1603 } #include Index: testsuite/ext/vstring/modifiers/insert/char/const_iterator.cc =================================================================== --- testsuite/ext/vstring/modifiers/insert/char/const_iterator.cc (revision 200579) +++ testsuite/ext/vstring/modifiers/insert/char/const_iterator.cc (working copy) @@ -23,5 +23,8 @@ void test01() { __gnu_cxx::__vstring vs1; - vs1.insert(vs1.cbegin(), '1'); + __gnu_cxx::__vstring::iterator it = vs1.insert(vs1.cbegin(), '1'); + it = vs1.insert(vs1.cbegin(), 1, '2'); + it = vs1.insert(vs1.cbegin(), {'3', '4'}); + it = vs1.insert(vs1.cbegin(), vs1.begin(), vs1.end()); } Index: testsuite/ext/vstring/modifiers/insert/wchar_t/const_iterator.cc =================================================================== --- testsuite/ext/vstring/modifiers/insert/wchar_t/const_iterator.cc (revision 200579) +++ testsuite/ext/vstring/modifiers/insert/wchar_t/const_iterator.cc (working copy) @@ -23,5 +23,8 @@ void test01() { __gnu_cxx::__wvstring wvs1; - wvs1.insert(wvs1.cbegin(), L'1'); + __gnu_cxx::__wvstring::iterator it = wvs1.insert(wvs1.cbegin(), L'1'); + it = wvs1.insert(wvs1.cbegin(), 1, L'2'); + it = wvs1.insert(wvs1.cbegin(), {L'3', L'4'}); + it = wvs1.insert(wvs1.cbegin(), wvs1.begin(), wvs1.end()); } Index: testsuite/ext/vstring/modifiers/replace/char/const_iterator.cc =================================================================== --- testsuite/ext/vstring/modifiers/replace/char/const_iterator.cc (revision 200579) +++ testsuite/ext/vstring/modifiers/replace/char/const_iterator.cc (working copy) @@ -27,4 +27,6 @@ vs1.replace(vs1.cbegin(), vs1.cend(), "1", 1); vs1.replace(vs1.cbegin(), vs1.cend(), "2"); vs1.replace(vs1.cbegin(), vs1.cend(), 1, '3'); + vs1.replace(vs1.cbegin(), vs1.cend(), vs1.begin(), vs1.end()); + vs1.replace(vs1.cbegin(), vs1.cend(), {'4', '5'}); } Index: testsuite/ext/vstring/modifiers/replace/wchar_t/const_iterator.cc =================================================================== --- testsuite/ext/vstring/modifiers/replace/wchar_t/const_iterator.cc (revision 200579) +++ testsuite/ext/vstring/modifiers/replace/wchar_t/const_iterator.cc (working copy) @@ -27,4 +27,6 @@ wvs1.replace(wvs1.cbegin(), wvs1.cend(), L"1", 1); wvs1.replace(wvs1.cbegin(), wvs1.cend(), L"2"); wvs1.replace(wvs1.cbegin(), wvs1.cend(), 1, L'3'); + wvs1.replace(wvs1.cbegin(), wvs1.cend(), wvs1.begin(), wvs1.end()); + wvs1.replace(wvs1.cbegin(), wvs1.cend(), {'4', '5'}); }