From patchwork Wed Aug 11 16:59:45 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Carlini X-Patchwork-Id: 61488 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]) by ozlabs.org (Postfix) with SMTP id 51851B70D8 for ; Thu, 12 Aug 2010 03:00:02 +1000 (EST) Received: (qmail 3822 invoked by alias); 11 Aug 2010 16:59:57 -0000 Received: (qmail 3803 invoked by uid 22791); 11 Aug 2010 16:59:56 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from vsmtp2.tin.it (HELO vsmtp2.tin.it) (212.216.176.222) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 11 Aug 2010 16:59:51 +0000 Received: from [192.168.0.4] (79.52.212.149) by vsmtp2.tin.it (8.0.022) id 49F5BE422666DB95; Wed, 11 Aug 2010 18:59:48 +0200 Message-ID: <4C62D701.5010506@oracle.com> Date: Wed, 11 Aug 2010 18:59:45 +0200 From: Paolo Carlini User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.11) Gecko/20100714 SUSE/3.0.6 Thunderbird/3.0.6 MIME-Version: 1.0 To: Gcc Patch List CC: libstdc++ Subject: Re: [v3] Update std::forward to N3092 References: <4C5A69D6.1060904@oracle.com> In-Reply-To: <4C5A69D6.1060904@oracle.com> X-IsSubscribed: yes 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 ... apparently US 90 is actually getting support, thus to avoid ping - pongs between different versions, I'm reinstating the N2835 version of std::forward which we have in 4_5-branch too (with common_type replacing of course identity, because the latter is gone). Tested x86_64-linux. Paolo. /////////////////////// 2010-08-11 Paolo Carlini * include/bits/move.h (forward): Reinstate the N2835 version. Index: include/bits/move.h =================================================================== --- include/bits/move.h (revision 163100) +++ include/bits/move.h (working copy) @@ -51,17 +51,30 @@ _GLIBCXX_BEGIN_NAMESPACE(std) - /// forward - template - inline typename - enable_if<((std::is_convertible< - typename std::remove_reference<_Up>::type*, - typename std::remove_reference<_Tp>::type*>::value) - && (!std::is_lvalue_reference<_Tp>::value - || std::is_lvalue_reference<_Up>::value)), _Tp&&>::type - forward(_Up&& __u) - { return static_cast<_Tp&&>(__u); } + /// forward (as per N2835) + /// Forward lvalues as rvalues. + template + inline typename enable_if::value, _Tp&&>::type + forward(typename std::common_type<_Tp>::type& __t) + { return static_cast<_Tp&&>(__t); } + /// Forward rvalues as rvalues. + template + inline typename enable_if::value, _Tp&&>::type + forward(typename std::common_type<_Tp>::type&& __t) + { return static_cast<_Tp&&>(__t); } + + // Forward lvalues as lvalues. + template + inline typename enable_if::value, _Tp>::type + forward(typename std::common_type<_Tp>::type __t) + { return __t; } + + // Prevent forwarding rvalues as const lvalues. + template + inline typename enable_if::value, _Tp>::type + forward(typename std::remove_reference<_Tp>::type&& __t) = delete; + /** * @brief Move a value. * @ingroup mutating_algorithms