From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 108903 invoked by alias); 20 Dec 2018 21:53:20 -0000 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 Received: (qmail 108882 invoked by uid 89); 20 Dec 2018 21:53:20 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=adapted, HContent-Transfer-Encoding:8bit X-HELO: mail-wm1-f48.google.com Received: from mail-wm1-f48.google.com (HELO mail-wm1-f48.google.com) (209.85.128.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Dec 2018 21:53:18 +0000 Received: by mail-wm1-f48.google.com with SMTP id f81so3788517wmd.4; Thu, 20 Dec 2018 13:53:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=zDelUdyVQylMCxFVrj/6DuS+D18ChPqGoA3WekYNODE=; b=HXXoE+UJgdgdxeyPgqURnbqslNp5tozR6pkxkoG16BeLiY89T+9wTtAu8KO82v2f/O /QD5BHc61lrE4ermwQXLAoUOyqtk87r6OxGM5Wr7VFOvJiV0fQAIJQVFmkg5059LFTCk uZmu/NTW8/Ftt7jnzpWXYLNk0wch6f2jMhaZLf+z4xbRAmDFD+g2OIGrn7QvRkinPV27 WWBwkDTr9EMrQAE8AfmGhg1V0SC5oYAJ2mVWNVFN/Sb2LwWvgqRBUuHQFgVi3M4M3kch 2c1gBskI5Jmu0HpST2G1YmBFdI1wA/7JSwFVk1i9bLa0IVD0kggwbNIgpMB6XBXgUobR Qo+g== Return-Path: Received: from [192.168.0.22] ([91.167.114.199]) by smtp.googlemail.com with ESMTPSA id v133sm8684393wmf.19.2018.12.20.13.53.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 13:53:15 -0800 (PST) Subject: Re: Relax std::move_if_noexcept for std::pair To: Ville Voutilainen Cc: "libstdc++@gcc.gnu.org" , gcc-patches References: <366bf0a3-2daf-d5c5-7a09-f1260c9c405f@gmail.com> From: =?UTF-8?Q?Fran=c3=a7ois_Dumont?= Message-ID: <8c9c47e8-84ac-3af6-9c5a-cfe81dc1df78@gmail.com> Date: Thu, 20 Dec 2018 21:54:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-SW-Source: 2018-12/txt/msg01508.txt.bz2 On 12/20/18 9:04 AM, Ville Voutilainen wrote: > On Thu, 20 Dec 2018 at 08:29, François Dumont wrote: >> Hi >> >> I eventually find out what was the problem with the >> std::move_if_noexcept within associative containers. >> >> The std::pair move default constructor might not move both first >> and second member. If any is not moveable it will just copy it. And then > ..as it should.. > >> the noexcept qualification of the copy constructor will participate in >> the noexcept qualification of the std::pair move constructor. So >> std::move_if_noexcept can eventually decide to not use move because a >> _copy_ constructor not noexcept qualified. > ..and again, as it should. > >> This is why I am partially specializing __move_if_noexcept_cond. As >> there doesn't seem to exist any Standard meta function to find out if >> move will take place I resort using std::is_const as in this case for >> sure the compiler won't call the move constructor. > That seems wrong; just because a type is or is not const has nothing > to do whether > it's nothrow_move_constructible. Indeed, I am not changing that. > > I don't understand what problem this is solving, and how it's not > introducing new problems. > The problem I am trying to solve is shown by the tests I have adapted. Allow more move semantic in associative container where key are stored as const. But if I make counter_type copy constructor noexcept then I also get the move on the pair.second instance, great. I am just surprise to have to make a copy constructor noexcept to have std::move_if_noexcept work as I expect. I think I just need to understand why we need std::move_if_noexcept in unordered containers or even rb_tree. Couldn't we just use std::move ? I don't understand what we are trying to avoid with this noexcept check. François