From patchwork Sun Apr 1 17:12:45 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 149962 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 F1C53B6EE7 for ; Mon, 2 Apr 2012 03:13:16 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1333905198; h=Comment: DomainKey-Signature:Received:Received:Received:Received: MIME-Version:Received:Received:Date:Message-ID:Subject:From:To: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=NFpIIr4 2wcn8mRLYH9vO7Fj7Wg8=; b=FfWau1g83cZmB/HGFZvy0AX7ysmA4+TdNfDQZeb ph4gL+EH698J2IWfozDw/PwnDJI2q6H7eilO+2o9xxcFS+10gAVbygcQzoX6SKvj 3upFRd11csWXmCc6rksGNxUzCIaLYzgYmL1N0d8UxITLZQMy9TRu9EA/xVFyicAS Tv6Y= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:MIME-Version:Received:Received:Date:Message-ID:Subject:From:To:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=JCg9xQRBul7fUrONHh9KsCdhx5WeHzcDi4OJ/MHgy8OFaDOXimDmq4nJW4QGMV jogztsB6725hEXodHKSBl/id3+2D5XzwBLCR2W6qmDPHhGKWqqFl8fT11q0wI4Y9 VjncsuApzP9wnmR2icOHxwdctRo25HpXHAZRozZHeP688=; Received: (qmail 17644 invoked by alias); 1 Apr 2012 17:13:04 -0000 Received: (qmail 17617 invoked by uid 22791); 1 Apr 2012 17:13:00 -0000 X-SWARE-Spam-Status: No, hits=-4.2 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-lpp01m010-f47.google.com (HELO mail-lpp01m010-f47.google.com) (209.85.215.47) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 01 Apr 2012 17:12:47 +0000 Received: by lagw12 with SMTP id w12so2585774lag.20 for ; Sun, 01 Apr 2012 10:12:45 -0700 (PDT) MIME-Version: 1.0 Received: by 10.152.115.38 with SMTP id jl6mr6271553lab.24.1333300365753; Sun, 01 Apr 2012 10:12:45 -0700 (PDT) Received: by 10.112.85.98 with HTTP; Sun, 1 Apr 2012 10:12:45 -0700 (PDT) Date: Sun, 1 Apr 2012 18:12:45 +0100 Message-ID: Subject: [v3] Fix std::function to cope with volatile-qualified pointers to members From: Jonathan Wakely To: "libstdc++" , gcc-patches 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 (N.B. not pointers to volatile member functions!) * include/std/functional (__callable_functor): Overload for volatile-qualified pointers. * testsuite/20_util/function/10.cc: New. Tested x86_64-linux, committed to trunk. I think the problem is obscure enough that the fix doesn't need to go on older branches. commit fb1df22f59d2ac8f60b9ec1b90f5ce062dbfdaab Author: Jonathan Wakely Date: Tue Mar 27 22:18:00 2012 +0100 * include/std/functional (__callable_functor): Overload for volatile-qualified pointers. * testsuite/20_util/function/10.cc: New. diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index 14785dd..980c6ab 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -1716,6 +1716,16 @@ _GLIBCXX_HAS_NESTED_TYPE(result_type) __callable_functor(_Member _Class::* const &__p) { return std::mem_fn(__p); } + template + inline _Mem_fn<_Member _Class::*> + __callable_functor(_Member _Class::* volatile &__p) + { return std::mem_fn(__p); } + + template + inline _Mem_fn<_Member _Class::*> + __callable_functor(_Member _Class::* const volatile &__p) + { return std::mem_fn(__p); } + template class function; diff --git a/libstdc++-v3/testsuite/20_util/function/10.cc b/libstdc++-v3/testsuite/20_util/function/10.cc new file mode 100644 index 0000000..3776f39 --- /dev/null +++ b/libstdc++-v3/testsuite/20_util/function/10.cc @@ -0,0 +1,37 @@ +// { dg-options "-std=gnu++0x" } +// { dg-do compile } +// +// Copyright (C) 2012 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 +// . + +// 20.8.11 polymorphic function object wrapper + +#include + +struct X { void f() { } }; + +void (X::*p)() = &X::f; +void (X::* volatile& vp)() = p; + +typedef std::function function_type; + +void test01() +{ + function_type f( vp ); + function_type f2( std::ref(vp) ); + function_type f3( std::cref(vp) ); +}