Topic: interest in an overload factory / match visitor


Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Sun, 16 Nov 2014 15:07:39 +0100
Raw View
This is a multi-part message in MIME format.
--------------010900070900060909050804
Content-Type: text/plain; charset=UTF-8; format=flowed

Hi,


In n3418
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3418.pdf)
there is an example of a overload function that I find quite useful. You
can found a variadic implementation at
https://github.com/JasonL9000/cppcon14/blob/master/variant.h#L114.

Is there an interest for such functionality in the standard?

     template <class R, class ... Fs>
     auto overload(Fs &&... fcts);

Example

     auto visitor = std::overload(
         [](int i, int j )         {          ...        },
         [](int i, string const &j )         {          ... },
         [](auto const &i, auto const &j )        {          ...        }
     ));

This kind of overloaded function object could be used in the context of
visitation for types as experimental::any/variant.

This library
https://github.com/JasonL9000/cppcon14/blob/master/variant.h contains
also a match function that could also be quite useful.

E.g we could have visit two variant as follows


     variant<int, string> a = 2;
variant<int, string> b = 2;
     match(make_tuple(a, b),
         [](int i, int j )
         { ... },
         [](auto const &i, auto const &j ) // there is at least a string
in a and b
         { ... },
         [](...) // there is neither an int nor a string in a and b
         { ... }
     );

For std::experimental::any, we need a wrapper that knows the list of
types to visit. Something like select_types<int, string>(a) could be
used to build this wrapper.

any a = 2;
     any b = 2;
     match(make_tuple(select_types<int, string>(a), select_types<int,
string>(b)),
         [](int i, int j )
         { ... },
         [](auto const &i, auto const &j ) // there is at least a string
in a and b
         { ... },
         [](...) // there is no int nor string in a and b
         { ... }
     );

Any comments are welcome,
Vicente

--

---
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/.

--------------010900070900060909050804
Content-Type: text/html; charset=UTF-8

<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <font size="+1">Hi,<br>
      <br>
      <br>
      In n3418
      (<a class="moz-txt-link-freetext" href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3418.pdf">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3418.pdf</a>)
      there is an example of a overload function that I find quite
      useful. You can found a variadic implementation at&nbsp;
      <a class="moz-txt-link-freetext" href="https://github.com/JasonL9000/cppcon14/blob/master/variant.h#L114">https://github.com/JasonL9000/cppcon14/blob/master/variant.h#L114</a>.<br>
      <br>
      Is there an interest for such functionality in the standard?<br>
      <br>
      &nbsp;&nbsp;&nbsp; template &lt;class R, class ... Fs&gt;<br>
      &nbsp;&nbsp;&nbsp; auto overload(Fs &amp;&amp;... fcts);<br>
      <br>
      Example<br>
      <br>
      &nbsp;&nbsp;&nbsp; auto visitor = std::overload(<br>
    </font><font size="+1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [](int i, int j ) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</font><font
      size="+1"><font size="+1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; },<br>
    </font><font size="+1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [](int i, string const &amp;j )
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</font><font size="+1"><font size="+1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      },<br>
    </font><font size="+1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [](auto const &amp;i, auto const
      &amp;j )&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
      &nbsp;&nbsp;&nbsp; ));<br>
      <br>
      This kind of overloaded function object could be used in the
      context of visitation for types as experimental::any/variant. <br>
      <br>
      This library </font><font size="+1"><font size="+1"><a class="moz-txt-link-freetext" href="https://github.com/JasonL9000/cppcon14/blob/master/variant.h">https://github.com/JasonL9000/cppcon14/blob/master/variant.h</a></font>
      contains also a match function that could also be quite useful.<br>
      <br>
      E.g we could have visit two variant as follows<br>
      <br>
    </font><br>
    <font size="+1"><font size="+1">&nbsp;&nbsp;&nbsp; variant&lt;int, string&gt; a =
        2;<br>
        &nbsp;&nbsp;&nbsp; </font></font><font size="+1"><font size="+1"><font
          size="+1"><font size="+1">variant&lt;int, string&gt;</font></font>
        b = 2;<br>
        &nbsp;&nbsp;&nbsp; match(make_tuple(a, b),<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [](int i, int j )<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { ... },<br>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [](auto const &amp;i, auto const &amp;j ) // there is at
        least a string in a and b<br>
      </font><font size="+1"><font size="+1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { ... },<br>
        </font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [](...) // there is neither an int nor a string
        in a and b<br>
      </font><font size="+1"><font size="+1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { ... }<br>
        </font>&nbsp;&nbsp;&nbsp; );<br>
        <br>
        For std::experimental::any, we need a wrapper that knows the
        list of types to visit. </font></font><font size="+1"><font
        size="+1"><font size="+1">Something like select_types&lt;int,
          string&gt;(a) could be used to build this wrapper.<br>
          <br>
        </font></font></font><font size="+1"><font size="+1"></font>&nbsp;&nbsp;&nbsp;
      any a = 2;<br>
      &nbsp;&nbsp;&nbsp; any b = 2;<br>
      &nbsp;&nbsp;&nbsp; match(make_tuple(select_types&lt;int, string&gt;(a),
      select_types&lt;int, string&gt;(b)),<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [](int i, int j )<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { ... },<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [](auto const &amp;i, auto const &amp;j ) // there is at
      least a string in a and b<br>
    </font><font size="+1"><font size="+1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { ... },<br>
      </font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; [](...) // there is no int nor string in a and b<br>
    </font><font size="+1"><font size="+1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { ... }<br>
      </font>&nbsp;&nbsp;&nbsp; );<br>
      <br>
      Any comments are welcome,<br>
      Vicente<br>
    </font>
  </body>
</html>

<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 email to <a href="mailto:std-proposals+unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href="mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />

--------------010900070900060909050804--

.


Author: Scott Prager <splinterofchaos@gmail.com>
Date: Fri, 28 Nov 2014 20:38:28 -0800 (PST)
Raw View
------=_Part_8300_89678546.1417235908488
Content-Type: multipart/alternative;
 boundary="----=_Part_8301_1841286075.1417235908488"

------=_Part_8301_1841286075.1417235908488
Content-Type: text/plain; charset=UTF-8



On Sunday, November 16, 2014 9:07:42 AM UTC-5, Vicente J. Botet Escriba
wrote:
>
>  Hi,
>
>
> In n3418 (
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3418.pdf) there
> is an example of a overload function that I find quite useful. You can
> found a variadic implementation at
> https://github.com/JasonL9000/cppcon14/blob/master/variant.h#L114.
>
> Is there an interest for such functionality in the standard?
>

Looks I'm the only one to respond in a week. :(

Personally, I would like to see this, among other functional programming
utilities, in the standard, but it doesn't work for regular functions. It
can be done more generically, just that implementation only needed to work
for lambdas.




--

---
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_8301_1841286075.1417235908488
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Sunday, November 16, 2014 9:07:42 AM UTC-5, Vic=
ente J. Botet Escriba wrote:<blockquote class=3D"gmail_quote" style=3D"marg=
in: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
 =20

   =20
 =20
  <div bgcolor=3D"#FFFFFF" text=3D"#000000">
    <font size=3D"+1">Hi,<br>
      <br>
      <br>
      In n3418
      (<a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n=
3418.pdf" target=3D"_blank" onmousedown=3D"this.href=3D'http://www.google.c=
om/url?q\75http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpape=
rs%2F2012%2Fn3418.pdf\46sa\75D\46sntz\0751\46usg\75AFQjCNFOviG5A2DE-CYn41vA=
T6qvA0yJMw';return true;" onclick=3D"this.href=3D'http://www.google.com/url=
?q\75http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2=
012%2Fn3418.pdf\46sa\75D\46sntz\0751\46usg\75AFQjCNFOviG5A2DE-CYn41vAT6qvA0=
yJMw';return true;">http://www.open-std.org/jtc1/<wbr>sc22/wg21/docs/papers=
/2012/<wbr>n3418.pdf</a>)
      there is an example of a overload function that I find quite
      useful. You can found a variadic implementation at&nbsp;
      <a href=3D"https://github.com/JasonL9000/cppcon14/blob/master/variant=
..h#L114" target=3D"_blank" onmousedown=3D"this.href=3D'https://www.google.c=
om/url?q\75https%3A%2F%2Fgithub.com%2FJasonL9000%2Fcppcon14%2Fblob%2Fmaster=
%2Fvariant.h%23L114\46sa\75D\46sntz\0751\46usg\75AFQjCNEEwlgUUN976w3A1sqkOk=
bAWLJI2w';return true;" onclick=3D"this.href=3D'https://www.google.com/url?=
q\75https%3A%2F%2Fgithub.com%2FJasonL9000%2Fcppcon14%2Fblob%2Fmaster%2Fvari=
ant.h%23L114\46sa\75D\46sntz\0751\46usg\75AFQjCNEEwlgUUN976w3A1sqkOkbAWLJI2=
w';return true;">https://github.com/JasonL9000/<wbr>cppcon14/blob/master/va=
riant.<wbr>h#L114</a>.<br>
      <br>
      Is there an interest for such functionality in the standard?<br></fon=
t></div></blockquote><div><br></div><div>Looks I'm the only one to respond =
in a week. :(<br></div><div><br></div><div>Personally, I would like to see =
this, among other functional programming utilities, in the standard, but it=
 doesn't work for regular functions. It can be done more generically, just =
that implementation only needed to work for lambdas.</div><div><br></div><d=
iv><br></div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div bgcolor=3D"#=
FFFFFF" text=3D"#000000">
  </div>

</blockquote></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_8301_1841286075.1417235908488--
------=_Part_8300_89678546.1417235908488--

.


Author: David Krauss <potswa@gmail.com>
Date: Sat, 29 Nov 2014 13:29:09 +0800
Raw View
--Apple-Mail=_7AEE9E12-1754-4601-AA71-EC82EE5D26C4
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


On 2014=E2=80=9311=E2=80=9316, at 10:07 PM, Vicente J. Botet Escriba <vicen=
te.botet@wanadoo.fr> wrote:

> https://github.com/JasonL9000/cppcon14/blob/master/variant.h#L114.
>=20
> Is there an interest for such functionality in the standard?

I=E2=80=99ve been using a similar utility for a while ( https://code.google=
..com/p/c-plus/source/browse/src/util.h#133 ), but not with dynamic visitati=
on. It=E2=80=99s pretty straightforward after you get over the difficulty o=
f the using declarations=E2=80=A6 we really need a pack expansion form for =
that.

There=E2=80=99s an =E2=80=9Coverload factory=E2=80=9D which aggregates any =
functors (in practice, usually lambdas or std::functions), and an alias tem=
plate to the case of aggregated std::functions. I wonder if the latter case=
 could be optimized, to use a single vtable as long as it=E2=80=99s initial=
ized directly from lambdas or such. The entire overload object should be on=
ly as big as a std::function when possible. Also, it would be nice to dispa=
tch multiple call signatures to a single component functor. (Otherwise, ove=
rload objects can=E2=80=99t be further composed after creation.)

I=E2=80=99m not sure that always specifying a common return type is a good =
idea. The dynamic visitation code might find a common type automatically, o=
r it might be specified to a visitation-oriented subclass. But there are go=
ing to be cases where the user just wants an overload set with unrelated re=
turn types.

--=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/.

--Apple-Mail=_7AEE9E12-1754-4601-AA71-EC82EE5D26C4
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014=
=E2=80=9311=E2=80=9316, at 10:07 PM, Vicente J. Botet Escriba &lt;<a href=
=3D"mailto:vicente.botet@wanadoo.fr">vicente.botet@wanadoo.fr</a>&gt; wrote=
:</div><br class=3D"Apple-interchange-newline"><blockquote type=3D"cite"><a=
 class=3D"moz-txt-link-freetext" href=3D"https://github.com/JasonL9000/cppc=
on14/blob/master/variant.h#L114" style=3D"font-family: Helvetica; font-size=
: large; font-style: normal; font-variant: normal; font-weight: normal; let=
ter-spacing: normal; line-height: normal; orphans: auto; text-align: start;=
 text-indent: 0px; text-transform: none; white-space: normal; widows: auto;=
 word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(2=
55, 255, 255);">https://github.com/JasonL9000/cppcon14/blob/master/variant.=
h#L114</a><span style=3D"font-family: Helvetica; font-size: large; font-sty=
le: normal; font-variant: normal; font-weight: normal; letter-spacing: norm=
al; line-height: normal; orphans: auto; text-align: start; text-indent: 0px=
; text-transform: none; white-space: normal; widows: auto; word-spacing: 0p=
x; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); fl=
oat: none; display: inline !important;">.</span><br style=3D"font-family: H=
elvetica; font-size: large; font-style: normal; font-variant: normal; font-=
weight: normal; letter-spacing: normal; line-height: normal; orphans: auto;=
 text-align: start; text-indent: 0px; text-transform: none; white-space: no=
rmal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; back=
ground-color: rgb(255, 255, 255);"><br style=3D"font-family: Helvetica; fon=
t-size: large; font-style: normal; font-variant: normal; font-weight: norma=
l; letter-spacing: normal; line-height: normal; orphans: auto; text-align: =
start; text-indent: 0px; text-transform: none; white-space: normal; widows:=
 auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color:=
 rgb(255, 255, 255);"><span style=3D"font-family: Helvetica; font-size: lar=
ge; font-style: normal; font-variant: normal; font-weight: normal; letter-s=
pacing: normal; line-height: normal; orphans: auto; text-align: start; text=
-indent: 0px; text-transform: none; white-space: normal; widows: auto; word=
-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 2=
55, 255); float: none; display: inline !important;">Is there an interest fo=
r such functionality in the standard?</span><br style=3D"font-family: Helve=
tica; font-size: large; font-style: normal; font-variant: normal; font-weig=
ht: normal; letter-spacing: normal; line-height: normal; orphans: auto; tex=
t-align: start; text-indent: 0px; text-transform: none; white-space: normal=
; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; backgrou=
nd-color: rgb(255, 255, 255);"></blockquote></div><br><div>I=E2=80=99ve bee=
n using a similar utility for a while ( <a href=3D"https://code.google.com/=
p/c-plus/source/browse/src/util.h#133">https://code.google.com/p/c-plus/sou=
rce/browse/src/util.h#133</a> ), but not with dynamic visitation. It=E2=80=
=99s pretty straightforward after you get over the difficulty of the <font =
face=3D"Courier">using</font> declarations=E2=80=A6 we really need a pack e=
xpansion form for that.</div><div><br></div><div>There=E2=80=99s an =E2=80=
=9Coverload factory=E2=80=9D which aggregates any functors (in practice, us=
ually lambdas or&nbsp;<span style=3D"font-family: Courier;">std::function</=
span>s), and an alias template to the case of aggregated <font face=3D"Cour=
ier">std::function</font>s. I wonder if the latter case could be optimized,=
 to use a single vtable as long as it=E2=80=99s initialized directly from l=
ambdas or such. The entire overload object should be only as big as a <font=
 face=3D"Courier">std::function</font> when possible. Also, it would be nic=
e to dispatch multiple call signatures to a single component functor. (Othe=
rwise, overload objects can=E2=80=99t be further composed after creation.)<=
/div><div><br></div><div>I=E2=80=99m not sure that always specifying a comm=
on return type is a good idea. The dynamic visitation code might find a com=
mon type automatically, or it might be specified to a visitation-oriented s=
ubclass. But there are going to be cases where the user just wants an overl=
oad set with unrelated return types.</div></body></html>

<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 />

--Apple-Mail=_7AEE9E12-1754-4601-AA71-EC82EE5D26C4--

.


Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Sat, 29 Nov 2014 09:32:16 +0100
Raw View
This is a multi-part message in MIME format.
--------------000905030101000706060501
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 29/11/14 05:38, Scott Prager a =C3=A9crit :
>
>
> On Sunday, November 16, 2014 9:07:42 AM UTC-5, Vicente J. Botet=20
> Escriba wrote:
>
>     Hi,
>
>
>     In n3418
>     (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3418.pdf
>     <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3418.pdf>)
>     there is an example of a overload function that I find quite
>     useful. You can found a variadic implementation at
>     https://github.com/JasonL9000/cppcon14/blob/master/variant.h#L114
>     <https://github.com/JasonL9000/cppcon14/blob/master/variant.h#L114>.
>
>     Is there an interest for such functionality in the standard?
>
>
> Looks I'm the only one to respond in a week. :(
>
  :(
> Personally, I would like to see this, among other functional=20
> programming utilities, in the standard, but it doesn't work for=20
> regular functions. It can be done more generically, just that=20
> implementation only needed to work for lambdas.
>
>
I'm sure we will be able to overcome this technical difficulties.
Do you have a link to an implementation that works with regular functions?

Best,
Vicente

--=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/.

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

<html>
  <head>
    <meta content=3D"text/html; charset=3DUTF-8" http-equiv=3D"Content-Type=
">
  </head>
  <body bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">Le 29/11/14 05:38, Scott Prager a
      =C3=A9crit=C2=A0:<br>
    </div>
    <blockquote
      cite=3D"mid:a0c8e99c-a52f-4a23-a765-23e0bac754af@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr"><br>
        <br>
        On Sunday, November 16, 2014 9:07:42 AM UTC-5, Vicente J. Botet
        Escriba wrote:
        <blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:
          0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
          <div bgcolor=3D"#FFFFFF" text=3D"#000000"> <font size=3D"+1">Hi,<=
br>
              <br>
              <br>
              In n3418 (<a moz-do-not-send=3D"true"
                href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/=
2012/n3418.pdf"
                target=3D"_blank"
                onmousedown=3D"this.href=3D'http://www.google.com/url?q\75h=
ttp%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2012%2F=
n3418.pdf\46sa\75D\46sntz\0751\46usg\75AFQjCNFOviG5A2DE-CYn41vAT6qvA0yJMw';=
return
                true;"
                onclick=3D"this.href=3D'http://www.google.com/url?q\75http%=
3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2012%2Fn341=
8.pdf\46sa\75D\46sntz\0751\46usg\75AFQjCNFOviG5A2DE-CYn41vAT6qvA0yJMw';retu=
rn
                true;">http://www.open-std.org/jtc1/<wbr>sc22/wg21/docs/pap=
ers/2012/<wbr>n3418.pdf</a>)
              there is an example of a overload function that I find
              quite useful. You can found a variadic implementation at=C2=
=A0
              <a moz-do-not-send=3D"true"
                href=3D"https://github.com/JasonL9000/cppcon14/blob/master/=
variant.h#L114"
                target=3D"_blank"
                onmousedown=3D"this.href=3D'https://www.google.com/url?q\75=
https%3A%2F%2Fgithub.com%2FJasonL9000%2Fcppcon14%2Fblob%2Fmaster%2Fvariant.=
h%23L114\46sa\75D\46sntz\0751\46usg\75AFQjCNEEwlgUUN976w3A1sqkOkbAWLJI2w';r=
eturn
                true;"
                onclick=3D"this.href=3D'https://www.google.com/url?q\75http=
s%3A%2F%2Fgithub.com%2FJasonL9000%2Fcppcon14%2Fblob%2Fmaster%2Fvariant.h%23=
L114\46sa\75D\46sntz\0751\46usg\75AFQjCNEEwlgUUN976w3A1sqkOkbAWLJI2w';retur=
n
                true;">https://github.com/JasonL9000/<wbr>cppcon14/blob/mas=
ter/variant.<wbr>h#L114</a>.<br>
              <br>
              Is there an interest for such functionality in the
              standard?<br>
            </font></div>
        </blockquote>
        <div><br>
        </div>
        <div>Looks I'm the only one to respond in a week. :(<br>
        </div>
        <div><br>
        </div>
      </div>
    </blockquote>
    =C2=A0:(<br>
    <blockquote
      cite=3D"mid:a0c8e99c-a52f-4a23-a765-23e0bac754af@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr">
        <div>Personally, I would like to see this, among other
          functional programming utilities, in the standard, but it
          doesn't work for regular functions. It can be done more
          generically, just that implementation only needed to work for
          lambdas.</div>
        <div><br>
        </div>
        <div><br>
        </div>
      </div>
    </blockquote>
    I'm sure we will be able to overcome this technical difficulties. <br>
    Do you have a link to an implementation that works with regular
    functions?<br>
    <br>
    Best,<br>
    Vicente<br>
  </body>
</html>

<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 />

--------------000905030101000706060501--

.


Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Sat, 29 Nov 2014 10:12:56 +0100
Raw View
This is a multi-part message in MIME format.
--------------070504030102020109060706
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 29/11/14 06:29, David Krauss a =C3=A9crit :
>
> On 2014=E2=80=9311=E2=80=9316, at 10:07 PM, Vicente J. Botet Escriba=20
> <vicente.botet@wanadoo.fr <mailto:vicente.botet@wanadoo.fr>> wrote:
>
>> https://github.com/JasonL9000/cppcon14/blob/master/variant.h#L114.
>>
>> Is there an interest for such functionality in the standard?
>
> I=E2=80=99ve been using a similar utility for a while (=20
> https://code.google.com/p/c-plus/source/browse/src/util.h#133 ), but=20
> not with dynamic visitation. It=E2=80=99s pretty straightforward after yo=
u get=20
> over the difficulty of the using declarations=E2=80=A6 we really need a p=
ack=20
> expansion form for that.
Please, could you elaborate?
>
> There=E2=80=99s an =E2=80=9Coverload factory=E2=80=9D which aggregates an=
y functors (in=20
> practice, usually lambdas or std::functions), and an alias template to=20
> the case of aggregated std::functions. I wonder if the latter case=20
> could be optimized, to use a single vtable as long as it=E2=80=99s initia=
lized=20
> directly from lambdas or such. The entire overload object should be=20
> only as big as a std::function when possible. Also, it would be nice=20
> to dispatch multiple call signatures to a single component functor.=20
> (Otherwise, overload objects can=E2=80=99t be further composed after crea=
tion.)
What do you mean by "dispatch multiple call signatures". Could you=20
elaborate on how they do not compose?
>
> I=E2=80=99m not sure that always specifying a common return type is a goo=
d=20
> idea. The dynamic visitation code might find a common type=20
> automatically, or it might be specified to a visitation-oriented=20
> subclass. But there are going to be cases where the user just wants an=20
> overload set with unrelated return types.

Completely agree.

The less constrained  case would need to return a variant of the results.

     auto x =3D match_ret_variant(a),
         [](int i)        { return A{}; },
         [](string s)        { return  B{}; },
     );

The type of x would be variant<A, B>

We could always try to see if there is a common_type.

     auto x =3D match_ret_common_type(a),
         [](int i)         { return A{}; },
         [](string s)        { return  B{}; },
     );

The type of x would be common_type<A, B>

This alternative could be built on top of the less constrained=20
alternative match_ret_variant

     auto x =3D to_common_type(match_ret_variant(a),
         [](int i)         { return A{}; },
         [](string s)        { return  B{}; },
     ));

but it would be less efficient than the the direct one.

Forcing a conversion to a result would be also useful.

     auto x =3D match_ret<C>(a),
         [](int i)        { return A{}; },
         [](string s)        { return  B{}; },
     );

The type of x would be C and the statement is well formed if A and B are=20
explicitly convertible to C.

The last one can be used also as

     auto x =3D match_ret<common_type<A,B>>(a),
         [](int i)        { return A{}; },
         [](string s)        { return  B{}; },
     );

and

     auto x =3D match_ret<variant<A,B>>(a),
         [](int i)        { return A{}; },
         [](string s)        { return  B{}; },
     );


Of course we need better names for each match alternative. I would=20
preserve match for the common_type overload as it should be the common case=
..

I would like to see builtin product/sum types with pattern matching in=20
C++2x, but waiting for that we could already have a library solution for=20
some specific cases. The question is if it is worth working on this now.

Vicente

--=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/.

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

<html>
  <head>
    <meta content=3D"text/html; charset=3DUTF-8" http-equiv=3D"Content-Type=
">
  </head>
  <body bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">Le 29/11/14 06:29, David Krauss a
      =C3=A9crit=C2=A0:<br>
    </div>
    <blockquote
      cite=3D"mid:167575B2-E6FE-454A-9F77-303178A636F9@gmail.com"
      type=3D"cite">
      <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DUTF=
-8">
      <br>
      <div>
        <div>On 2014=E2=80=9311=E2=80=9316, at 10:07 PM, Vicente J. Botet E=
scriba &lt;<a
            moz-do-not-send=3D"true"
            href=3D"mailto:vicente.botet@wanadoo.fr">vicente.botet@wanadoo.=
fr</a>&gt;
          wrote:</div>
        <br class=3D"Apple-interchange-newline">
        <blockquote type=3D"cite"><a moz-do-not-send=3D"true"
            class=3D"moz-txt-link-freetext"
            href=3D"https://github.com/JasonL9000/cppcon14/blob/master/vari=
ant.h#L114"
            style=3D"font-family: Helvetica; font-size: large; font-style:
            normal; font-variant: normal; font-weight: normal;
            letter-spacing: normal; line-height: normal; orphans: auto;
            text-align: start; text-indent: 0px; text-transform: none;
            white-space: normal; widows: auto; word-spacing: 0px;
            -webkit-text-stroke-width: 0px; background-color: rgb(255,
            255, 255);">https://github.com/JasonL9000/cppcon14/blob/master/=
variant.h#L114</a><span
            style=3D"font-family: Helvetica; font-size: large; font-style:
            normal; font-variant: normal; font-weight: normal;
            letter-spacing: normal; line-height: normal; orphans: auto;
            text-align: start; text-indent: 0px; text-transform: none;
            white-space: normal; widows: auto; word-spacing: 0px;
            -webkit-text-stroke-width: 0px; background-color: rgb(255,
            255, 255); float: none; display: inline !important;">.</span><b=
r
            style=3D"font-family: Helvetica; font-size: large; font-style:
            normal; font-variant: normal; font-weight: normal;
            letter-spacing: normal; line-height: normal; orphans: auto;
            text-align: start; text-indent: 0px; text-transform: none;
            white-space: normal; widows: auto; word-spacing: 0px;
            -webkit-text-stroke-width: 0px; background-color: rgb(255,
            255, 255);">
          <br style=3D"font-family: Helvetica; font-size: large;
            font-style: normal; font-variant: normal; font-weight:
            normal; letter-spacing: normal; line-height: normal;
            orphans: auto; text-align: start; text-indent: 0px;
            text-transform: none; white-space: normal; widows: auto;
            word-spacing: 0px; -webkit-text-stroke-width: 0px;
            background-color: rgb(255, 255, 255);">
          <span style=3D"font-family: Helvetica; font-size: large;
            font-style: normal; font-variant: normal; font-weight:
            normal; letter-spacing: normal; line-height: normal;
            orphans: auto; text-align: start; text-indent: 0px;
            text-transform: none; white-space: normal; widows: auto;
            word-spacing: 0px; -webkit-text-stroke-width: 0px;
            background-color: rgb(255, 255, 255); float: none; display:
            inline !important;">Is there an interest for such
            functionality in the standard?</span><br style=3D"font-family:
            Helvetica; font-size: large; font-style: normal;
            font-variant: normal; font-weight: normal; letter-spacing:
            normal; line-height: normal; orphans: auto; text-align:
            start; text-indent: 0px; text-transform: none; white-space:
            normal; widows: auto; word-spacing: 0px;
            -webkit-text-stroke-width: 0px; background-color: rgb(255,
            255, 255);">
        </blockquote>
      </div>
      <br>
      <div>I=E2=80=99ve been using a similar utility for a while ( <a
          moz-do-not-send=3D"true"
          href=3D"https://code.google.com/p/c-plus/source/browse/src/util.h=
#133">https://code.google.com/p/c-plus/source/browse/src/util.h#133</a>
        ), but not with dynamic visitation. It=E2=80=99s pretty straightfor=
ward
        after you get over the difficulty of the <font face=3D"Courier">usi=
ng</font>
        declarations=E2=80=A6 we really need a pack expansion form for that=
..</div>
    </blockquote>
    Please, could you elaborate?<br>
    <blockquote
      cite=3D"mid:167575B2-E6FE-454A-9F77-303178A636F9@gmail.com"
      type=3D"cite">
      <div><br>
      </div>
      <div>There=E2=80=99s an =E2=80=9Coverload factory=E2=80=9D which aggr=
egates any functors
        (in practice, usually lambdas or=C2=A0<span style=3D"font-family:
          Courier;">std::function</span>s), and an alias template to the
        case of aggregated <font face=3D"Courier">std::function</font>s.
        I wonder if the latter case could be optimized, to use a single
        vtable as long as it=E2=80=99s initialized directly from lambdas or
        such. The entire overload object should be only as big as a <font
          face=3D"Courier">std::function</font> when possible. Also, it
        would be nice to dispatch multiple call signatures to a single
        component functor. (Otherwise, overload objects can=E2=80=99t be fu=
rther
        composed after creation.)</div>
    </blockquote>
    What do you mean by "dispatch multiple call signatures". Could you
    elaborate on how they do not compose?<br>
    <blockquote
      cite=3D"mid:167575B2-E6FE-454A-9F77-303178A636F9@gmail.com"
      type=3D"cite">
      <div><br>
      </div>
      <div>I=E2=80=99m not sure that always specifying a common return type=
 is a
        good idea. The dynamic visitation code might find a common type
        automatically, or it might be specified to a visitation-oriented
        subclass. But there are going to be cases where the user just
        wants an overload set with unrelated return types.</div>
    </blockquote>
    <br>
    Completely agree. <br>
    <br>
    The less constrained=C2=A0 case would need to return a variant of the
    results. <br>
    <br>
    <font size=3D"+1"><font size=3D"+1"> =C2=A0=C2=A0=C2=A0 auto x =3D matc=
h_ret_variant(a),<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 [](int i)=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 { return A{}; },<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 [](string s</font></font=
><font size=3D"+1"><font size=3D"+1">
        )</font><font size=3D"+1"><font size=3D"+1">=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 { return=C2=A0 B{};
          },<br>
        </font></font><font size=3D"+1">=C2=A0=C2=A0=C2=A0 );<br>
        <br>
        The type of x would be variant&lt;A, B&gt;<br>
        <br>
      </font></font>We could always try to see if there is a
    common_type.<br>
    <br>
    <font size=3D"+1"><font size=3D"+1"> =C2=A0=C2=A0=C2=A0 auto x =3D
        match_ret_common_type(a),<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 [](int i) =C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { return A{}; },<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 [](string s</font></font=
><font size=3D"+1"><font size=3D"+1">
        )</font><font size=3D"+1"><font size=3D"+1">=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 { return=C2=A0 B{};
          },<br>
        </font></font><font size=3D"+1">=C2=A0=C2=A0=C2=A0 );<br>
      </font></font><br>
    <font size=3D"+1"><font size=3D"+1">The type of x would be
        common_type&lt;A, B&gt;<br>
      </font></font><br>
    This alternative could be built on top of the less constrained
    alternative <font size=3D"+1"><font size=3D"+1">match_ret_variant</font=
></font><br>
    <br>
    <font size=3D"+1"><font size=3D"+1"> =C2=A0=C2=A0=C2=A0 auto x =3D
        to_common_type(match_ret_variant(a),<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 [](int i) =C2=A0=C2=A0=
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 { return A{}; },<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 [](string s</font></font=
><font size=3D"+1"><font size=3D"+1">
        )</font><font size=3D"+1"><font size=3D"+1">=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 { return=C2=A0 B{};
          },<br>
        </font></font><font size=3D"+1">=C2=A0=C2=A0=C2=A0 ));<br>
      </font></font><br>
    but it would be less efficient than the the direct one.<br>
    <br>
    Forcing a conversion to a result would be also useful.<br>
    <br>
    <font size=3D"+1"><font size=3D"+1">=C2=A0=C2=A0=C2=A0 auto x =3D match=
_ret&lt;C&gt;(a),<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 [](int i)=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 { return A{}; },<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 [](string s</font></font=
><font size=3D"+1"><font size=3D"+1">
        )</font><font size=3D"+1"><font size=3D"+1">=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 { return=C2=A0 B{};
          },<br>
        </font></font><font size=3D"+1">=C2=A0=C2=A0=C2=A0 );<br>
      </font></font><br>
    <font size=3D"+1"><font size=3D"+1">The type of x would be C and the
        statement is well formed if </font></font><font size=3D"+1"><font
        size=3D"+1">A and B are explicitly convertible to C</font></font>.<=
br>
    <br>
    The last one can be used also as<br>
    <br>
    <font size=3D"+1"><font size=3D"+1">=C2=A0=C2=A0=C2=A0 auto x =3D
        match_ret&lt;common_type&lt;A,B&gt;&gt;(a),<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 [](int i)=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 { return A{}; },<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 [](string s</font></font=
><font size=3D"+1"><font size=3D"+1">
        )</font><font size=3D"+1"><font size=3D"+1">=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 { return=C2=A0 B{};
          },<br>
        </font></font><font size=3D"+1">=C2=A0=C2=A0=C2=A0 );<br>
      </font></font><br>
    and<br>
    <br>
    <font size=3D"+1"><font size=3D"+1">=C2=A0=C2=A0=C2=A0 auto x =3D
        match_ret&lt;variant&lt;A,B&gt;&gt;(a),<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 [](int i)=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0 { return A{}; },<br>
        =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 [](string s</font></font=
><font size=3D"+1"><font size=3D"+1">
        )</font><font size=3D"+1"><font size=3D"+1">=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0 { return=C2=A0 B{};
          },<br>
        </font></font><font size=3D"+1">=C2=A0=C2=A0=C2=A0 );<br>
      </font></font><br>
    <br>
    Of course we need better names for each match alternative. I would
    preserve match for the common_type overload as it should be the
    common case.<br>
    <br>
    I would like to see builtin product/sum types with pattern matching
    in C++2x, but waiting for that we could already have a library
    solution for some specific cases. The question is if it is worth
    working on this now.<br>
    <br>
    Vicente<br>
    <br>
  </body>
</html>

<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 />

--------------070504030102020109060706--

.


Author: David Krauss <potswa@gmail.com>
Date: Sat, 29 Nov 2014 17:48:34 +0800
Raw View
--Apple-Mail=_8257E8AD-7229-4B56-AB78-758318E85088
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


On 2014=E2=80=9311=E2=80=9329, at 5:12 PM, Vicente J. Botet Escriba <vicent=
e.botet@wanadoo.fr> wrote:

> Le 29/11/14 06:29, David Krauss a =C3=A9crit :
>>=20
>> I=E2=80=99ve been using a similar utility for a while ( https://code.goo=
gle.com/p/c-plus/source/browse/src/util.h#133 ), but not with dynamic visit=
ation. It=E2=80=99s pretty straightforward after you get over the difficult=
y of the using declarations=E2=80=A6 we really need a pack expansion form f=
or that.
> Please, could you elaborate?

The implementations both jump through hoops to form a chain of N derived cl=
asses for the N overloads, each of which includes a using base::operator ()=
; declaration. It would be better to do that with one class derived from a =
pack expansion, with a using base::operator (); ... declaration, with base =
being a pack and the ellipsis expanding it.

> What do you mean by "dispatch multiple call signatures". Could you elabor=
ate on how they do not compose?

Ah, actually they do. I misidentified the problem, sorry.

For a dynamically-dispatched overload object, it would be nice to specify t=
he list of overload signatures in the template argument list, but initializ=
e it from an arbitrary set of objects covering the signatures. My current s=
olution aggregates separate std::function objects, which loses some efficie=
ncy.

Perhaps there should really be two interfaces, one for an amalgamation of f=
unctors (including lambdas) typically used for static dispatch, and one whi=
ch is a super-std::function always performing dynamic dispatch. Perhaps the=
 latter could be shoehorned into the existing std::function template.

> I would like to see builtin product/sum types with pattern matching in C+=
+2x, but waiting for that we could already have a library solution for some=
 specific cases. The question is if it is worth working on this now.

Overload-set functors seem to be more fundamental than visitors and pattern=
-matching. Maybe that piece should be bitten off first?

--=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/.

--Apple-Mail=_8257E8AD-7229-4B56-AB78-758318E85088
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014=
=E2=80=9311=E2=80=9329, at 5:12 PM, Vicente J. Botet Escriba &lt;<a href=3D=
"mailto:vicente.botet@wanadoo.fr">vicente.botet@wanadoo.fr</a>&gt; wrote:</=
div><br class=3D"Apple-interchange-newline"><blockquote type=3D"cite">
 =20
    <meta content=3D"text/html; charset=3DUTF-8" http-equiv=3D"Content-Type=
">
 =20
  <div bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">Le 29/11/14 06:29, David Krauss a
      =C3=A9crit&nbsp;:<br>
    </div>
    <blockquote cite=3D"mid:167575B2-E6FE-454A-9F77-303178A636F9@gmail.com"=
 type=3D"cite">
      <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DUTF=
-8">
      <br>
      <div>
        <div>I=E2=80=99ve been using a similar utility for a while ( <a moz=
-do-not-send=3D"true" href=3D"https://code.google.com/p/c-plus/source/brows=
e/src/util.h#133">https://code.google.com/p/c-plus/source/browse/src/util.h=
#133</a>
        ), but not with dynamic visitation. It=E2=80=99s pretty straightfor=
ward
        after you get over the difficulty of the <font face=3D"Courier">usi=
ng</font>
        declarations=E2=80=A6 we really need a pack expansion form for that=
..</div></div>
    </blockquote>
    Please, could you elaborate?<br></div></blockquote><div><br></div><div>=
The implementations both jump through hoops to form a chain of N derived cl=
asses for the N overloads, each of which includes a <font face=3D"Courier">=
using base::operator ();</font> declaration. It would be better to do that =
with one class derived from a pack expansion, with a <font face=3D"Courier"=
>using base::operator (); ...</font> declaration, with <font face=3D"Courie=
r">base</font> being a pack and the ellipsis expanding it.</div><br><blockq=
uote type=3D"cite"><div bgcolor=3D"#FFFFFF" text=3D"#000000">
    What do you mean by "dispatch multiple call signatures". Could you
    elaborate on how they do not compose?<br></div></blockquote><div><br></=
div><div>Ah, actually they do. I misidentified the problem, sorry.</div><di=
v><br></div><div>For a dynamically-dispatched overload object, it would be =
nice to specify the list of overload signatures in the template argument li=
st, but initialize it from an arbitrary set of objects covering the signatu=
res. My current solution aggregates separate <font face=3D"Courier">std::fu=
nction</font> objects, which loses some efficiency.</div><div><br></div><di=
v>Perhaps there should really be two interfaces, one for an amalgamation of=
 functors (including lambdas) typically used for static dispatch, and one w=
hich is a super-<font face=3D"Courier">std::function</font>&nbsp;always per=
forming dynamic dispatch. Perhaps the latter could be shoehorned into the e=
xisting <font face=3D"Courier">std::function</font> template.</div><div><br=
></div><blockquote type=3D"cite"><div bgcolor=3D"#FFFFFF" text=3D"#000000">
    I would like to see builtin product/sum types with pattern matching
    in C++2x, but waiting for that we could already have a library
    solution for some specific cases. The question is if it is worth
    working on this now.<br></div></blockquote><br></div><div>Overload-set =
functors seem to be more fundamental than visitors and pattern-matching. Ma=
ybe that piece should be bitten off first?</div></body></html>

<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 />

--Apple-Mail=_8257E8AD-7229-4B56-AB78-758318E85088--

.


Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Sat, 29 Nov 2014 12:25:28 +0100
Raw View
This is a multi-part message in MIME format.
--------------070303020304010109020003
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 29/11/14 10:48, David Krauss a =C3=A9crit :
>
> On 2014=E2=80=9311=E2=80=9329, at 5:12 PM, Vicente J. Botet Escriba=20
> <vicente.botet@wanadoo.fr <mailto:vicente.botet@wanadoo.fr>> wrote:
>
>> Le 29/11/14 06:29, David Krauss a =C3=A9crit :
>>>
>>> I=E2=80=99ve been using a similar utility for a while (=20
>>> https://code.google.com/p/c-plus/source/browse/src/util.h#133 ), but=20
>>> not with dynamic visitation. It=E2=80=99s pretty straightforward after =
you=20
>>> get over the difficulty of the using declarations=E2=80=A6 we really ne=
ed a=20
>>> pack expansion form for that.
>> Please, could you elaborate?
>
> The implementations both jump through hoops to form a chain of N=20
> derived classes for the N overloads, each of which includes a using=20
> base::operator (); declaration. It would be better to do that with one=20
> class derived from a pack expansion, with a using base::operator ();=20
> ... declaration, with base being a pack and the ellipsis expanding it.
A part from simplifying the implementation, would this using pack=20
expansion improve in something else?
>
>> What do you mean by "dispatch multiple call signatures". Could you=20
>> elaborate on how they do not compose?
>
> Ah, actually they do. I misidentified the problem, sorry.
>
> For a dynamically-dispatched overload object, it would be nice to=20
> specify the list of overload signatures in the template argument list,=20
> but initialize it from an arbitrary set of objects covering the=20
> signatures. My current solution aggregates separate std::function=20
> objects, which loses some efficiency.

Could you show some cases where given the list of overloaded signatures=20
would be beneficial?
>
> Perhaps there should really be two interfaces, one for an amalgamation=20
> of functors (including lambdas) typically used for static dispatch,=20
> and one which is a super-std::function always performing dynamic=20
> dispatch. Perhaps the latter could be shoehorned into the existing=20
> std::function template.
IIUC, you want a type-erased overloaded function, isn't it?
>
>> I would like to see builtin product/sum types with pattern matching=20
>> in C++2x, but waiting for that we could already have a library=20
>> solution for some specific cases. The question is if it is worth=20
>> working on this now.
>
> Overload-set functors seem to be more fundamental than visitors and=20
> pattern-matching. Maybe that piece should be bitten off first?
>
Agreed.
Vicente

--=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/.

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

<html>
  <head>
    <meta content=3D"text/html; charset=3DUTF-8" http-equiv=3D"Content-Type=
">
  </head>
  <body bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">Le 29/11/14 10:48, David Krauss a
      =C3=A9crit=C2=A0:<br>
    </div>
    <blockquote
      cite=3D"mid:651B9DD6-0EAF-47DA-B462-657508D2D569@gmail.com"
      type=3D"cite">
      <meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3DUTF=
-8">
      <br>
      <div>
        <div>On 2014=E2=80=9311=E2=80=9329, at 5:12 PM, Vicente J. Botet Es=
criba &lt;<a
            moz-do-not-send=3D"true"
            href=3D"mailto:vicente.botet@wanadoo.fr">vicente.botet@wanadoo.=
fr</a>&gt;
          wrote:</div>
        <br class=3D"Apple-interchange-newline">
        <blockquote type=3D"cite">
          <meta content=3D"text/html; charset=3DUTF-8"
            http-equiv=3D"Content-Type">
          <div bgcolor=3D"#FFFFFF" text=3D"#000000">
            <div class=3D"moz-cite-prefix">Le 29/11/14 06:29, David Krauss
              a =C3=A9crit=C2=A0:<br>
            </div>
            <blockquote
              cite=3D"mid:167575B2-E6FE-454A-9F77-303178A636F9@gmail.com"
              type=3D"cite">
              <meta http-equiv=3D"Content-Type" content=3D"text/html;
                charset=3DUTF-8">
              <br>
              <div>
                <div>I=E2=80=99ve been using a similar utility for a while =
( <a
                    moz-do-not-send=3D"true"
                    href=3D"https://code.google.com/p/c-plus/source/browse/=
src/util.h#133">https://code.google.com/p/c-plus/source/browse/src/util.h#1=
33</a>
                  ), but not with dynamic visitation. It=E2=80=99s pretty
                  straightforward after you get over the difficulty of
                  the <font face=3D"Courier">using</font> declarations=E2=
=80=A6
                  we really need a pack expansion form for that.</div>
              </div>
            </blockquote>
            Please, could you elaborate?<br>
          </div>
        </blockquote>
        <div><br>
        </div>
        <div>The implementations both jump through hoops to form a chain
          of N derived classes for the N overloads, each of which
          includes a <font face=3D"Courier">using base::operator ();</font>
          declaration. It would be better to do that with one class
          derived from a pack expansion, with a <font face=3D"Courier">usin=
g
            base::operator (); ...</font> declaration, with <font
            face=3D"Courier">base</font> being a pack and the ellipsis
          expanding it.</div>
      </div>
    </blockquote>
    A part from simplifying the implementation, would this using pack
    expansion improve in something else?<br>
    <blockquote
      cite=3D"mid:651B9DD6-0EAF-47DA-B462-657508D2D569@gmail.com"
      type=3D"cite">
      <div><br>
        <blockquote type=3D"cite">
          <div bgcolor=3D"#FFFFFF" text=3D"#000000"> What do you mean by
            "dispatch multiple call signatures". Could you elaborate on
            how they do not compose?<br>
          </div>
        </blockquote>
        <div><br>
        </div>
        <div>Ah, actually they do. I misidentified the problem, sorry.</div=
>
        <div><br>
        </div>
        <div>For a dynamically-dispatched overload object, it would be
          nice to specify the list of overload signatures in the
          template argument list, but initialize it from an arbitrary
          set of objects covering the signatures. My current solution
          aggregates separate <font face=3D"Courier">std::function</font>
          objects, which loses some efficiency.</div>
      </div>
    </blockquote>
    <br>
    Could you show some cases where given the list of overloaded
    signatures would be beneficial? <br>
    <blockquote
      cite=3D"mid:651B9DD6-0EAF-47DA-B462-657508D2D569@gmail.com"
      type=3D"cite">
      <div>
        <div><br>
        </div>
        <div>Perhaps there should really be two interfaces, one for an
          amalgamation of functors (including lambdas) typically used
          for static dispatch, and one which is a super-<font
            face=3D"Courier">std::function</font>=C2=A0always performing
          dynamic dispatch. Perhaps the latter could be shoehorned into
          the existing <font face=3D"Courier">std::function</font>
          template.</div>
      </div>
    </blockquote>
    IIUC, you want a type-erased overloaded function, isn't it?<br>
    <blockquote
      cite=3D"mid:651B9DD6-0EAF-47DA-B462-657508D2D569@gmail.com"
      type=3D"cite">
      <div>
        <div><br>
        </div>
        <blockquote type=3D"cite">
          <div bgcolor=3D"#FFFFFF" text=3D"#000000"> I would like to see
            builtin product/sum types with pattern matching in C++2x,
            but waiting for that we could already have a library
            solution for some specific cases. The question is if it is
            worth working on this now.<br>
          </div>
        </blockquote>
        <br>
      </div>
      <div>Overload-set functors seem to be more fundamental than
        visitors and pattern-matching. Maybe that piece should be bitten
        off first?</div>
      <br>
    </blockquote>
    Agreed. <br>
    Vicente<br>
  </body>
</html>

<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 />

--------------070303020304010109020003--

.


Author: David Krauss <potswa@gmail.com>
Date: Sat, 29 Nov 2014 23:35:13 +0800
Raw View
--Apple-Mail=_7B7F4B7A-033D-4F66-8C92-2342CCC220AB
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


On 2014=E2=80=9311=E2=80=9329, at 7:25 PM, Vicente J. Botet Escriba <vicent=
e.botet@wanadoo.fr> wrote:

> A part from simplifying the implementation, would this using pack expansi=
on improve in something else?

Besides operator(), it could also be useful for inheriting constructors. (M=
aybe.) When a set of base classes include implicit conversions, the using p=
ack expansion would provide a way to uniformly adjust their access qualific=
ations, e.g. private: using base::operator typename base::conversion_type; =
.... . The use cases are few, but the workaround is extremely inconvenient a=
nd nuanced.

The feature could be a tough sell; given that we=E2=80=99re capable of the =
workaround, I guess the library proposal might as well not mention it.

> Could you show some cases where given the list of overloaded signatures w=
ould be beneficial?

The use cases are the same as for std::function. A type-list of overload si=
gnatures captures the interface, but not the implementation. Plugging a dyn=
amic-dispatch overload functor into your visitor interface, the same visita=
tion specializations would work for different visitors without additional b=
loat.

> IIUC, you want a type-erased overloaded function, isn't it?

Right. My project uses both kinds. Type erasure is inserted strategically t=
o limit bloat. (Otherwise, the template recursion would be infinite!) But, =
I=E2=80=99m using a simplistic implementation, simply:

template< typename ... sig >
using function =3D amalgam_ftor< std::function< sig > ... >;

where amalgam_ftor is my equivalent to overload_t.

> Agreed.=20

Cool. I hope I can help more=E2=80=A6

--=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/.

--Apple-Mail=_7B7F4B7A-033D-4F66-8C92-2342CCC220AB
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014=
=E2=80=9311=E2=80=9329, at 7:25 PM, Vicente J. Botet Escriba &lt;<a href=3D=
"mailto:vicente.botet@wanadoo.fr">vicente.botet@wanadoo.fr</a>&gt; wrote:</=
div><br class=3D"Apple-interchange-newline"><blockquote type=3D"cite">
 =20
    <meta content=3D"text/html; charset=3DUTF-8" http-equiv=3D"Content-Type=
">
 =20
  <div bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">A part from simplifying the implementati=
on, would this using pack
    expansion improve in something else?</div></div></blockquote><div><br><=
/div><div>Besides <font face=3D"Courier">operator()</font>, it could also b=
e useful for inheriting constructors. (Maybe.) When a set of base classes i=
nclude implicit conversions, the using pack expansion would provide a way t=
o uniformly adjust their access qualifications, e.g. <font face=3D"Courier"=
>private: using base::operator typename base::conversion_type; ...</font> .=
 The use cases are few, but the workaround is extremely inconvenient and nu=
anced.</div><div><br></div><div>The feature could be a tough sell; given th=
at we=E2=80=99re capable of the workaround, I guess the library proposal mi=
ght as well not mention it.</div><br><blockquote type=3D"cite"><div bgcolor=
=3D"#FFFFFF" text=3D"#000000">
    Could you show some cases where given the list of overloaded
    signatures would be beneficial?<br></div></blockquote><div><br></div><d=
iv>The use cases are the same as for <font face=3D"Courier">std::function</=
font>. A type-list of overload signatures captures the interface, but not t=
he implementation. Plugging a dynamic-dispatch overload functor into your v=
isitor interface, the same visitation specializations would work for differ=
ent visitors without additional bloat.</div><br><blockquote type=3D"cite"><=
div bgcolor=3D"#FFFFFF" text=3D"#000000">
    IIUC, you want a type-erased overloaded function, isn't it?<br></div></=
blockquote><div><br></div><div>Right. My project uses both kinds. Type eras=
ure is inserted strategically to limit bloat. (Otherwise, the template recu=
rsion would be infinite!) But, I=E2=80=99m using a simplistic implementatio=
n, simply:</div><div><br></div><div><div><font face=3D"Courier">template&lt=
; typename ... sig &gt;</font></div><div><font face=3D"Courier">using funct=
ion =3D amalgam_ftor&lt; std::function&lt; sig &gt; ... &gt;;</font></div><=
div><br></div><div>where <font face=3D"Courier">amalgam_ftor</font> is my e=
quivalent to <font face=3D"Courier">overload_t</font>.</div><div><br></div>=
</div><blockquote type=3D"cite"><div bgcolor=3D"#FFFFFF" text=3D"#000000">
    Agreed. <br></div></blockquote><br></div><div>Cool. I hope I can help m=
ore=E2=80=A6</div></body></html>

<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 />

--Apple-Mail=_7B7F4B7A-033D-4F66-8C92-2342CCC220AB--

.


Author: Scott Prager <splinterofchaos@gmail.com>
Date: Sat, 29 Nov 2014 09:17:46 -0800 (PST)
Raw View
------=_Part_5466_829303875.1417281466584
Content-Type: multipart/alternative;
 boundary="----=_Part_5467_941358095.1417281466584"

------=_Part_5467_941358095.1417281466584
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



On Saturday, November 29, 2014 3:32:18 AM UTC-5, Vicente J. Botet Escriba=
=20
wrote:
>
>  Le 29/11/14 05:38, Scott Prager a =C3=A9crit :
>
>  Personally, I would like to see this, among other functional programming=
=20
> utilities, in the standard, but it doesn't work for regular functions. It=
=20
> can be done more generically, just that implementation only needed to wor=
k=20
> for lambdas.
>
> =20
>   I'm sure we will be able to overcome this technical difficulties.=20
> Do you have a link to an implementation that works with regular functions=
?
>
> Best,
> Vicente
>

Thought I had one, but I can't find it. Here's a rewrite.

    #include <iostream>
    #include <functional>

    template< class F > struct Forwarder : F {
      using F::operator();
      constexpr Forwarder(const F& f) : F(f) { }
    };

    template< class R, class ...X >=20
    struct Forwarder<R(X...)> {
        using type =3D R(*)(X...);
        type f;
    =20
        constexpr Forwarder(type f) : f(f) { }
    =20
        constexpr R operator () (X &&... x) const {
            return f(std::forward<X>(x)...);
        }
    };

    template<class R, class O, class...X>
    struct Forwarder<R(O::*)(X...)> :=20
Forwarder<decltype(std::mem_fn(std::declval<R(O::*)(X...)>()))> {
      using base =3D=20
Forwarder<decltype(std::mem_fn(std::declval<R(O::*)(X...)>()))>;
      using type =3D R(O::*)(X...);

      constexpr Forwarder(type f) : base(std::mem_fn(f)) { }
      using base::operator();
    };

    template< class F, class G >
    struct Overloaded : Forwarder<F>, Forwarder<G> {
      using Forwarder<F>::operator();
      using Forwarder<G>::operator();
      constexpr Overloaded( const F& f, const G& g )
        : Forwarder<F>(f), Forwarder<G>(g)
      {
      }
    };
    =20
    template< class F > F overload( F&& f ) {
        return std::forward<F>(f);
    }
    =20
    template< class F, class G, class ...H,
              class O1 =3D Overloaded<F,G> >=20
    auto overload( const F& f, const G& g, const H& ...h ) {
        return overload( O1(f,g), h... );
    }

    struct X {
      void f() { std::cout << "X::f" << std::endl; }
    };

    void f(std::string ) {
      std::cout << "string" << std::endl;
    }

    int main() {
      auto set =3D overload([](int ) { std::cout << "int" << std::endl; },
                          [](char) { std::cout << "char" << std::endl; },
                          f,
                          &X::f);
      set(0);
      set('x');
      set(std::string("x"));

      X x;
      set(x);
    }=20

Compiles fine with gcc 4.9. Doesn't work at all with the master branch of=
=20
clang.

--=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_5467_941358095.1417281466584
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Saturday, November 29, 2014 3:32:18 AM UTC-5, V=
icente J. Botet Escriba wrote:<blockquote class=3D"gmail_quote" style=3D"ma=
rgin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
 =20
   =20
 =20
  <div bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div>Le 29/11/14 05:38, Scott Prager a
      =C3=A9crit&nbsp;:</div>
    <blockquote type=3D"cite">
      <div dir=3D"ltr">
        <div>Personally, I would like to see this, among other
          functional programming utilities, in the standard, but it
          doesn't work for regular functions. It can be done more
          generically, just that implementation only needed to work for
          lambdas.</div>
        <div><br>
        </div>
        <div><br>
        </div>
      </div>
    </blockquote>
    I'm sure we will be able to overcome this technical difficulties. <br>
    Do you have a link to an implementation that works with regular
    functions?<br>
    <br>
    Best,<br>
    Vicente<br></div></blockquote><div><br></div><div>Thought I had one, bu=
t I can't find it. Here's a rewrite.</div><div><br></div><div>&nbsp; &nbsp;=
 #include &lt;iostream&gt;</div><div>&nbsp; &nbsp; #include &lt;functional&=
gt;</div><div><br></div><div>&nbsp; &nbsp; template&lt; class F &gt; struct=
 Forwarder : F {</div><div>&nbsp; &nbsp; &nbsp; using F::operator();</div><=
div>&nbsp; &nbsp; &nbsp; constexpr Forwarder(const F&amp; f) : F(f) { }</di=
v><div>&nbsp; &nbsp; };</div><div><br></div><div>&nbsp; &nbsp; template&lt;=
 class R, class ...X &gt;&nbsp;</div><div>&nbsp; &nbsp; struct Forwarder&lt=
;R(X...)&gt; {</div><div>&nbsp; &nbsp; &nbsp; &nbsp; using type =3D R(*)(X.=
...);</div><div>&nbsp; &nbsp; &nbsp; &nbsp; type f;</div><div>&nbsp; &nbsp; =
&nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbsp; constexpr Forwarder(type f) : =
f(f) { }</div><div>&nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; &nbsp; &nbs=
p; constexpr R operator () (X &amp;&amp;... x) const {</div><div>&nbsp; &nb=
sp; &nbsp; &nbsp; &nbsp; &nbsp; return f(std::forward&lt;X&gt;(x)...);</div=
><div>&nbsp; &nbsp; &nbsp; &nbsp; }</div><div>&nbsp; &nbsp; };</div><div><b=
r></div><div>&nbsp; &nbsp; template&lt;class R, class O, class...X&gt;</div=
><div>&nbsp; &nbsp; struct Forwarder&lt;R(O::*)(X...)&gt; : Forwarder&lt;de=
cltype(std::mem_fn(std::declval&lt;R(O::*)(X...)&gt;()))&gt; {</div><div>&n=
bsp; &nbsp; &nbsp; using base =3D Forwarder&lt;decltype(std::mem_fn(std::de=
clval&lt;R(O::*)(X...)&gt;()))&gt;;</div><div>&nbsp; &nbsp; &nbsp; using ty=
pe =3D R(O::*)(X...);</div><div><br></div><div>&nbsp; &nbsp; &nbsp; constex=
pr Forwarder(type f) : base(std::mem_fn(f)) { }</div><div>&nbsp; &nbsp; &nb=
sp; using base::operator();</div><div>&nbsp; &nbsp; };</div><div><br></div>=
<div>&nbsp; &nbsp; template&lt; class F, class G &gt;</div><div>&nbsp; &nbs=
p; struct Overloaded : Forwarder&lt;F&gt;, Forwarder&lt;G&gt; {</div><div>&=
nbsp; &nbsp; &nbsp; using Forwarder&lt;F&gt;::operator();</div><div>&nbsp; =
&nbsp; &nbsp; using Forwarder&lt;G&gt;::operator();</div><div>&nbsp; &nbsp;=
 &nbsp; constexpr Overloaded( const F&amp; f, const G&amp; g )</div><div>&n=
bsp; &nbsp; &nbsp; &nbsp; : Forwarder&lt;F&gt;(f), Forwarder&lt;G&gt;(g)</d=
iv><div>&nbsp; &nbsp; &nbsp; {</div><div>&nbsp; &nbsp; &nbsp; }</div><div>&=
nbsp; &nbsp; };</div><div>&nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; temp=
late&lt; class F &gt; F overload( F&amp;&amp; f ) {</div><div>&nbsp; &nbsp;=
 &nbsp; &nbsp; return std::forward&lt;F&gt;(f);</div><div>&nbsp; &nbsp; }</=
div><div>&nbsp; &nbsp; &nbsp;</div><div>&nbsp; &nbsp; template&lt; class F,=
 class G, class ...H,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &=
nbsp; class O1 =3D Overloaded&lt;F,G&gt; &gt;&nbsp;</div><div>&nbsp; &nbsp;=
 auto overload( const F&amp; f, const G&amp; g, const H&amp; ...h ) {</div>=
<div>&nbsp; &nbsp; &nbsp; &nbsp; return overload( O1(f,g), h... );</div><di=
v>&nbsp; &nbsp; }</div><div><br></div><div>&nbsp; &nbsp; struct X {</div><d=
iv>&nbsp; &nbsp; &nbsp; void f() { std::cout &lt;&lt; "X::f" &lt;&lt; std::=
endl; }</div><div>&nbsp; &nbsp; };</div><div><br></div><div>&nbsp; &nbsp; v=
oid f(std::string ) {</div><div>&nbsp; &nbsp; &nbsp; std::cout &lt;&lt; "st=
ring" &lt;&lt; std::endl;</div><div>&nbsp; &nbsp; }</div><div><br></div><di=
v>&nbsp; &nbsp; int main() {</div><div>&nbsp; &nbsp; &nbsp; auto set =3D ov=
erload([](int ) { std::cout &lt;&lt; "int" &lt;&lt; std::endl; },</div><div=
>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbs=
p; &nbsp; &nbsp; [](char) { std::cout &lt;&lt; "char" &lt;&lt; std::endl; }=
,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; f,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &amp;X::f);</div><=
div>&nbsp; &nbsp; &nbsp; set(0);</div><div>&nbsp; &nbsp; &nbsp; set('x');</=
div><div>&nbsp; &nbsp; &nbsp; set(std::string("x"));</div><div><br></div><d=
iv>&nbsp; &nbsp; &nbsp; X x;</div><div>&nbsp; &nbsp; &nbsp; set(x);</div><d=
iv>&nbsp; &nbsp; }&nbsp;</div><div><br></div><div>Compiles fine with gcc 4.=
9. Doesn't work at all with the master branch of clang.</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_5467_941358095.1417281466584--
------=_Part_5466_829303875.1417281466584--

.


Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Sat, 29 Nov 2014 21:00:59 +0100
Raw View
This is a multi-part message in MIME format.
--------------020506090205030609000905
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 29/11/14 18:17, Scott Prager a =C3=A9crit :
>
>
> On Saturday, November 29, 2014 3:32:18 AM UTC-5, Vicente J. Botet=20
> Escriba wrote:
>
>     Le 29/11/14 05:38, Scott Prager a =C3=A9crit :
>>     Personally, I would like to see this, among other functional
>>     programming utilities, in the standard, but it doesn't work for
>>     regular functions. It can be done more generically, just that
>>     implementation only needed to work for lambdas.
>>
>>
>     I'm sure we will be able to overcome this technical difficulties.
>     Do you have a link to an implementation that works with regular
>     functions?
>
>     Best,
>     Vicente
>
>
> Thought I had one, but I can't find it. Here's a rewrite.
>
>     #include <iostream>
>     #include <functional>
>
>     template< class F > struct Forwarder : F {
>       using F::operator();
>       constexpr Forwarder(const F& f) : F(f) { }
>     };
>
>     template< class R, class ...X >
>     struct Forwarder<R(X...)> {
>         using type =3D R(*)(X...);
>         type f;
>         constexpr Forwarder(type f) : f(f) { }
>         constexpr R operator () (X &&... x) const {
>             return f(std::forward<X>(x)...);
>         }
>     };
>
>     template<class R, class O, class...X>
>     struct Forwarder<R(O::*)(X...)> :=20
> Forwarder<decltype(std::mem_fn(std::declval<R(O::*)(X...)>()))> {
>       using base =3D=20
> Forwarder<decltype(std::mem_fn(std::declval<R(O::*)(X...)>()))>;
>       using type =3D R(O::*)(X...);
>
>       constexpr Forwarder(type f) : base(std::mem_fn(f)) { }
>       using base::operator();
>     };
>
>     template< class F, class G >
>     struct Overloaded : Forwarder<F>, Forwarder<G> {
>       using Forwarder<F>::operator();
>       using Forwarder<G>::operator();
>       constexpr Overloaded( const F& f, const G& g )
>         : Forwarder<F>(f), Forwarder<G>(g)
>       {
>       }
>     };
>     template< class F > F overload( F&& f ) {
>         return std::forward<F>(f);
>     }
>     template< class F, class G, class ...H,
>               class O1 =3D Overloaded<F,G> >
>     auto overload( const F& f, const G& g, const H& ...h ) {
>         return overload( O1(f,g), h... );
>     }
>
>     struct X {
>       void f() { std::cout << "X::f" << std::endl; }
>     };
>
>     void f(std::string ) {
>       std::cout << "string" << std::endl;
>     }
>
>     int main() {
>       auto set =3D overload([](int ) { std::cout << "int" << std::endl; }=
,
>                           [](char) { std::cout << "char" << std::endl; },
>                           f,
>                           &X::f);
>       set(0);
>       set('x');
>       set(std::string("x"));
>
>       X x;
>       set(x);
>     }
>
> Compiles fine with gcc 4.9. Doesn't work at all with the master branch=20
> of clang.
>
Is there something not portable or is there a bug on clang?

Thanks for sharing,
Vicente

--=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/.

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

<html>
  <head>
    <meta content=3D"text/html; charset=3DUTF-8" http-equiv=3D"Content-Type=
">
  </head>
  <body bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">Le 29/11/14 18:17, Scott Prager a
      =C3=A9crit=C2=A0:<br>
    </div>
    <blockquote
      cite=3D"mid:a378d678-60d9-4cd2-b3d3-26443ee03194@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr"><br>
        <br>
        On Saturday, November 29, 2014 3:32:18 AM UTC-5, Vicente J.
        Botet Escriba wrote:
        <blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:
          0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
          <div bgcolor=3D"#FFFFFF" text=3D"#000000">
            <div>Le 29/11/14 05:38, Scott Prager a =C3=A9crit=C2=A0:</div>
            <blockquote type=3D"cite">
              <div dir=3D"ltr">
                <div>Personally, I would like to see this, among other
                  functional programming utilities, in the standard, but
                  it doesn't work for regular functions. It can be done
                  more generically, just that implementation only needed
                  to work for lambdas.</div>
                <div><br>
                </div>
                <div><br>
                </div>
              </div>
            </blockquote>
            I'm sure we will be able to overcome this technical
            difficulties. <br>
            Do you have a link to an implementation that works with
            regular functions?<br>
            <br>
            Best,<br>
            Vicente<br>
          </div>
        </blockquote>
        <div><br>
        </div>
        <div>Thought I had one, but I can't find it. Here's a rewrite.</div=
>
        <div><br>
        </div>
        <div>=C2=A0 =C2=A0 #include &lt;iostream&gt;</div>
        <div>=C2=A0 =C2=A0 #include &lt;functional&gt;</div>
        <div><br>
        </div>
        <div>=C2=A0 =C2=A0 template&lt; class F &gt; struct Forwarder : F {=
</div>
        <div>=C2=A0 =C2=A0 =C2=A0 using F::operator();</div>
        <div>=C2=A0 =C2=A0 =C2=A0 constexpr Forwarder(const F&amp; f) : F(f=
) { }</div>
        <div>=C2=A0 =C2=A0 };</div>
        <div><br>
        </div>
        <div>=C2=A0 =C2=A0 template&lt; class R, class ...X &gt;=C2=A0</div=
>
        <div>=C2=A0 =C2=A0 struct Forwarder&lt;R(X...)&gt; {</div>
        <div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 using type =3D R(*)(X...);</div>
        <div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 type f;</div>
        <div>=C2=A0 =C2=A0 =C2=A0</div>
        <div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 constexpr Forwarder(type f) : f(f)=
 { }</div>
        <div>=C2=A0 =C2=A0 =C2=A0</div>
        <div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 constexpr R operator () (X &amp;&a=
mp;... x) const {</div>
        <div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return f(std::forwar=
d&lt;X&gt;(x)...);</div>
        <div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 }</div>
        <div>=C2=A0 =C2=A0 };</div>
        <div><br>
        </div>
        <div>=C2=A0 =C2=A0 template&lt;class R, class O, class...X&gt;</div=
>
        <div>=C2=A0 =C2=A0 struct Forwarder&lt;R(O::*)(X...)&gt; :
          Forwarder&lt;decltype(std::mem_fn(std::declval&lt;R(O::*)(X...)&g=
t;()))&gt;
          {</div>
        <div>=C2=A0 =C2=A0 =C2=A0 using base =3D
Forwarder&lt;decltype(std::mem_fn(std::declval&lt;R(O::*)(X...)&gt;()))&gt;=
;</div>
        <div>=C2=A0 =C2=A0 =C2=A0 using type =3D R(O::*)(X...);</div>
        <div><br>
        </div>
        <div>=C2=A0 =C2=A0 =C2=A0 constexpr Forwarder(type f) : base(std::m=
em_fn(f)) {
          }</div>
        <div>=C2=A0 =C2=A0 =C2=A0 using base::operator();</div>
        <div>=C2=A0 =C2=A0 };</div>
        <div><br>
        </div>
        <div>=C2=A0 =C2=A0 template&lt; class F, class G &gt;</div>
        <div>=C2=A0 =C2=A0 struct Overloaded : Forwarder&lt;F&gt;,
          Forwarder&lt;G&gt; {</div>
        <div>=C2=A0 =C2=A0 =C2=A0 using Forwarder&lt;F&gt;::operator();</di=
v>
        <div>=C2=A0 =C2=A0 =C2=A0 using Forwarder&lt;G&gt;::operator();</di=
v>
        <div>=C2=A0 =C2=A0 =C2=A0 constexpr Overloaded( const F&amp; f, con=
st G&amp; g
          )</div>
        <div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 : Forwarder&lt;F&gt;(f), Forwarder=
&lt;G&gt;(g)</div>
        <div>=C2=A0 =C2=A0 =C2=A0 {</div>
        <div>=C2=A0 =C2=A0 =C2=A0 }</div>
        <div>=C2=A0 =C2=A0 };</div>
        <div>=C2=A0 =C2=A0 =C2=A0</div>
        <div>=C2=A0 =C2=A0 template&lt; class F &gt; F overload( F&amp;&amp=
; f ) {</div>
        <div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 return std::forward&lt;F&gt;(f);</=
div>
        <div>=C2=A0 =C2=A0 }</div>
        <div>=C2=A0 =C2=A0 =C2=A0</div>
        <div>=C2=A0 =C2=A0 template&lt; class F, class G, class ...H,</div>
        <div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 class O1 =3D =
Overloaded&lt;F,G&gt; &gt;=C2=A0</div>
        <div>=C2=A0 =C2=A0 auto overload( const F&amp; f, const G&amp; g, c=
onst
          H&amp; ...h ) {</div>
        <div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 return overload( O1(f,g), h... );<=
/div>
        <div>=C2=A0 =C2=A0 }</div>
        <div><br>
        </div>
        <div>=C2=A0 =C2=A0 struct X {</div>
        <div>=C2=A0 =C2=A0 =C2=A0 void f() { std::cout &lt;&lt; "X::f" &lt;=
&lt;
          std::endl; }</div>
        <div>=C2=A0 =C2=A0 };</div>
        <div><br>
        </div>
        <div>=C2=A0 =C2=A0 void f(std::string ) {</div>
        <div>=C2=A0 =C2=A0 =C2=A0 std::cout &lt;&lt; "string" &lt;&lt; std:=
:endl;</div>
        <div>=C2=A0 =C2=A0 }</div>
        <div><br>
        </div>
        <div>=C2=A0 =C2=A0 int main() {</div>
        <div>=C2=A0 =C2=A0 =C2=A0 auto set =3D overload([](int ) { std::cou=
t &lt;&lt;
          "int" &lt;&lt; std::endl; },</div>
        <div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 [](char) { std::cout &lt;&lt;
          "char" &lt;&lt; std::endl; },</div>
        <div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 f,</div>
        <div>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 &amp;X::f);</div>
        <div>=C2=A0 =C2=A0 =C2=A0 set(0);</div>
        <div>=C2=A0 =C2=A0 =C2=A0 set('x');</div>
        <div>=C2=A0 =C2=A0 =C2=A0 set(std::string("x"));</div>
        <div><br>
        </div>
        <div>=C2=A0 =C2=A0 =C2=A0 X x;</div>
        <div>=C2=A0 =C2=A0 =C2=A0 set(x);</div>
        <div>=C2=A0 =C2=A0 }=C2=A0</div>
        <div><br>
        </div>
        <div>Compiles fine with gcc 4.9. Doesn't work at all with the
          master branch of clang.</div>
      </div>
      <br>
    </blockquote>
    Is there something not portable or is there a bug on clang?<br>
    <br>
    Thanks for sharing,<br>
    Vicente<br>
  </body>
</html>

<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 />

--------------020506090205030609000905--

.


Author: Scott Prager <splinterofchaos@gmail.com>
Date: Sat, 29 Nov 2014 12:17:12 -0800 (PST)
Raw View
------=_Part_9039_307250386.1417292232614
Content-Type: multipart/alternative;
 boundary="----=_Part_9040_1406550114.1417292232614"

------=_Part_9040_1406550114.1417292232614
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



On Saturday, November 29, 2014 3:01:03 PM UTC-5, Vicente J. Botet Escriba=
=20
wrote:
>
>  Le 29/11/14 18:17, Scott Prager a =C3=A9crit :
> =20
>
>
> On Saturday, November 29, 2014 3:32:18 AM UTC-5, Vicente J. Botet Escriba=
=20
> wrote:=20
>>
>>  Le 29/11/14 05:38, Scott Prager a =C3=A9crit :
>>
> Compiles fine with gcc 4.9. Doesn't work at all with the master branch of=
=20
> clang.
> =20
>  Is there something not portable or is there a bug on clang?
>

I was mistaken, it does compile. (Tried to compile the wrong file.)

--=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_9040_1406550114.1417292232614
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><br>On Saturday, November 29, 2014 3:01:03 PM UTC-5, V=
icente J. Botet Escriba wrote:<blockquote class=3D"gmail_quote" style=3D"ma=
rgin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
 =20
   =20
 =20
  <div bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div>Le 29/11/14 18:17, Scott Prager a
      =C3=A9crit&nbsp;:<br>
    </div>
    <blockquote type=3D"cite">
      <div dir=3D"ltr"><br>
        <br>
        On Saturday, November 29, 2014 3:32:18 AM UTC-5, Vicente J.
        Botet Escriba wrote:
        <blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8=
ex;border-left:1px #ccc solid;padding-left:1ex">
          <div bgcolor=3D"#FFFFFF" text=3D"#000000">
            <div>Le 29/11/14 05:38, Scott Prager a =C3=A9crit&nbsp;:</div><=
/div></blockquote>
        <div>Compiles fine with gcc 4.9. Doesn't work at all with the
          master branch of clang.</div>
      </div>
      <br>
    </blockquote>
    Is there something not portable or is there a bug on clang?<br></div></=
blockquote><div><br></div><div>I was mistaken, it does compile. (Tried to c=
ompile the wrong file.)</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_9040_1406550114.1417292232614--
------=_Part_9039_307250386.1417292232614--

.


Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Sat, 29 Nov 2014 21:25:09 +0100
Raw View
This is a multi-part message in MIME format.
--------------080105020507000000020201
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 29/11/14 21:17, Scott Prager a =C3=A9crit :
>
>
> On Saturday, November 29, 2014 3:01:03 PM UTC-5, Vicente J. Botet=20
> Escriba wrote:
>
>     Le 29/11/14 18:17, Scott Prager a =C3=A9crit :
>>
>>
>>     On Saturday, November 29, 2014 3:32:18 AM UTC-5, Vicente J. Botet
>>     Escriba wrote:
>>
>>         Le 29/11/14 05:38, Scott Prager a =C3=A9crit :
>>
>>     Compiles fine with gcc 4.9. Doesn't work at all with the master
>>     branch of clang.
>>
>     Is there something not portable or is there a bug on clang?
>
>
> I was mistaken, it does compile. (Tried to compile the wrong file.)
>
Great,
Vicente

--=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/.

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

<html>
  <head>
    <meta content=3D"text/html; charset=3DUTF-8" http-equiv=3D"Content-Type=
">
  </head>
  <body bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">Le 29/11/14 21:17, Scott Prager a
      =C3=A9crit=C2=A0:<br>
    </div>
    <blockquote
      cite=3D"mid:196840c7-cb46-4b58-9ff4-d4f26488b6f5@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr"><br>
        <br>
        On Saturday, November 29, 2014 3:01:03 PM UTC-5, Vicente J.
        Botet Escriba wrote:
        <blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:
          0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
          <div bgcolor=3D"#FFFFFF" text=3D"#000000">
            <div>Le 29/11/14 18:17, Scott Prager a =C3=A9crit=C2=A0:<br>
            </div>
            <blockquote type=3D"cite">
              <div dir=3D"ltr"><br>
                <br>
                On Saturday, November 29, 2014 3:32:18 AM UTC-5, Vicente
                J. Botet Escriba wrote:
                <blockquote class=3D"gmail_quote"
                  style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc
                  solid;padding-left:1ex">
                  <div bgcolor=3D"#FFFFFF" text=3D"#000000">
                    <div>Le 29/11/14 05:38, Scott Prager a =C3=A9crit=C2=A0=
:</div>
                  </div>
                </blockquote>
                <div>Compiles fine with gcc 4.9. Doesn't work at all
                  with the master branch of clang.</div>
              </div>
              <br>
            </blockquote>
            Is there something not portable or is there a bug on clang?<br>
          </div>
        </blockquote>
        <div><br>
        </div>
        <div>I was mistaken, it does compile. (Tried to compile the
          wrong file.)</div>
      </div>
      <br>
    </blockquote>
    Great,<br>
    Vicente<br>
  </body>
</html>

<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 />

--------------080105020507000000020201--

.


Author: David Krauss <potswa@gmail.com>
Date: Sun, 30 Nov 2014 10:05:40 +0800
Raw View
--Apple-Mail=_3B949BDA-6F65-4AAF-9721-FC35399C1980
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


On 2014=E2=80=9311=E2=80=9330, at 1:17 AM, Scott Prager <splinterofchaos@gm=
ail.com> wrote:

>     template< class R, class ...X >=20
>     struct Forwarder<R(X...)> {
>         using type =3D R(*)(X...);
>         type f;
>     =20
>         constexpr Forwarder(type f) : f(f) { }
>     =20
>         constexpr R operator () (X &&... x) const {
>             return f(std::forward<X>(x)...);
>         }
>     };

This is very much like std::reference_wrapper<R(X...)>.

--=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/.

--Apple-Mail=_3B949BDA-6F65-4AAF-9721-FC35399C1980
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dwindows-1252"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-=
mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 2014=
=E2=80=9311=E2=80=9330, at 1:17 AM, Scott Prager &lt;<a href=3D"mailto:spli=
nterofchaos@gmail.com">splinterofchaos@gmail.com</a>&gt; wrote:</div><br cl=
ass=3D"Apple-interchange-newline"><blockquote type=3D"cite"><div style=3D"f=
ont-family: Helvetica; font-size: 12px; font-style: normal; font-variant: n=
ormal; font-weight: normal; letter-spacing: normal; line-height: normal; or=
phans: auto; text-align: start; text-indent: 0px; text-transform: none; whi=
te-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-widt=
h: 0px;">&nbsp; &nbsp; template&lt; class R, class ...X &gt;&nbsp;</div><di=
v style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; fon=
t-variant: normal; font-weight: normal; letter-spacing: normal; line-height=
: normal; orphans: auto; text-align: start; text-indent: 0px; text-transfor=
m: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text=
-stroke-width: 0px;">&nbsp; &nbsp; struct Forwarder&lt;R(X...)&gt; {</div><=
div style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; f=
ont-variant: normal; font-weight: normal; letter-spacing: normal; line-heig=
ht: normal; orphans: auto; text-align: start; text-indent: 0px; text-transf=
orm: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-te=
xt-stroke-width: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; using type =3D R(*)(X...=
);</div><div style=3D"font-family: Helvetica; font-size: 12px; font-style: =
normal; font-variant: normal; font-weight: normal; letter-spacing: normal; =
line-height: normal; orphans: auto; text-align: start; text-indent: 0px; te=
xt-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -=
webkit-text-stroke-width: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; type f;</div><d=
iv style=3D"font-family: Helvetica; font-size: 12px; font-style: normal; fo=
nt-variant: normal; font-weight: normal; letter-spacing: normal; line-heigh=
t: normal; orphans: auto; text-align: start; text-indent: 0px; text-transfo=
rm: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-tex=
t-stroke-width: 0px;">&nbsp; &nbsp; &nbsp;</div><div style=3D"font-family: =
Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-=
weight: normal; letter-spacing: normal; line-height: normal; orphans: auto;=
 text-align: start; text-indent: 0px; text-transform: none; white-space: no=
rmal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">&nb=
sp; &nbsp; &nbsp; &nbsp; constexpr Forwarder(type f) : f(f) { }</div><div s=
tyle=3D"font-family: Helvetica; font-size: 12px; font-style: normal; font-v=
ariant: normal; font-weight: normal; letter-spacing: normal; line-height: n=
ormal; orphans: auto; text-align: start; text-indent: 0px; text-transform: =
none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-st=
roke-width: 0px;">&nbsp; &nbsp; &nbsp;</div><div style=3D"font-family: Helv=
etica; font-size: 12px; font-style: normal; font-variant: normal; font-weig=
ht: normal; letter-spacing: normal; line-height: normal; orphans: auto; tex=
t-align: start; text-indent: 0px; text-transform: none; white-space: normal=
; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">&nbsp; =
&nbsp; &nbsp; &nbsp; constexpr R operator () (X &amp;&amp;... x) const {</d=
iv><div style=3D"font-family: Helvetica; font-size: 12px; font-style: norma=
l; font-variant: normal; font-weight: normal; letter-spacing: normal; line-=
height: normal; orphans: auto; text-align: start; text-indent: 0px; text-tr=
ansform: none; white-space: normal; widows: auto; word-spacing: 0px; -webki=
t-text-stroke-width: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; return=
 f(std::forward&lt;X&gt;(x)...);</div><div style=3D"font-family: Helvetica;=
 font-size: 12px; font-style: normal; font-variant: normal; font-weight: no=
rmal; letter-spacing: normal; line-height: normal; orphans: auto; text-alig=
n: start; text-indent: 0px; text-transform: none; white-space: normal; wido=
ws: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">&nbsp; &nbsp;=
 &nbsp; &nbsp; }</div><div style=3D"font-family: Helvetica; font-size: 12px=
; font-style: normal; font-variant: normal; font-weight: normal; letter-spa=
cing: normal; line-height: normal; orphans: auto; text-align: start; text-i=
ndent: 0px; text-transform: none; white-space: normal; widows: auto; word-s=
pacing: 0px; -webkit-text-stroke-width: 0px;">&nbsp; &nbsp; };</div></block=
quote></div><br><div>This is very much like <font face=3D"Courier">std::ref=
erence_wrapper&lt;R(X...)&gt;</font>.</div></body></html>

<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 />

--Apple-Mail=_3B949BDA-6F65-4AAF-9721-FC35399C1980--

.