Topic: Functions with multiple overloads should behave


Author: =?UTF-8?B?R2HFoXBlciBBxb5tYW4=?= <gasper.azman@gmail.com>
Date: Tue, 15 May 2018 20:05:12 +0100
Raw View
--00000000000062a56f056c4349c2
Content-Type: text/plain; charset="UTF-8"

I have a feeling first-class overload sets have been proposed a few times.
Perhaps a search might be in order :).

G

On Tue, May 15, 2018 at 8:03 PM, Antonio Perez <antonio@perezexcelsior.com>
wrote:

> *Motivation:*
> Let's define a function with two overloads:
> void my_print_func(int x) {
>    std::cout << "My int: " << x << std::endl;
> }
> void my_print_func(const std::string& s) {
>    std::cout << "My string: " << s << std::endl;
> }
>
> If I try passing my_print_func to a higher-order function, I get a
> compiler error:
>
> //Causes compiler error
> std::invoke(my_print_func, "Hello, world");
> //gcc prints "couldn't deduce template parameter _Callable"
>
> This makes sense on face value: how does the compiler know which overload
> to pass?
>
> Here's the kicker: the compiler doesn't *need* to know which overload to
> pass. Let's say I create a generic lambda that calls my print function:
>
> auto my_print_lambda = [](auto&&... inputs) {
>     return my_print_func(inputs...);
> };
>
> I can now pass my_print_lambda to a higher order function, and it'll call
> the correct overload:
>
> std::invoke(my_print_lambda, 4);
> /* Output is "My int: 4" */
> std::invoke(my_print_lambda, "hello, world");
> /* Output is "My string: hello, world" */
>
> *Proposal:*
> When an overload can't be deduced for a function with multiple overloads,
> the compiler should treat that function as though it were a generic lambda.
>
> --
> 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.
> To view this discussion on the web visit https://groups.google.com/a/
> isocpp.org/d/msgid/std-proposals/2999e8b8-d8fe-4638-
> b120-f5a9581a3dad%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/2999e8b8-d8fe-4638-b120-f5a9581a3dad%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkU0F6zWV3as_hj2hYegD-HtUYiGvADDCi8QKWhj%2BdZ9KA%40mail.gmail.com.

--00000000000062a56f056c4349c2
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I have a feeling first-class overload sets have been propo=
sed a few times. Perhaps a search might be in order :).<div><br></div><div>=
G</div></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On T=
ue, May 15, 2018 at 8:03 PM, Antonio Perez <span dir=3D"ltr">&lt;<a href=3D=
"mailto:antonio@perezexcelsior.com" target=3D"_blank">antonio@perezexcelsio=
r.com</a>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"m=
argin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"l=
tr"><b>Motivation:</b><div>Let&#39;s define a function with two overloads:<=
/div><div><div class=3D"gmail-m_-3854521347876531136prettyprint" style=3D"b=
order:1px solid rgb(187,187,187);word-wrap:break-word"><code class=3D"gmail=
-m_-3854521347876531136prettyprint"><div class=3D"gmail-m_-3854521347876531=
136subprettyprint"><div style=3D"color:rgb(212,212,212);font-family:Menlo,M=
onaco,&quot;Courier New&quot;,monospace;font-size:12px;line-height:18px;whi=
te-space:pre-wrap;background-color:rgb(255,255,255)"><div><span style=3D"co=
lor:rgb(116,151,145)"><span style=3D"color:rgb(0,0,136)" class=3D"gmail-m_-=
3854521347876531136styled-by-prettify">void</span></span><span style=3D"col=
or:rgb(0,0,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify"> my=
_</span><span style=3D"color:rgb(139,238,217)"><span style=3D"color:rgb(0,0=
,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify">print_func</s=
pan></span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-385452134=
7876531136styled-by-prettify">(</span><span style=3D"color:rgb(116,151,145)=
"><span style=3D"color:rgb(0,0,136)" class=3D"gmail-m_-3854521347876531136s=
tyled-by-prettify">int</span></span><span style=3D"color:rgb(0,0,0)" class=
=3D"gmail-m_-3854521347876531136styled-by-prettify"> x</span><span style=3D=
"color:rgb(102,102,0)" class=3D"gmail-m_-3854521347876531136styled-by-prett=
ify">)</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-38545213478=
76531136styled-by-prettify"> </span><span style=3D"color:rgb(102,102,0)" cl=
ass=3D"gmail-m_-3854521347876531136styled-by-prettify">{</span></div><div><=
span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-3854521347876531136styled=
-by-prettify"> =C2=A0 =C2=A0std</span><span style=3D"color:rgb(102,102,0)" =
class=3D"gmail-m_-3854521347876531136styled-by-prettify">::</span><span sty=
le=3D"color:rgb(0,0,0)" class=3D"gmail-m_-3854521347876531136styled-by-pret=
tify">cout </span><span style=3D"color:rgb(129,198,190)"><span style=3D"col=
or:rgb(102,102,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify"=
>&lt;&lt;</span></span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-3=
854521347876531136styled-by-prettify"> </span><span style=3D"color:rgb(0,25=
5,255)"><span style=3D"color:rgb(0,136,0)" class=3D"gmail-m_-38545213478765=
31136styled-by-prettify">&quot;My int: &quot;</span></span><span style=3D"c=
olor:rgb(0,0,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify"> =
</span><span style=3D"color:rgb(129,198,190)"><span style=3D"color:rgb(102,=
102,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify">&lt;&lt;</=
span></span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-385452134787=
6531136styled-by-prettify"> x </span><span style=3D"color:rgb(129,198,190)"=
><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-3854521347876531136=
styled-by-prettify">&lt;&lt;</span></span><span style=3D"color:rgb(0,0,0)" =
class=3D"gmail-m_-3854521347876531136styled-by-prettify"> std</span><span s=
tyle=3D"color:rgb(102,102,0)" class=3D"gmail-m_-3854521347876531136styled-b=
y-prettify">::</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-385=
4521347876531136styled-by-prettify">endl</span><span style=3D"color:rgb(102=
,102,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify">;</span><=
/div><div><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-3854521347=
876531136styled-by-prettify">}</span></div><div><span style=3D"color:rgb(11=
6,151,145)"><span style=3D"color:rgb(0,0,136)" class=3D"gmail-m_-3854521347=
876531136styled-by-prettify">void</span></span><span style=3D"color:rgb(0,0=
,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify"> my_</span><s=
pan style=3D"color:rgb(139,238,217)"><span style=3D"color:rgb(0,0,0)" class=
=3D"gmail-m_-3854521347876531136styled-by-prettify">print_func</span></span=
><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-3854521347876531136=
styled-by-prettify">(</span><span style=3D"color:rgb(116,151,145)"><span st=
yle=3D"color:rgb(0,0,136)" class=3D"gmail-m_-3854521347876531136styled-by-p=
rettify">const</span></span><span style=3D"color:rgb(0,0,0)" class=3D"gmail=
-m_-3854521347876531136styled-by-prettify"> std</span><span style=3D"color:=
rgb(102,102,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify">::=
</span><span style=3D"color:rgb(0,0,136)" class=3D"gmail-m_-385452134787653=
1136styled-by-prettify">string</span><span style=3D"color:rgb(129,198,190)"=
><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-3854521347876531136=
styled-by-prettify">&amp;</span></span><span style=3D"color:rgb(0,0,0)" cla=
ss=3D"gmail-m_-3854521347876531136styled-by-prettify"> s</span><span style=
=3D"color:rgb(102,102,0)" class=3D"gmail-m_-3854521347876531136styled-by-pr=
ettify">)</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-38545213=
47876531136styled-by-prettify"> </span><span style=3D"color:rgb(102,102,0)"=
 class=3D"gmail-m_-3854521347876531136styled-by-prettify">{</span></div><di=
v><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-3854521347876531136sty=
led-by-prettify"> =C2=A0 =C2=A0std</span><span style=3D"color:rgb(102,102,0=
)" class=3D"gmail-m_-3854521347876531136styled-by-prettify">::</span><span =
style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-3854521347876531136styled-by-p=
rettify">cout </span><span style=3D"color:rgb(129,198,190)"><span style=3D"=
color:rgb(102,102,0)" class=3D"gmail-m_-3854521347876531136styled-by-pretti=
fy">&lt;&lt;</span></span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m=
_-3854521347876531136styled-by-prettify"> </span><span style=3D"color:rgb(0=
,255,255)"><span style=3D"color:rgb(0,136,0)" class=3D"gmail-m_-38545213478=
76531136styled-by-prettify">&quot;My string: &quot;</span></span><span styl=
e=3D"color:rgb(0,0,0)" class=3D"gmail-m_-3854521347876531136styled-by-prett=
ify"> </span><span style=3D"color:rgb(129,198,190)"><span style=3D"color:rg=
b(102,102,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify">&lt;=
&lt;</span></span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-385452=
1347876531136styled-by-prettify"> s </span><span style=3D"color:rgb(129,198=
,190)"><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-3854521347876=
531136styled-by-prettify">&lt;&lt;</span></span><span style=3D"color:rgb(0,=
0,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify"> std</span><=
span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-3854521347876531136st=
yled-by-prettify">::</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-=
m_-3854521347876531136styled-by-prettify">endl</span><span style=3D"color:r=
gb(102,102,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify">;</=
span></div><div><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-3854=
521347876531136styled-by-prettify">}</span></div></div></div></code></div><=
br>If I try passing my_print_func to a higher-order function, I get a compi=
ler error:</div><div><br></div><div><div class=3D"gmail-m_-3854521347876531=
136prettyprint" style=3D"border:1px solid rgb(187,187,187);word-wrap:break-=
word"><code class=3D"gmail-m_-3854521347876531136prettyprint"><div class=3D=
"gmail-m_-3854521347876531136subprettyprint"><div style=3D"color:rgb(212,21=
2,212);font-family:Menlo,Monaco,&quot;Courier New&quot;,monospace;font-size=
:12px;line-height:18px;white-space:pre-wrap;background-color:rgb(255,255,25=
5)"><span style=3D"color:rgb(139,238,217)"><span style=3D"color:rgb(136,0,0=
)" class=3D"gmail-m_-3854521347876531136styled-by-prettify">//Causes compil=
er error</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-385452134=
7876531136styled-by-prettify"><br>std</span><span style=3D"color:rgb(102,10=
2,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify">::</span><sp=
an style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-3854521347876531136styled-b=
y-prettify">invoke</span></span><span style=3D"color:rgb(102,102,0)" class=
=3D"gmail-m_-3854521347876531136styled-by-prettify">(</span><span style=3D"=
color:rgb(0,0,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify">=
my_print_func</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-=
3854521347876531136styled-by-prettify">,</span><span style=3D"color:rgb(0,0=
,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify"> </span><span=
 style=3D"color:rgb(0,255,255)"><span style=3D"color:rgb(0,136,0)" class=3D=
"gmail-m_-3854521347876531136styled-by-prettify">&quot;Hello, world&quot;</=
span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-385452134787653=
1136styled-by-prettify">);</span><span style=3D"color:rgb(0,0,0)" class=3D"=
gmail-m_-3854521347876531136styled-by-prettify"><br></span><span style=3D"c=
olor:rgb(136,0,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify"=
>//gcc prints &quot;couldn&#39;t deduce template parameter _Callable&quot;<=
/span></span></div></div></code></div><br>This makes sense on face value: h=
ow does the compiler know which overload to pass?=C2=A0</div><div><br></div=
><div>Here&#39;s the kicker: the compiler doesn&#39;t <i>need</i>=C2=A0to k=
now which overload to pass. Let&#39;s say I create a generic lambda that ca=
lls my print function:</div><div><br></div><div><div class=3D"gmail-m_-3854=
521347876531136prettyprint" style=3D"border:1px solid rgb(187,187,187);word=
-wrap:break-word"><code class=3D"gmail-m_-3854521347876531136prettyprint"><=
div class=3D"gmail-m_-3854521347876531136subprettyprint"><div style=3D"colo=
r:rgb(212,212,212);font-family:Menlo,Monaco,&quot;Courier New&quot;,monospa=
ce;font-size:12px;line-height:18px;white-space:pre-wrap;background-color:rg=
b(255,255,255)"><span style=3D"color:rgb(116,151,145)"><span style=3D"color=
:rgb(0,0,136)" class=3D"gmail-m_-3854521347876531136styled-by-prettify">aut=
o</span></span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-385452134=
7876531136styled-by-prettify"> my_print_lambda </span><span style=3D"color:=
rgb(129,198,190)"><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-38=
54521347876531136styled-by-prettify">=3D</span></span><span style=3D"color:=
rgb(0,0,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify"> </spa=
n><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-385452134787653113=
6styled-by-prettify">[](</span><span style=3D"color:rgb(116,151,145)"><span=
 style=3D"color:rgb(0,0,136)" class=3D"gmail-m_-3854521347876531136styled-b=
y-prettify">auto</span></span><span style=3D"color:rgb(129,198,190)"><span =
style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-3854521347876531136styled-=
by-prettify">&amp;&amp;</span></span><span style=3D"color:rgb(102,102,0)" c=
lass=3D"gmail-m_-3854521347876531136styled-by-prettify">...</span><span sty=
le=3D"color:rgb(0,0,0)" class=3D"gmail-m_-3854521347876531136styled-by-pret=
tify"> </span><span style=3D"color:rgb(255,255,255)"><span style=3D"color:r=
gb(0,0,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify">inputs<=
/span></span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-3854521=
347876531136styled-by-prettify">)</span><span style=3D"color:rgb(0,0,0)" cl=
ass=3D"gmail-m_-3854521347876531136styled-by-prettify"> </span><span style=
=3D"color:rgb(102,102,0)" class=3D"gmail-m_-3854521347876531136styled-by-pr=
ettify">{</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-38545213=
47876531136styled-by-prettify"> <br></span><span style=3D"color:rgb(139,238=
,217)"><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-38545213478765311=
36styled-by-prettify">=C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0,136=
)" class=3D"gmail-m_-3854521347876531136styled-by-prettify">return</span><s=
pan style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-3854521347876531136styled-=
by-prettify"> my_print_func</span></span><span style=3D"color:rgb(102,102,0=
)" class=3D"gmail-m_-3854521347876531136styled-by-prettify">(</span><span s=
tyle=3D"color:rgb(0,0,0)" class=3D"gmail-m_-3854521347876531136styled-by-pr=
ettify">inputs</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_=
-3854521347876531136styled-by-prettify">...);</span><span style=3D"color:rg=
b(0,0,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify"> <br></s=
pan><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-3854521347876531=
136styled-by-prettify">};</span></div></div></code></div><br>I can now pass=
 my_print_lambda to a higher order function, and it&#39;ll call the correct=
 overload:</div><div><br></div><div><div class=3D"gmail-m_-3854521347876531=
136prettyprint" style=3D"border:1px solid rgb(187,187,187);word-wrap:break-=
word"><code class=3D"gmail-m_-3854521347876531136prettyprint"><div class=3D=
"gmail-m_-3854521347876531136subprettyprint"><div style=3D"font-family:Menl=
o,Monaco,&quot;Courier New&quot;,monospace;font-size:12px;line-height:18px;=
white-space:pre-wrap;background-color:rgb(255,255,255)"><div style=3D"color=
:rgb(212,212,212)"><span style=3D"color:rgb(139,238,217)"><span style=3D"co=
lor:rgb(0,0,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify">st=
d</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-385452134787=
6531136styled-by-prettify">::</span><span style=3D"color:rgb(0,0,0)" class=
=3D"gmail-m_-3854521347876531136styled-by-prettify">invoke</span></span><sp=
an style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-3854521347876531136styl=
ed-by-prettify">(</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-=
3854521347876531136styled-by-prettify">my_print_lambda</span><span style=3D=
"color:rgb(102,102,0)" class=3D"gmail-m_-3854521347876531136styled-by-prett=
ify">,</span><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-38545213478=
76531136styled-by-prettify"> </span><span style=3D"color:rgb(0,255,255)"><s=
pan style=3D"color:rgb(0,102,102)" class=3D"gmail-m_-3854521347876531136sty=
led-by-prettify">4</span></span><span style=3D"color:rgb(102,102,0)" class=
=3D"gmail-m_-3854521347876531136styled-by-prettify">);</span><span style=3D=
"color:rgb(0,0,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify"=
> </span></div><div><span style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-38=
54521347876531136styled-by-prettify">/</span><font color=3D"#000000"><span =
style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-3854521347876531136styled-by=
-prettify">* </span></font><span style=3D"color:rgb(136,0,0)" class=3D"gmai=
l-m_-3854521347876531136styled-by-prettify">Output is &quot;My int: 4&quot;=
 */</span></div><div style=3D"color:rgb(212,212,212)"><span style=3D"color:=
rgb(139,238,217)"><span style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-385452=
1347876531136styled-by-prettify">std</span><span style=3D"color:rgb(102,102=
,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify">::</span><spa=
n style=3D"color:rgb(0,0,0)" class=3D"gmail-m_-3854521347876531136styled-by=
-prettify">invoke</span></span><span style=3D"color:rgb(102,102,0)" class=
=3D"gmail-m_-3854521347876531136styled-by-prettify">(</span><span style=3D"=
color:rgb(0,0,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify">=
my_print_lambda</span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m=
_-3854521347876531136styled-by-prettify">,</span><span style=3D"color:rgb(0=
,0,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify"> </span><sp=
an style=3D"color:rgb(0,255,255)"><span style=3D"color:rgb(0,136,0)" class=
=3D"gmail-m_-3854521347876531136styled-by-prettify">&quot;hello, world&quot=
;</span></span><span style=3D"color:rgb(102,102,0)" class=3D"gmail-m_-38545=
21347876531136styled-by-prettify">);</span><span style=3D"color:rgb(0,0,0)"=
 class=3D"gmail-m_-3854521347876531136styled-by-prettify"> </span></div><di=
v style=3D"color:rgb(212,212,212)"><span style=3D"color:rgb(86,108,105)"><s=
pan style=3D"color:rgb(136,0,0)" class=3D"gmail-m_-3854521347876531136style=
d-by-prettify">/* Output is &quot;My string: hello,</span><span style=3D"co=
lor:rgb(136,0,0)" class=3D"gmail-m_-3854521347876531136styled-by-prettify">=
 world&quot; */</span></span></div></div></div></code></div><br><b>Proposal=
:</b></div><div>When an overload can&#39;t be deduced for a function with m=
ultiple overloads, the compiler should treat that function as though it wer=
e a generic lambda.=C2=A0</div></div><span class=3D"gmail-HOEnZb"><font col=
or=3D"#888888">

<p></p>

-- <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" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/2999e8b8-d8fe-4638-b120-f5a9581a3dad%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/2999=
e8b8-d8fe-4638-<wbr>b120-f5a9581a3dad%40isocpp.org</a><wbr>.<br>
</font></span></blockquote></div><br></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkU0F6zWV3as_hj2hYegD-HtUYiGvA=
DDCi8QKWhj%2BdZ9KA%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAANG%3DkU0F6=
zWV3as_hj2hYegD-HtUYiGvADDCi8QKWhj%2BdZ9KA%40mail.gmail.com</a>.<br />

--00000000000062a56f056c4349c2--

.


Author: Antonio Perez <antonio@perezexcelsior.com>
Date: Tue, 15 May 2018 12:55:22 -0700 (PDT)
Raw View
------=_Part_9981_527220885.1526414122866
Content-Type: multipart/alternative;
 boundary="----=_Part_9982_1609983879.1526414122866"

------=_Part_9982_1609983879.1526414122866
Content-Type: text/plain; charset="UTF-8"

I found a proposal from 2013 with the same goals that I have
(https://isocpp.org/files/papers/n3617.txt), although it was introduced
before generic lambdas had officially become part of the C++ standard. I am
unsure as to why it was rejected, although the syntax they propose is not
intuitive (it looks like an ill-formed lambda).

Now that generic lambdas have officially become part of the standard, I
think it would be a good time to revisit the idea of first-class
overloading sets. I think that my proposed syntax (of allowing an
overloaded function to be passed or assigned as though it were a generic
lambda) is cleaner, intuitive, and matches the way functions are currently
passed in C++.

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/92b6dc12-375b-4df0-93e3-8f486998cb0f%40isocpp.org.

------=_Part_9982_1609983879.1526414122866
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I found a proposal from 2013 with the same goals that I ha=
ve (https://isocpp.org/files/papers/n3617.txt), although it was introduced =
before generic lambdas had officially become part of the C++ standard. I am=
 unsure as to why it was rejected, although the syntax they propose is not =
intuitive (it looks like an ill-formed lambda).=C2=A0<div><br></div><div>No=
w that generic lambdas have officially become part of the standard, I think=
 it would be a good time to revisit the idea of first-class overloading set=
s. I think that my proposed syntax (of allowing an overloaded function to b=
e passed or assigned as though it were a generic lambda) is cleaner, intuit=
ive, and matches the way functions are currently passed in C++.=C2=A0</div>=
</div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/92b6dc12-375b-4df0-93e3-8f486998cb0f%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/92b6dc12-375b-4df0-93e3-8f486998cb0f=
%40isocpp.org</a>.<br />

------=_Part_9982_1609983879.1526414122866--

------=_Part_9981_527220885.1526414122866--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Tue, 15 May 2018 12:56:16 -0700 (PDT)
Raw View
------=_Part_32697_1642545446.1526414176964
Content-Type: multipart/alternative;
 boundary="----=_Part_32698_1751962565.1526414176964"

------=_Part_32698_1751962565.1526414176964
Content-Type: text/plain; charset="UTF-8"

On Tuesday, May 15, 2018 at 3:03:38 PM UTC-4, Antonio Perez wrote:
>
> P*roposal:*
> When an overload can't be deduced for a function with multiple overloads,
> the compiler should treat that function as though it were a generic lambda.
>

Considering that generic lambdas are objects while functions are not, this
has far too many opportunities to cause oddball problems. Consider:

void some_func();
auto func = some_func;  //This is a function pointer.
std::function<std::remove_pointer_t<decltype(func)>> functor = func;

void some_func(int);
auto func2 = some_func; //This is... something else.
std::function<std::remove_pointer_t<decltype(func2)>> functor2(func2);

The latter would fail to compile for a seemingly inscrutable reason:
`func2` is not a function pointer like you expected. Whereas currently, it
fails to compile at the site of the actual error: getting the overloaded
`some_func`.

Most proposals that want to package overload sets usually attempt to use
some kind of identifying syntax. Since it's creating a lambda, the most
recent one used `[]function_name`.

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/981053e6-7add-4732-9013-d43381ed6ca8%40isocpp.org.

------=_Part_32698_1751962565.1526414176964
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Tuesday, May 15, 2018 at 3:03:38 PM UTC-4, Antonio Pere=
z wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0=
..8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div>=
P<b>roposal:</b></div><div>When an overload can&#39;t be deduced for a func=
tion with multiple overloads, the compiler should treat that function as th=
ough it were a generic lambda.=C2=A0</div></div></blockquote><div><br></div=
><div>Considering that generic lambdas are objects while functions are not,=
 this has far too many opportunities to cause oddball problems. Consider:</=
div><div><br></div><div style=3D"background-color: rgb(250, 250, 250); bord=
er-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; overf=
low-wrap: break-word;" class=3D"prettyprint"><code class=3D"prettyprint"><d=
iv class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by=
-prettify">void</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> some_func</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">();</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r></span><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> func </span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> some_func</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> =C2=A0</span><span style=3D"color=
: #800;" class=3D"styled-by-prettify">//This is a function pointer.</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br>std</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">function</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">std</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">remove_pointer_t</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">decltype</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">func</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">)&gt;&gt;</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> functor </span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 func</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span><span=
 style=3D"color: #000;" class=3D"styled-by-prettify"> some_func</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color:=
 #660;" class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> func2 </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> some_func</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> =
</span><span style=3D"color: #800;" class=3D"styled-by-prettify">//This is.=
... something else.</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"><br>std</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">::</span><span style=3D"color: #008;" class=3D"styled-by-prettify">fun=
ction</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;<=
/span><code class=3D"prettyprint"><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">std</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">remove_pointer_t</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">&lt;</span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">decltype</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">func2</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">)&gt;</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify"></span></code><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> functor2</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">func2</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">);</span></div></code></div><div></div><di=
v><br></div><div>The latter would fail to compile for a seemingly inscrutab=
le reason: `func2` is not a function pointer like you expected. Whereas cur=
rently, it fails to compile at the site of the actual error: getting the ov=
erloaded `some_func`.<br></div><div></div><div><br></div><div>Most proposal=
s that want to package overload sets usually attempt to use some kind of id=
entifying syntax. Since it&#39;s creating a lambda, the most recent one use=
d `[]function_name`.<br></div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/981053e6-7add-4732-9013-d43381ed6ca8%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/981053e6-7add-4732-9013-d43381ed6ca8=
%40isocpp.org</a>.<br />

------=_Part_32698_1751962565.1526414176964--

------=_Part_32697_1642545446.1526414176964--

.


Author: Barry Revzin <barry.revzin@gmail.com>
Date: Tue, 15 May 2018 13:11:32 -0700 (PDT)
Raw View
------=_Part_32661_528885864.1526415092967
Content-Type: multipart/alternative;
 boundary="----=_Part_32662_1992606073.1526415092967"

------=_Part_32662_1992606073.1526415092967
Content-Type: text/plain; charset="UTF-8"


>
>
> *Proposal:*
> When an overload can't be deduced for a function with multiple overloads,
> the compiler should treat that function as though it were a generic lambda.
>

 P0119: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0119r2.pdf

And its response, pointing out the unfortunate problems with the idea and
why we can't have nice things:

P0382: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0382r0.html

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b3d696b9-b3ed-403f-9c09-ecae5f1a1e79%40isocpp.org.

------=_Part_32662_1992606073.1526415092967
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr"><div><br><b>Proposal:</b></div><div>When an overload can&#39;t be deduc=
ed for a function with multiple overloads, the compiler should treat that f=
unction as though it were a generic lambda.=C2=A0</div></div></blockquote><=
div><br></div><div>=C2=A0P0119:=C2=A0http://www.open-std.org/jtc1/sc22/wg21=
/docs/papers/2016/p0119r2.pdf</div><div><br></div><div>And its response, po=
inting out the unfortunate problems with the idea and why we can&#39;t have=
 nice things:</div><div><br></div><div>P0382:=C2=A0http://www.open-std.org/=
jtc1/sc22/wg21/docs/papers/2016/p0382r0.html</div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/b3d696b9-b3ed-403f-9c09-ecae5f1a1e79%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/b3d696b9-b3ed-403f-9c09-ecae5f1a1e79=
%40isocpp.org</a>.<br />

------=_Part_32662_1992606073.1526415092967--

------=_Part_32661_528885864.1526415092967--

.


Author: Antonio Perez <antonio@perezexcelsior.com>
Date: Tue, 15 May 2018 14:24:11 -0700 (PDT)
Raw View
------=_Part_33476_1514698153.1526419451069
Content-Type: multipart/alternative;
 boundary="----=_Part_33477_1966160946.1526419451070"

------=_Part_33477_1966160946.1526419451070
Content-Type: text/plain; charset="UTF-8"

Based on the response paper, it seems like the introduction of modules
would go a long way in removing most of the issues with the idea.

On Tuesday, May 15, 2018 at 2:11:33 PM UTC-6, Barry Revzin wrote:
>
>
>> *Proposal:*
>> When an overload can't be deduced for a function with multiple overloads,
>> the compiler should treat that function as though it were a generic lambda.
>>
>
>  P0119:
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0119r2.pdf
>
> And its response, pointing out the unfortunate problems with the idea and
> why we can't have nice things:
>
> P0382:
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0382r0.html
>

--
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.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/eba5579b-2b27-4eca-bbb5-9caabe7ea083%40isocpp.org.

------=_Part_33477_1966160946.1526419451070
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Based on the response paper, it seems like the introductio=
n of modules would go a long way in removing most of the issues with the id=
ea.=C2=A0<br><br>On Tuesday, May 15, 2018 at 2:11:33 PM UTC-6, Barry Revzin=
 wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.=
8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><block=
quote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left=
:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><div><br><b>Proposal:</b=
></div><div>When an overload can&#39;t be deduced for a function with multi=
ple overloads, the compiler should treat that function as though it were a =
generic lambda.=C2=A0</div></div></blockquote><div><br></div><div>=C2=A0P01=
19:=C2=A0<a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016=
/p0119r2.pdf" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=
=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.open-std.org%2Fjtc1=
%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2016%2Fp0119r2.pdf\x26sa\x3dD\x26sntz\x3d1=
\x26usg\x3dAFQjCNGoAOJ6ga3YICb8Yuy8BieDykws0A&#39;;return true;" onclick=3D=
"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.open-std.=
org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2016%2Fp0119r2.pdf\x26sa\x3dD\x2=
6sntz\x3d1\x26usg\x3dAFQjCNGoAOJ6ga3YICb8Yuy8BieDykws0A&#39;;return true;">=
http://www.open-std.<wbr>org/jtc1/sc22/wg21/docs/<wbr>papers/2016/p0119r2.p=
df</a></div><div><br></div><div>And its response, pointing out the unfortun=
ate problems with the idea and why we can&#39;t have nice things:</div><div=
><br></div><div>P0382:=C2=A0<a href=3D"http://www.open-std.org/jtc1/sc22/wg=
21/docs/papers/2016/p0382r0.html" target=3D"_blank" rel=3D"nofollow" onmous=
edown=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.o=
pen-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2016%2Fp0382r0.html\x26s=
a\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGeG7Tiko06g4FWV1UD6poAk9lcTA&#39;;retur=
n true;" onclick=3D"this.href=3D&#39;http://www.google.com/url?q\x3dhttp%3A=
%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2016%2Fp0382r=
0.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGeG7Tiko06g4FWV1UD6poAk9lcTA=
&#39;;return true;">http://www.open-std.<wbr>org/jtc1/sc22/wg21/docs/<wbr>p=
apers/2016/p0382r0.html</a></div></div></blockquote></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/eba5579b-2b27-4eca-bbb5-9caabe7ea083%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/eba5579b-2b27-4eca-bbb5-9caabe7ea083=
%40isocpp.org</a>.<br />

------=_Part_33477_1966160946.1526419451070--

------=_Part_33476_1514698153.1526419451069--

.