220 4650 <3100c7f2-43d6-4f28-a7ec-54a2f6e94d21@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Jonathan Wakely <cxx@kayari.org>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Extension to std::function to allow binding a
 object to its member function
Date: Tue, 28 May 2013 05:09:06 -0700 (PDT)
Lines: 96
Approved: news@gmane.org
Message-ID: <3100c7f2-43d6-4f28-a7ec-54a2f6e94d21@isocpp.org>
References: <6472bf39-fa71-4947-ae99-df011d5435e2@isocpp.org>
 <CAFk2RUbya71TN=oPShj+fatACEsnVRnv59+Sa8vZDAWEca6ibQ@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_3915_5041585.1369742946289"
X-Trace: ger.gmane.org 1369742952 25110 80.91.229.3 (28 May 2013 12:09:12 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 28 May 2013 12:09:12 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCMONUNYS4IRBY54SKGQKGQE2RKWOKI@isocpp.org Tue May 28 14:09:10 2013
Return-path: <std-proposals+bncBCMONUNYS4IRBY54SKGQKGQE2RKWOKI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yh0-f69.google.com ([209.85.213.69])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCMONUNYS4IRBY54SKGQKGQE2RKWOKI@isocpp.org>)
	id 1UhIiC-0003FZ-GO
	for gclcip-std-proposals@m.gmane.org; Tue, 28 May 2013 14:09:08 +0200
Original-Received: by mail-yh0-f69.google.com with SMTP id i72sf6080539yha.0
        for <gclcip-std-proposals@m.gmane.org>; Tue, 28 May 2013 05:09:07 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=x-beenthere:date:from:to:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-google-group-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=dyvOpHdp1LHJ+PAn7FaoviGlkD42d0gz2WSfBz53HLM=;
        b=kZmbCLFdOkDmiYxDFp/+4aK1U+gVidtlK3AkytUSK86cN6/bS1Gfd9Fot9S796nIA5
         yFRWxFPGseXRnJBNex+7YCV8pfYDBeUyypLZSFhYxaz+CvCll2F0mKYSA2G3FmgYrPj/
         TWR/SokJ5Lh/iWU5PwVTDTcp+kCn1vQvutlIi8ffBx5jNg0ZSzcHRbNHcWUVLIpruwRb
         qaHKbdZe3ivRMHGWkJX3EPUkMvPXShu7ME09h7pVHYOsr1JWtE6mpCQKsXoJatZq1rOv
         7W4ga3dlSN09PCMkOms0MjsjWH3BBOG5YEeKS6UAtG1AiW0oIsXj2VVlB7vBd4yRaNhq
         xRXg==
X-Received: by 10.224.36.66 with SMTP id s2mr17405237qad.6.1369742947637;
        Tue, 28 May 2013 05:09:07 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.98.99 with SMTP id eh3ls688924qeb.15.gmail; Tue, 28 May
 2013 05:09:06 -0700 (PDT)
X-Received: by 10.49.95.3 with SMTP id dg3mr201943qeb.41.1369742946611;
        Tue, 28 May 2013 05:09:06 -0700 (PDT)
In-Reply-To: <CAFk2RUbya71TN=oPShj+fatACEsnVRnv59+Sa8vZDAWEca6ibQ@mail.gmail.com>
X-Original-Sender: cxx@kayari.org
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post?hl=en>,
 <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?hl=en&topic=25838>,
 <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:4650
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/4650>

------=_Part_3915_5041585.1369742946289
Content-Type: text/plain; charset=ISO-8859-1



On Monday, May 27, 2013 2:32:17 PM UTC+1, Ville Voutilainen wrote:
>
>
>> First of all, the standard function + bind will not allow to do this. 
>>
>
> I don't quite grasp what you think std::function and std::bind don't allow.
>

This proposal would allow you to refer to an overloaded member function 
without an explicit cast or other means to specify the desired overload, 
e.g.

struct A
{
  void f();
  int f(int);
} a;

std::function<void()> f1(&a, &A::f);  // chooses first overload

That's quite convenient.  However it isn't as flexible: std::function 
allows implicit conversions on the return type and arguments, but using 
this proposal you'd have to be precise, e.g.

std::function<void(int)> f2(&a, &A::f);  // error
std::function<short(short)> f3(&a, &A::f);  // error

Both of those will work using std::bind (and a cast to select the 
overload), but with this proposal you'd have to do:

std::function<void(int)> f2 = std::function<int(int)>(&a, &A::f);
std::function<short(short)> f3 = std::function<int(int)>(&a, &A::f);

 

-- 

--- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



------=_Part_3915_5041585.1369742946289
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br><br>On Monday, May 27, 2013 2:32:17 PM UTC+1, Ville Voutilainen wrote:<=
blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bord=
er-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><div clas=
s=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .=
8ex;border-left:1px #ccc solid;padding-left:1ex"><p><br>First of all, the s=
tandard function + bind will not allow to do this. <br></p></blockquote><di=
v><br></div><div>I don't quite grasp what you think std::function and std::=
bind don't allow.<br></div></div></div></div></blockquote><div><br>This pro=
posal would allow you to refer to an overloaded member function without an =
explicit cast or other means to specify the desired overload, e.g.<br><br>s=
truct A<br>{<br>&nbsp; void f();<br>&nbsp; int f(int);<br>} a;<br><br>std::=
function&lt;void()&gt; f1(&amp;a, &amp;A::f);&nbsp; // chooses first overlo=
ad<br><br>That's quite convenient.&nbsp; However it isn't as flexible: std:=
:function allows implicit conversions on the return type and arguments, but=
 using this proposal you'd have to be precise, e.g.<br><br>std::function&lt=
;void(int)&gt; f2(&amp;a, &amp;A::f);&nbsp; // error<br>std::function&lt;sh=
ort(short)&gt; f3(&amp;a, &amp;A::f);&nbsp; // error<br><br>Both of those w=
ill work using std::bind (and a cast to select the overload), but with this=
 proposal you'd have to do:<br><br>std::function&lt;void(int)&gt; f2 =3D st=
d::function&lt;int(int)&gt;(&amp;a, &amp;A::f);<br>std::function&lt;short(s=
hort)&gt; f3 =3D std::function&lt;int(int)&gt;(&amp;a, &amp;A::f);<br><br>&=
nbsp;<br></div>

<p></p>

-- <br />
&nbsp;<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

------=_Part_3915_5041585.1369742946289--

.
