From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29987 invoked by alias); 15 Oct 2009 01:16:04 -0000 Received: (qmail 29968 invoked by uid 22791); 15 Oct 2009 01:16:03 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from vsmtp12.tin.it (HELO vsmtp12.tin.it) (212.216.176.206) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 15 Oct 2009 01:15:59 +0000 Received: from [192.168.0.4] (79.45.216.40) by vsmtp12.tin.it (8.5.113) id 4AA62DD8026CF58A; Thu, 15 Oct 2009 03:15:56 +0200 Message-ID: <4AD677CC.7030205@oracle.com> Date: Thu, 15 Oct 2009 02:23:00 -0000 From: Paolo Carlini User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: "gcc-patches@gcc.gnu.org" CC: libstdc++ Subject: [v3] Tweak basic_string overloads on initializer_list... Content-Type: multipart/mixed; boundary="------------010402050700020501040202" X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2009-10/txt/msg00952.txt.bz2 This is a multi-part message in MIME format. --------------010402050700020501040202 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-length: 109 ... to avoid unnecessary instantiations in the library. Tested x86_64-linux, committed to mainline. Paolo. --------------010402050700020501040202 Content-Type: text/plain; name="CL_il" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="CL_il" Content-length: 476 2009-10-14 Paolo Carlini * include/bits/basic_string.h (operator+=(initializer_list<>), append(initializer_list<>)): Forward to the append overload taking a const CharT* pointer and a size, thus avoiding instantiating unnecessarily in the built library the overload taking a pair of iterators. (operator=(initializer_list<>), assign(initializer_list<>)): Likewise for assign. (insert(iterator, initializer_list<>): Likewise for insert. --------------010402050700020501040202 Content-Type: text/plain; name="patch_il" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="patch_il" Content-length: 1583 Index: include/bits/basic_string.h =================================================================== --- include/bits/basic_string.h (revision 152771) +++ include/bits/basic_string.h (working copy) @@ -540,7 +540,7 @@ basic_string& operator=(initializer_list<_CharT> __l) { - this->assign (__l.begin(), __l.end()); + this->assign(__l.begin(), __l.size()); return *this; } #endif // __GXX_EXPERIMENTAL_CXX0X__ @@ -860,7 +860,7 @@ */ basic_string& operator+=(initializer_list<_CharT> __l) - { return this->append(__l.begin(), __l.end()); } + { return this->append(__l.begin(), __l.size()); } #endif // __GXX_EXPERIMENTAL_CXX0X__ /** @@ -926,7 +926,7 @@ */ basic_string& append(initializer_list<_CharT> __l) - { return this->append(__l.begin(), __l.end()); } + { return this->append(__l.begin(), __l.size()); } #endif // __GXX_EXPERIMENTAL_CXX0X__ /** @@ -1045,7 +1045,7 @@ */ basic_string& assign(initializer_list<_CharT> __l) - { return this->assign(__l.begin(), __l.end()); } + { return this->assign(__l.begin(), __l.size()); } #endif // __GXX_EXPERIMENTAL_CXX0X__ /** @@ -1089,7 +1089,10 @@ */ void insert(iterator __p, initializer_list<_CharT> __l) - { this->insert(__p, __l.begin(), __l.end()); } + { + _GLIBCXX_DEBUG_PEDASSERT(__p >= _M_ibegin() && __p <= _M_iend()); + this->insert(__p - _M_ibegin(), __l.begin(), __l.size()); + } #endif // __GXX_EXPERIMENTAL_CXX0X__ /** --------------010402050700020501040202--