220 20416 <msuqsv$e3q$1@ger.gmane.org> article
Path: news.gmane.org!not-for-mail
From: Matthew Woehlke <mwoehlke.floss@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Usability improvement: Unambiguously resolve
 overloaded functions when passed as function parameters
Date: Fri, 11 Sep 2015 11:10:22 -0400
Lines: 49
Approved: news@gmane.org
Message-ID: <msuqsv$e3q$1@ger.gmane.org>
References: <a6df5848-0cdc-46eb-be42-a7e29481853f@isocpp.org> <mss2qp$ful$1@ger.gmane.org> <f7265d31-566c-4a00-8820-f2ac7fda7002@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Trace: ger.gmane.org 1441984277 15352 80.91.229.3 (11 Sep 2015 15:11:17 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 11 Sep 2015 15:11:17 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC37LBFWUIFBB6G5ZOXQKGQEGMSQJWQ@isocpp.org Fri Sep 11 17:11:08 2015
Return-path: <std-proposals+bncBC37LBFWUIFBB6G5ZOXQKGQEGMSQJWQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lb0-f199.google.com ([209.85.217.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC37LBFWUIFBB6G5ZOXQKGQEGMSQJWQ@isocpp.org>)
	id 1ZaPya-0007rC-8r
	for gclcip-std-proposals@m.gmane.org; Fri, 11 Sep 2015 17:10:56 +0200
Original-Received: by lbcao8 with SMTP id ao8sf25492464lbc.1
        for <gclcip-std-proposals@m.gmane.org>; Fri, 11 Sep 2015 08:10:50 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:to:from:subject:date:lines:message-id:references
         :mime-version:content-type:user-agent:in-reply-to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=mRLyE14FtpQQ8uU/yaKt4jGIctgqVFdeWmznL4Wcj34=;
        b=KNsfulRxN9iIJ4s1zwEDRYlfkQXFNswbKFnKdzfbxEW48izloYLQ9xwhDF5gU3/Nhj
         9woQ525+pJdY+dOS1KTmYBIQRVf3xtrzHLu6Tkt6Z37c20s6xEK63fbcTdcBpt5YWTNj
         vQBVpiwWCpykh/wGHC/EVoF2q17PN3GNYWBn3u9/FOeadOI4qqsHAwpk+XHnzSx34J0O
         Wjx8SKxv6GKenx4BLSH+u7h945kmGIfo+sA2hjt2+CcM7AiTWflaTnprlRpMpWhRGBiB
         qPqLiWRT1pnatU2g46WNwrk/ic4EdIKaYcAE9jvNWiqxWKyueqD7PJQyuBfRMd5u8mOF
         
X-Gm-Message-State: ALoCoQmDGgPec/vDnB/0CjL/V9VB7Uc/aJJKYE3vNBJ/J+9A0dKwzHdYFiys74GUcowcl2v5ygVB
X-Received: by 10.112.139.137 with SMTP id qy9mr11271718lbb.17.1441984250895;
        Fri, 11 Sep 2015 08:10:50 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.152.28.66 with SMTP id z2ls315392lag.76.gmail; Fri, 11 Sep
 2015 08:10:48 -0700 (PDT)
X-Received: by 10.152.7.106 with SMTP id i10mr42693160laa.114.1441984248041;
        Fri, 11 Sep 2015 08:10:48 -0700 (PDT)
Original-Received: from plane.gmane.org (plane.gmane.org. [80.91.229.3])
        by mx.google.com with ESMTPS id ry9si507376lbb.99.2015.09.11.08.10.48
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=RC4-SHA bits=128/128);
        Fri, 11 Sep 2015 08:10:48 -0700 (PDT)
Received-SPF: pass (google.com: domain of gclcip-std-proposals@m.gmane.org designates 80.91.229.3 as permitted sender) client-ip=80.91.229.3;
Original-Received: from list by plane.gmane.org with local (Exim 4.69)
	(envelope-from <gclcip-std-proposals@m.gmane.org>)
	id 1ZaPyI-0007cf-Dg
	for std-proposals@isocpp.org; Fri, 11 Sep 2015 17:10:38 +0200
Original-Received: from tripoint.kitware.com ([66.194.253.20])
        by main.gmane.org with esmtp (Gmexim 0.1 (Debian))
        id 1AlnuQ-0007hv-00
        for <std-proposals@isocpp.org>; Fri, 11 Sep 2015 17:10:38 +0200
Original-Received: from mwoehlke.floss by tripoint.kitware.com with local (Gmexim 0.1 (Debian))
        id 1AlnuQ-0007hv-00
        for <std-proposals@isocpp.org>; Fri, 11 Sep 2015 17:10:38 +0200
X-Injected-Via-Gmane: http://gmane.org/
Original-Lines: 40
Original-X-Complaints-To: usenet@ger.gmane.org
X-Gmane-NNTP-Posting-Host: tripoint.kitware.com
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0
In-Reply-To: <f7265d31-566c-4a00-8820-f2ac7fda7002@isocpp.org>
X-Original-Sender: mwoehlke.floss@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of gclcip-std-proposals@m.gmane.org designates 80.91.229.3 as
 permitted sender) smtp.mailfrom=gclcip-std-proposals@m.gmane.org;
       dmarc=fail (p=NONE dis=NONE) header.from=gmail.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:20416
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/20416>

On 2015-09-10 23:29, german.diago@hubblehome.com wrote:
>> Less of an improvement than your macro, but it might be cool to see 
>> [snipped] 
>> 
>> 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 
> compilerinliners, I am pretty sure it is very easy to eliminate the
> overhead of the lambdas.

Even in a case like this?

  void foo(void (*)(int));
  void foo(std::function<void (int)>);
  foo(overloaded(bar));

To be equally as efficient, the above would have to resolve to a call of
'void foo(void (*)(int))' with '&bar' (proper overload selected) as the
parameter. This happens with my helper function. I'm less sure it would
happen, or even if it legally *can* happen, with your lambda wrapper.

>> 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.

Well, yes, but I suppose my point is that your solution is not usable
for this case. Signals/slots *must* be fully resolved at call time (the
signal, at least). Also, I'm not sure if Qt's parameter matching would
work with templated lambdas.

-- 
Matthew

-- 

--- 
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/.

.
