From patchwork Thu Apr 25 20:11:41 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Fran=C3=A7ois_Dumont?= X-Patchwork-Id: 239591 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 716D02C0118 for ; Fri, 26 Apr 2013 06:11:55 +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:subject:content-type; q= dns; s=default; b=CTJk31A5AEJrEn/B0//wfSfFn3m7lxPEunrefjGkPtgUaP ebvAcZ+d7/yVOuma8yMtox5cKCjGt31q2VRRat3vwEa21P6bHYVcIxwVJF6kSNrr ur6AfJZeAKGStnmnzPaIpXTVKzXfYvzdOfSyXi78PyS3+7dM2k0SoZ+I9JTGM= 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:subject:content-type; s= default; bh=rYZd9k23pf1RAeM4Frzq7Per6rw=; b=kXSOFzymwdOcWeGz6bEk 1MxyvBhuqpXJpiPFF2/LBACRdeDTMgpCMNWpLSdHjMqBApSfSrTjTObSsCSKxZ8U c0Nj9DVsy72jaY4d6WiEq2bA3omdAlj3iAh2d7VI438uPzxuYWxJHn5kjrMDt4ef MN8kvXp148wCyZ3Vhp+H+ps= Received: (qmail 10713 invoked by alias); 25 Apr 2013 20:11:49 -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 10694 invoked by uid 89); 25 Apr 2013 20:11:48 -0000 X-Spam-SWARE-Status: No, score=-2.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE, SPF_PASS autolearn=ham version=3.3.1 X-Spam-User: qpsmtpd, 2 recipients Received: from mail-we0-f181.google.com (HELO mail-we0-f181.google.com) (74.125.82.181) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 25 Apr 2013 20:11:46 +0000 Received: by mail-we0-f181.google.com with SMTP id m1so2960738wea.26 for ; Thu, 25 Apr 2013 13:11:44 -0700 (PDT) X-Received: by 10.180.182.110 with SMTP id ed14mr66605wic.6.1366920704132; Thu, 25 Apr 2013 13:11:44 -0700 (PDT) Received: from localhost.localdomain (arf62-1-82-237-250-248.fbx.proxad.net. [82.237.250.248]) by mx.google.com with ESMTPSA id fp2sm40737051wib.7.2013.04.25.13.11.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 25 Apr 2013 13:11:42 -0700 (PDT) Message-ID: <51798DFD.508@gmail.com> Date: Thu, 25 Apr 2013 22:11:41 +0200 From: =?ISO-8859-1?Q?Fran=E7ois_Dumont?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120829 Thunderbird/15.0 MIME-Version: 1.0 To: "libstdc++@gcc.gnu.org" , gcc-patches Subject: insert move iterator patch X-Virus-Found: No Hi Here is a patch to use move semantic when inserting a move_iterator range into the unordered containers. 2013-04-25 François Dumont * include/bits/hashtable_policy.h (_Insert_base<>::insert<_It>(_It, _It)): Enable move semantic. * testsuite/23_containers/unordered_set/insert/move_range.cc: New. Tested under Linux x86_64. Ok to commit ? Maybe in 4.8 branch too ? François Index: include/bits/hashtable_policy.h =================================================================== --- include/bits/hashtable_policy.h (revision 198319) +++ include/bits/hashtable_policy.h (working copy) @@ -665,7 +665,7 @@ __h._M_rehash(__do_rehash.second, __saved_state); for (; __first != __last; ++__first) - this->insert(*__first); + __h._M_insert(*__first, __unique_keys()); } /** Index: testsuite/23_containers/unordered_set/insert/move_range.cc =================================================================== --- testsuite/23_containers/unordered_set/insert/move_range.cc (revision 0) +++ testsuite/23_containers/unordered_set/insert/move_range.cc (revision 0) @@ -0,0 +1,51 @@ +// { dg-options "-std=c++11" } + +// 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 +// . + +// range insert using move iterator + +#include +#include +#include +#include +#include + +bool test __attribute__((unused)) = true; + +void test01() +{ + using namespace __gnu_test; + + std::vector ref = { 0, 1, 2, 3, 4, 5 }; + typedef std::unordered_set Set; + Set s; + + counter_type::reset(); + + s.insert(std::make_move_iterator(ref.begin()), + std::make_move_iterator(ref.end())); + + VERIFY( s.size() == ref.size() ); + VERIFY( counter_type::move_count == ref.size() ); +} + +int main() +{ + test01(); + return 0; +}