220 20413 <ce3faada-19f9-4cb8-b779-bda51f61a6b9@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Arthur O'Dwyer <arthur.j.odwyer@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 01:16:27 -0700 (PDT)
Lines: 106
Approved: news@gmane.org
Message-ID: <ce3faada-19f9-4cb8-b779-bda51f61a6b9@isocpp.org>
References: <a6df5848-0cdc-46eb-be42-a7e29481853f@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_749_64981022.1441959387347"
X-Trace: ger.gmane.org 1441959391 17799 80.91.229.3 (11 Sep 2015 08:16:31 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 11 Sep 2015 08:16:31 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDLZJYWNDQINZG6KV4CRUBDH3JA7O@isocpp.org Fri Sep 11 10:16:31 2015
Return-path: <std-proposals+bncBDLZJYWNDQINZG6KV4CRUBDH3JA7O@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qk0-f198.google.com ([209.85.220.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDLZJYWNDQINZG6KV4CRUBDH3JA7O@isocpp.org>)
	id 1ZaJVV-0003C7-GL
	for gclcip-std-proposals@m.gmane.org; Fri, 11 Sep 2015 10:16:29 +0200
Original-Received: by qkdj7 with SMTP id j7sf9422003qkd.1
        for <gclcip-std-proposals@m.gmane.org>; Fri, 11 Sep 2015 01:16:28 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to: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=nHFP1dZn0uT0MD/f/xBf6RS2QP3Ruu8qIcAVg1yAdoA=;
        b=J5FiqEeVFM71uWlfc3KhYDWYYoLjtay/+fXsLeT7HzzxnenA3OcoWDngm545Bb8kpj
         HoPgwyJ2A76ltiy/ZwASueN4/tVO4fHBH2KxrfIQG7C70JkmKMTY/SX7EC3vnOI69ypM
         Ti0UKZ75qBIEhx4VDrSB31KH8fVaPfGvV+rlSx65iq3P44eP5qlnzN6Q1m6NleIriUoZ
         uHKWV9dKmUptLFCqePJC2Kkf59mVZ4kLI/gew+lXOxYWOWMXtZW6mGzIg8Dms1oFX48f
         qyrIGzO8/+suB/Fsh54im42zN/ROb68IMRowMwg5BQlSkCbFq/mHUOR213Bel/nWPWfY
         /53A==
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: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=nHFP1dZn0uT0MD/f/xBf6RS2QP3Ruu8qIcAVg1yAdoA=;
        b=bNlnw2+nGkH/XAlIQASKUHuqJMs+6h2ay/NDhhJjSKZlUZ3fDKCdOOSQVvNaHojKsz
         tGm3BcBPGqMdcsI7tlFI+oSsX+5MFMEnzJ05by3I70h+Fmz+DpLWZEaD4767SjW4WrzG
         nhiGQt3bRrkmiwszBEiTJ2vZFMJe9axwxxWR+RmDvNR+IVg80Jp8J2R8hwd11O7TecSA
         7UVAfyOh+WlBGVraCZC62ubpkZABNHNE3NUhoxWtKz9CMWKljSfQZq0m8KkRkOq4kRFJ
         Tqss6DcDsHPPynS2Kh1g5B8FdnvK3SBJoVrH89s9XTN70djewNVeikW/Srs1e4CG4BRp
         RfuQ==
X-Gm-Message-State: ALoCoQnjsg1Wrd2CJZUu36p2DGWkJ2nStWeAOXbcJlRYJKf+mhrBH132bygaEE9Xct/TFXtTWMwF
X-Received: by 10.13.200.198 with SMTP id k189mr40455750ywd.46.1441959388683;
        Fri, 11 Sep 2015 01:16:28 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.66.229 with SMTP id i5ls455768igt.8.gmail; Fri, 11 Sep 2015
 01:16:28 -0700 (PDT)
X-Received: by 10.50.122.103 with SMTP id lr7mr9342igb.10.1441959388042;
        Fri, 11 Sep 2015 01:16:28 -0700 (PDT)
In-Reply-To: <a6df5848-0cdc-46eb-be42-a7e29481853f@isocpp.org>
X-Original-Sender: arthur.j.odwyer@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:20413
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/20413>

------=_Part_749_64981022.1441959387347
Content-Type: multipart/alternative; 
	boundary="----=_Part_750_1016620126.1441959387348"

------=_Part_750_1016620126.1441959387348
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Wednesday, September 9, 2015 at 9:16:28 PM UTC-7, Germ=C3=A1n Diago wrot=
e:
>
> Hello everyone,
>
> A usability problem I found and it is quite annoying and could show in=20
> many scenarios,
> and potentially in generic scenarios, is the following one:
>
>
>     void f();
>     void f(int, float);
>     void f(int);
>
>
>     auto bound_f =3D bind(f, std::placeholders::_1, 3.8f); //Ambigous cal=
l
> =20
> Instead we must do this, which is annoying, but also advanced for=20
> non-expert users (usability problem):
>
>     auto bound_f =3D bind (static_cast<void (*)(int, float)>(f),=20
> std::placeholders::_1, 3.8f);
>

An alternative in C++14 is

    auto bound_f =3D [](auto x, ...){ return f(x, 3.8f); };

and then if you don't actually need the "..." part, you could drop it,=20
which would make your code read more cleanly.

    auto bound_f =3D [](auto x){ return f(x, 3.8f); };

I have thought it would be nice to have some sort of macro like

    #define OVERLOAD_SET(f) [](auto&&... args) { return=20
f(std::forward<decltype(args)>(args)...); }

but I've never actually found myself *needing* it in practice, yet.

--=20

---=20
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 e=
mail 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-proposa=
ls/.

------=_Part_750_1016620126.1441959387348
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Wednesday, September 9, 2015 at 9:16:28 PM UTC-7, Germ=
=C3=A1n Diago wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">Hello everyone,<br><br>A usability problem I found and it is quite=
 annoying and could show in many scenarios,<br>and potentially in generic s=
cenarios, is the following one:<br><br><br>=C2=A0=C2=A0=C2=A0 void f();<br>=
=C2=A0=C2=A0=C2=A0 void f(int, float);<br>=C2=A0=C2=A0=C2=A0 void f(int);<b=
r><br><br>=C2=A0=C2=A0=C2=A0 auto bound_f =3D bind(f, std::placeholders::_1=
, 3.8f); //Ambigous call<br>=C2=A0<br>Instead we must do this, which is ann=
oying, but also advanced for non-expert users (usability problem):<br><br>=
=C2=A0=C2=A0=C2=A0 auto bound_f =3D bind (static_cast&lt;void (*)(int, floa=
t)&gt;(f), std::placeholders::_1, 3.8f);<br></div></blockquote><div><br></d=
iv><div>An alternative in C++14 is</div><div><br></div><div>=C2=A0 =C2=A0 a=
uto bound_f =3D [](auto x, ...){ return f(x, 3.8f); };</div><div><br></div>=
<div>and then if you don&#39;t actually need the &quot;...&quot; part, you =
could drop it, which would make your code read more cleanly.</div><div><br>=
</div><div><div>=C2=A0 =C2=A0 auto bound_f =3D [](auto x){ return f(x, 3.8f=
); };</div></div><div><br></div><div>I have thought it would be nice to hav=
e some sort of macro like</div><div><br></div><div>=C2=A0 =C2=A0 #define OV=
ERLOAD_SET(f) [](auto&amp;&amp;... args) { return f(std::forward&lt;decltyp=
e(args)&gt;(args)...); }</div><div><br></div><div>but I&#39;ve never actual=
ly found myself *needing* it in practice, yet.</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_750_1016620126.1441959387348--
------=_Part_749_64981022.1441959387347--

.
