220 20405 <f7265d31-566c-4a00-8820-f2ac7fda7002@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: german.diago@hubblehome.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Usability improvement: Unambiguously resolve
 overloaded functions when passed as function parameters
Date: Thu, 10 Sep 2015 20:29:07 -0700 (PDT)
Lines: 136
Approved: news@gmane.org
Message-ID: <f7265d31-566c-4a00-8820-f2ac7fda7002@isocpp.org>
References: <a6df5848-0cdc-46eb-be42-a7e29481853f@isocpp.org>
 <mss2qp$ful$1@ger.gmane.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_472_322957566.1441942147695"
X-Trace: ger.gmane.org 1441942156 26271 80.91.229.3 (11 Sep 2015 03:29:16 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 11 Sep 2015 03:29:16 +0000 (UTC)
Cc: mwoehlke.floss@gmail.com
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDKJVOEEVYNRBBEVZGXQKGQEMCD5YOY@isocpp.org Fri Sep 11 05:29:15 2015
Return-path: <std-proposals+bncBDKJVOEEVYNRBBEVZGXQKGQEMCD5YOY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oi0-f72.google.com ([209.85.218.72])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDKJVOEEVYNRBBEVZGXQKGQEMCD5YOY@isocpp.org>)
	id 1ZaF1S-0002Ux-7X
	for gclcip-std-proposals@m.gmane.org; Fri, 11 Sep 2015 05:29:10 +0200
Original-Received: by oiww128 with SMTP id w128sf96046467oiw.0
        for <gclcip-std-proposals@m.gmane.org>; Thu, 10 Sep 2015 20:29:09 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to
         :references:subject:mime-version:content-type:x-original-sender
         :reply-to:precedence:mailing-list:list-id:x-spam-checked-in-group
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=iiLDK/ek3GupeE3hSQcxIvhX76EvCPeWD/kpiJyIBsM=;
        b=dtbkLWLkP9d2+2i59Mi+uKpJ+J83AlDeZNIrl7KFMusjRsOsY+SIczlqTBdfWKv0ZY
         dkoLXFeAUyUAPPOPJwRA4aOUnyPYnMUHqHL16OAGgSI1EmblOZ7wD5S7/HViK+6VHhOr
         TTs16X/3N2kOniA5l3ErprsED7oprllbef2R3+gomkZC7F0V1ibb6hUf55bdX45lpX5Z
         2m75KRc7qZ8ozIotxD68KbJev6k+ataCsutS3fJVeeEJdZYmuudv2TlQuINue4RVA7pG
         lXqVAYQhXreQu0bgNBoyhySAwgDjJhiGNZaePekqpHcs8f5YUHN51hxn7dyr0uW/8gJE
         jA1g==
X-Gm-Message-State: ALoCoQkYdEf2rL+vatLRBOsw/zk08oz+P6cqy+3/WKlTZTc3JwmlbMS13LrtQmjMwBYzucHaLz9q
X-Received: by 10.182.128.101 with SMTP id nn5mr40091961obb.31.1441942149319;
        Thu, 10 Sep 2015 20:29:09 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.122.106 with SMTP id lr10ls427705igb.9.gmail; Thu, 10 Sep
 2015 20:29:08 -0700 (PDT)
X-Received: by 10.50.77.39 with SMTP id p7mr85889igw.7.1441942148562;
        Thu, 10 Sep 2015 20:29:08 -0700 (PDT)
In-Reply-To: <mss2qp$ful$1@ger.gmane.org>
X-Original-Sender: german.diago@hubblehome.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:20405
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/20405>

------=_Part_472_322957566.1441942147695
Content-Type: multipart/alternative; 
	boundary="----=_Part_473_1713470962.1441942147696"

------=_Part_473_1713470962.1441942147696
Content-Type: text/plain; charset=UTF-8

Less of an improvement than your macro, but it might be cool to see 

> these standardized (especially if a better solution is not forthcoming): 
>
>     template<class... Args, class T, class R> 
>     auto overload(R (T::*m)(Args...)) -> decltype(m) 
>     { return m; } 
>
>     template<class T, class R> 
>     auto overload(R (T::*m)(void)) -> decltype(m) 
>     { return m; } 
>

Well, it is better than current status, but why not go directly for a full 
solution?
 

> On the plus side, not a macro, and resolves to the desired overload 
> directly rather than adding an indirection through a templated lambda 
> (even if the compiler is able to optimize that away, though I don't know 
> that I would count on it being able to do so). 
>

Taking into account that a lambda is declared inline, with current compiler 
inliners,
I am pretty sure it is very easy to eliminate the overhead of the lambdas.
 

>
> The above is irresolvably ambiguous without additional information, 
> because either noise(int) + listen(int) or noise(float) + listen(float) 
> would be acceptable. (This is where the above 'overload<...>' is most 
> useful.) 
>

Well, actually my solution does not choose one function at the time of 
connection,
at that time you would pass an overloaded function object.
 

> Here's a silly notion: what if we allowed <>'s after any overloaded 
> function to select a particular overload? IOW: 
>
>   connect(foo, &Foo::noise<int>, bar, &Bar::listen<int>); 
>

I think this makes the pointer to member to look like a template, when in 
fact it is not.
So I would choose something else.
 
 

-- 

--- 
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/.

------=_Part_473_1713470962.1441942147696
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Less of an improvement than your macro, but it might be co=
ol to see
<br><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex=
;border-left: 1px #ccc solid;padding-left: 1ex;">these standardized (especi=
ally if a better solution is not forthcoming):
<br>
<br>=C2=A0 =C2=A0 template&lt;class... Args, class T, class R&gt;
<br>=C2=A0 =C2=A0 auto overload(R (T::*m)(Args...)) -&gt; decltype(m)
<br>=C2=A0 =C2=A0 { return m; }
<br>
<br>=C2=A0 =C2=A0 template&lt;class T, class R&gt;
<br>=C2=A0 =C2=A0 auto overload(R (T::*m)(void)) -&gt; decltype(m)
<br>=C2=A0 =C2=A0 { return m; }
<br></blockquote><div><br>Well, it is better than current status, but why n=
ot go directly for a full solution?<br>=C2=A0<br></div><blockquote class=3D=
"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc s=
olid;padding-left: 1ex;">On the plus side, not a macro, and resolves to the=
 desired overload
<br>directly rather than adding an indirection through a templated lambda
<br>(even if the compiler is able to optimize that away, though I don&#39;t=
 know
<br>that I would count on it being able to do so).
<br></blockquote><div><br>Taking into account that a lambda is declared inl=
ine, with current compiler inliners,<br>I am pretty sure it is very easy to=
 eliminate the overhead of the lambdas.<br>=C2=A0<br></div><blockquote clas=
s=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #c=
cc solid;padding-left: 1ex;"><br>The above is irresolvably ambiguous withou=
t additional information,
<br>because either noise(int) + listen(int) or noise(float) + listen(float)
<br>would be acceptable. (This is where the above &#39;overload&lt;...&gt;&=
#39; is most
<br>useful.)
<br></blockquote><div><br>Well, actually my solution does not choose one fu=
nction at the time of connection,<br>at that time you would pass an overloa=
ded function object.<br>=C2=A0<br></div><blockquote class=3D"gmail_quote" s=
tyle=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-le=
ft: 1ex;">Here&#39;s a silly notion: what if we allowed &lt;&gt;&#39;s afte=
r any overloaded
<br>function to select a particular overload? IOW:
<br>
<br>=C2=A0 connect(foo, &amp;Foo::noise&lt;int&gt;, bar, &amp;Bar::listen&l=
t;int&gt;);
<br></blockquote><div><br>I think this makes the pointer to member to look =
like a template, when in fact it is not.<br>So I would choose something els=
e.<br>=C2=A0<br></div><div>=C2=A0</div></div>

<p></p>

-- <br />
<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 <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_473_1713470962.1441942147696--
------=_Part_472_322957566.1441942147695--

.
