Topic: Variadic decomposition
Author: Richard Thorell <richard.thorell@king.com>
Date: Wed, 12 Oct 2016 03:51:24 -0700 (PDT)
Raw View
------=_Part_3894_73075416.1476269484504
Content-Type: multipart/alternative;
boundary="----=_Part_3895_1655120811.1476269484504"
------=_Part_3895_1655120811.1476269484504
Content-Type: text/plain; charset=UTF-8
Hey,
After looking at the structured bindings paper [
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0144r0.pdf] I
thought, why don't we allow the members to be automatically unpacked into
it's components and forwarded to a method?
We have this functionality when it comes to tuples today, using std::get<>
and std::index_sequence. But what if it was a built-in language feature and
a one-liner? And worked with any structure!
Proposal:
template <class... Args>
void foo(void(*func)(Args...), std::tuple<Args...> args)
{
func(auto{ ... } = args);
}
The syntax is questionable, but I wanted it to follow the structured
bindings syntax as close as possible. The auto keyword can have const,
l-value and r-value reference modifiers which will be appended to each
argument. Also, the decomposition can only be used within a
function/constructor call.
Maybe this has already been discussed somewhere?
Any feedback is appreciated!
Thanks,
Richard
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/0d627ddf-dec9-4051-abaf-e6e6f8dbeaaa%40isocpp.org.
------=_Part_3895_1655120811.1476269484504
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hey,<div><div><br></div><div>After looking at the structur=
ed bindings paper [<a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/p=
apers/2015/p0144r0.pdf">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/=
2015/p0144r0.pdf</a>] I thought, why don't we allow the members to be a=
utomatically unpacked into it's components and forwarded to a method?</=
div><div>We have this functionality when it comes to tuples today, using st=
d::get<> and std::index_sequence. But what if it was a built-in langu=
age feature and a one-liner? And worked with any structure!<br></div><div><=
br></div><div>Proposal:</div></div><div class=3D"prettyprint" style=3D"back=
ground-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-=
style: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"pre=
ttyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=
=3D"styled-by-prettify">template</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify"><</span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">class</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">...</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #606;" class=3D"styled-by-prettify">Args</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">></span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">void</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"> foo</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">void</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(*</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">func</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">)(</span><span style=3D"color: #606;" class=3D"styled-by-prettify">Ar=
gs</span><span style=3D"color: #660;" class=3D"styled-by-prettify">...),</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">tuple</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color:=
#606;" class=3D"styled-by-prettify">Args</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">...></span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> args</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br>=C2=A0 =C2=A0 func</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">(</span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">auto</span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">...</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> args</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">);</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</spa=
n></div></code></div><div>=C2=A0</div><div>The syntax is questionable, but =
I wanted it to follow the structured bindings syntax as close as possible. =
The auto keyword can have const, l-value and r-value reference modifiers wh=
ich will be appended to each argument. Also, the decomposition can only be =
used within a function/constructor call.</div><div><br></div><div>Maybe thi=
s has already been discussed somewhere?</div><div><br></div><div>Any feedba=
ck is appreciated!</div><div><br></div><div>Thanks,</div><div>Richard</div>=
</div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/0d627ddf-dec9-4051-abaf-e6e6f8dbeaaa%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0d627ddf-dec9-4051-abaf-e6e6f8dbeaaa=
%40isocpp.org</a>.<br />
------=_Part_3895_1655120811.1476269484504--
------=_Part_3894_73075416.1476269484504--
.
Author: Alisdair Meredith <alisdairm@me.com>
Date: Wed, 12 Oct 2016 06:58:10 -0400
Raw View
--Apple-Mail-D5A918BE-5BC5-4064-A676-3DC7963A772A
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
A library function with these semantics is already present in the C++17 CD,=
called 'apply'. What benefit do you expect by complicating the language w=
ith a compiler feature to delivery (mostly) the same effect?
(By using the INVOKE treatment, the library version is actually slightly mo=
re capable than a likely language feature, dispatching through pointer-to-m=
embers etc. as well.)
AlisdairM
Sent from my iPad
> On 12 Oct 2016, at 06:51, Richard Thorell <richard.thorell@king.com> wrot=
e:
>=20
> Hey,
>=20
> After looking at the structured bindings paper [http://www.open-std.org/j=
tc1/sc22/wg21/docs/papers/2015/p0144r0.pdf] I thought, why don't we allow t=
he members to be automatically unpacked into it's components and forwarded =
to a method?
> We have this functionality when it comes to tuples today, using std::get<=
> and std::index_sequence. But what if it was a built-in language feature a=
nd a one-liner? And worked with any structure!
>=20
> Proposal:
> template <class... Args>
> void foo(void(*func)(Args...), std::tuple<Args...> args)
> {
> func(auto{ ... } =3D args);
> }
> =20
> The syntax is questionable, but I wanted it to follow the structured bind=
ings syntax as close as possible. The auto keyword can have const, l-value =
and r-value reference modifiers which will be appended to each argument. Al=
so, the decomposition can only be used within a function/constructor call.
>=20
> Maybe this has already been discussed somewhere?
>=20
> Any feedback is appreciated!
>=20
> Thanks,
> Richard
> --=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=
email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit https://groups.google.com/a/isoc=
pp.org/d/msgid/std-proposals/0d627ddf-dec9-4051-abaf-e6e6f8dbeaaa%40isocpp.=
org.
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/8B2D635D-B919-4757-B11D-D2D28C503864%40me.com.
--Apple-Mail-D5A918BE-5BC5-4064-A676-3DC7963A772A
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<html><head><meta http-equiv=3D"content-type" content=3D"text/html; charset=
=3Dutf-8"></head><body dir=3D"auto"><div><div style=3D"direction: inherit;"=
>A library function with these semantics is already present in the C++17 CD=
, called 'apply'. What benefit do you expect by complicating the lang=
uage with a compiler feature to delivery (mostly) the same effect?</div><di=
v style=3D"direction: inherit;"><br></div><div style=3D"direction: inherit;=
">(By using the INVOKE treatment, the library version is actually slightly =
more capable than a likely language feature, dispatching through pointer-to=
-members etc. as well.)</div><div style=3D"direction: inherit;"><br></div><=
div style=3D"direction: inherit;">AlisdairM</div><br>Sent from my iPad</div=
><div><br>On 12 Oct 2016, at 06:51, Richard Thorell <<a href=3D"mailto:r=
ichard.thorell@king.com">richard.thorell@king.com</a>> wrote:<br><br></d=
iv><blockquote type=3D"cite"><div><div dir=3D"ltr">Hey,<div><div><br></div>=
<div>After looking at the structured bindings paper [<a href=3D"http://www.=
open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0144r0.pdf">http://www.open-s=
td.org/jtc1/sc22/wg21/docs/papers/2015/p0144r0.pdf</a>] I thought, why don'=
t we allow the members to be automatically unpacked into it's components an=
d forwarded to a method?</div><div>We have this functionality when it comes=
to tuples today, using std::get<> and std::index_sequence. But what =
if it was a built-in language feature and a one-liner? And worked with any =
structure!<br></div><div><br></div><div>Proposal:</div></div><div class=3D"=
prettyprint" style=3D"background-color: rgb(250, 250, 250); border-color: r=
gb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: break=
-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">template</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #660;" class=3D"styled-by-prettify"><</span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">class</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">...</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by=
-prettify">Args</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">></span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">void</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> foo</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">void</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">(*</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">func</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">)(</span><span style=3D"color: #606;" class=3D"s=
tyled-by-prettify">Args</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">...),</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify"> std</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">tuple<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span>=
<span style=3D"color: #606;" class=3D"styled-by-prettify">Args</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">...></span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> args</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br> func</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">auto</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
....</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> args</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">}</span></div></code></div><div> </div><div>The syntax =
is questionable, but I wanted it to follow the structured bindings syntax a=
s close as possible. The auto keyword can have const, l-value and r-value r=
eference modifiers which will be appended to each argument. Also, the decom=
position can only be used within a function/constructor call.</div><div><br=
></div><div>Maybe this has already been discussed somewhere?</div><div><br>=
</div><div>Any feedback is appreciated!</div><div><br></div><div>Thanks,</d=
iv><div>Richard</div></div>
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/0d627ddf-dec9-4051-abaf-e6e6f8dbeaaa%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.goo=
gle.com/a/isocpp.org/d/msgid/std-proposals/0d627ddf-dec9-4051-abaf-e6e6f8db=
eaaa%40isocpp.org</a>.<br>
</div></blockquote></body></html>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/8B2D635D-B919-4757-B11D-D2D28C503864%=
40me.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/8B2D635D-B919-4757-B11D-D2D28C503864%40m=
e.com</a>.<br />
--Apple-Mail-D5A918BE-5BC5-4064-A676-3DC7963A772A--
.
Author: Richard Thorell <richard.thorell@king.com>
Date: Wed, 12 Oct 2016 04:09:01 -0700 (PDT)
Raw View
------=_Part_1491_928320850.1476270541560
Content-Type: multipart/alternative;
boundary="----=_Part_1492_1222889145.1476270541561"
------=_Part_1492_1222889145.1476270541561
Content-Type: text/plain; charset=UTF-8
Hey,
Yeah I'm aware of std::apply but it still only operates on std::tuple. If
you have your own structure and you want to decompose it, there's no
generic way to do so.
template <class T>
constexpr auto struct_to_fw_tuple(T& any_struct)
{
return std::forward_as_tuple(auto&{...} = any_struct);
}
template <class F, class Tuple>
constexpr decltype(auto) apply(F&& func, Tuple&& tuple)
{
return std::invoke(std::forward<F>(func), auto&&{...} = tuple);
}
The snippet in both post were just examples of usages.
Cheers,
Richard
On Wednesday, October 12, 2016 at 11:58:31 AM UTC+1, Alisdair Meredith
wrote:
>
> A library function with these semantics is already present in the C++17
> CD, called 'apply'. What benefit do you expect by complicating the
> language with a compiler feature to delivery (mostly) the same effect?
>
> (By using the INVOKE treatment, the library version is actually slightly
> more capable than a likely language feature, dispatching through
> pointer-to-members etc. as well.)
>
> AlisdairM
>
> Sent from my iPad
>
> On 12 Oct 2016, at 06:51, Richard Thorell <richard...@king.com
> <javascript:>> wrote:
>
> Hey,
>
> After looking at the structured bindings paper [
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0144r0.pdf] I
> thought, why don't we allow the members to be automatically unpacked into
> it's components and forwarded to a method?
> We have this functionality when it comes to tuples today, using std::get<>
> and std::index_sequence. But what if it was a built-in language feature and
> a one-liner? And worked with any structure!
>
> Proposal:
> template <class... Args>
> void foo(void(*func)(Args...), std::tuple<Args...> args)
> {
> func(auto{ ... } = args);
> }
>
> The syntax is questionable, but I wanted it to follow the structured
> bindings syntax as close as possible. The auto keyword can have const,
> l-value and r-value reference modifiers which will be appended to each
> argument. Also, the decomposition can only be used within a
> function/constructor call.
>
> Maybe this has already been discussed somewhere?
>
> Any feedback is appreciated!
>
> Thanks,
> Richard
>
> --
> 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-proposal...@isocpp.org <javascript:>.
> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/0d627ddf-dec9-4051-abaf-e6e6f8dbeaaa%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/0d627ddf-dec9-4051-abaf-e6e6f8dbeaaa%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>
>
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/6867504e-d4e5-4e2b-859c-3040f7cdc05f%40isocpp.org.
------=_Part_1492_1222889145.1476270541561
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hey,<div><br></div><div>Yeah I'm aware of std::apply b=
ut it still only operates on std::tuple. If you have your own structure and=
you want to decompose it, there's no generic way to do so.</div><div><=
br></div><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250=
, 250); border-color: rgb(187, 187, 187); border-style: solid; border-width=
: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"su=
bprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">tem=
plate</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">class</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">></span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;"=
class=3D"styled-by-prettify">constexpr</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">auto</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> struct_to_fw_tuple</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">T</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">&</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> any_struct</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </sp=
an><span style=3D"color: #008;" class=3D"styled-by-prettify">return</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> std</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">::</span><font color=3D"=
#000000"><span style=3D"color: #000;" class=3D"styled-by-prettify">forward_=
as_tuple</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(<=
/span><span style=3D"color: #008;" class=3D"styled-by-prettify">auto</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">&{...}</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> any_struct</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">);</span></font><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">}</span></div></code></div><div><br><di=
v class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); bord=
er-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-=
wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint=
"><span style=3D"color: #008;" class=3D"styled-by-prettify">template</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify"><</span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">class</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> F</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">class</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"> </span><span style=3D"color: #606;" class=3D"styled-by-prettify">Tu=
ple</span><span style=3D"color: #660;" class=3D"styled-by-prettify">></s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">constexpr</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">decltype</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> apply</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">F</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">&&</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> func</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><spa=
n style=3D"color: #606;" class=3D"styled-by-prettify">Tuple</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">&&</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> tuple</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">{</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">return</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> std</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">invoke</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">std</span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">forward</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify">F</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">>(</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">func</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">),</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">auto</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">&&{</span><font color=3D"#000000"><span style=3D"color=
: #660;" class=3D"styled-by-prettify">...}</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> tuple</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">);</span></font><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">}</span></div></code></div><div><br></div>The snippet in both post we=
re just examples of usages.</div><div><br></div><div>Cheers,</div><div>Rich=
ard<br><br>On Wednesday, October 12, 2016 at 11:58:31 AM UTC+1, Alisdair Me=
redith wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"auto"=
><div><div style=3D"direction:inherit">A library function with these semant=
ics is already present in the C++17 CD, called 'apply'. =C2=A0What =
benefit do you expect by complicating the language with a compiler feature =
to delivery (mostly) the same effect?</div><div style=3D"direction:inherit"=
><br></div><div style=3D"direction:inherit">(By using the INVOKE treatment,=
the library version is actually slightly more capable than a likely langua=
ge feature, dispatching through pointer-to-members etc. as well.)</div><div=
style=3D"direction:inherit"><br></div><div style=3D"direction:inherit">Ali=
sdairM</div><br>Sent from my iPad</div><div><br>On 12 Oct 2016, at 06:51, R=
ichard Thorell <<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated=
-mailto=3D"kgukxOpXAQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'j=
avascript:';return true;" onclick=3D"this.href=3D'javascript:';=
return true;">richard...@king.com</a>> wrote:<br><br></div><blockquote t=
ype=3D"cite"><div><div dir=3D"ltr">Hey,<div><div><br></div><div>After looki=
ng at the structured bindings paper [<a href=3D"http://www.open-std.org/jtc=
1/sc22/wg21/docs/papers/2015/p0144r0.pdf" target=3D"_blank" rel=3D"nofollow=
" onmousedown=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F=
%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2015%2Fp0144r0.p=
df\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG1MKJjnldtN4lm6MvN4r0b6M0ewA'=
;;return true;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3d=
http%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2015%2=
Fp0144r0.pdf\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG1MKJjnldtN4lm6MvN4r0b=
6M0ewA';return true;">http://www.open-std.org/jtc1/<wbr>sc22/wg21/docs/=
papers/2015/<wbr>p0144r0.pdf</a>] I thought, why don't we allow the mem=
bers to be automatically unpacked into it's components and forwarded to=
a method?</div><div>We have this functionality when it comes to tuples tod=
ay, using std::get<> and std::index_sequence. But what if it was a bu=
ilt-in language feature and a one-liner? And worked with any structure!<br>=
</div><div><br></div><div>Proposal:</div></div><div style=3D"background-col=
or:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;border=
-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#008">temp=
late</span><span style=3D"color:#000"> </span><span style=3D"color:#660">&l=
t;</span><span style=3D"color:#008">class</span><span style=3D"color:#660">=
....</span><span style=3D"color:#000"> </span><span style=3D"color:#606">Arg=
s</span><span style=3D"color:#660">></span><span style=3D"color:#000"><b=
r></span><span style=3D"color:#008">void</span><span style=3D"color:#000"> =
foo</span><span style=3D"color:#660">(</span><span style=3D"color:#008">voi=
d</span><span style=3D"color:#660">(*</span><span style=3D"color:#000">func=
</span><span style=3D"color:#660">)(</span><span style=3D"color:#606">Args<=
/span><span style=3D"color:#660">...),</span><span style=3D"color:#000"> st=
d</span><span style=3D"color:#660">::</span><span style=3D"color:#000">tupl=
e</span><span style=3D"color:#660"><</span><span style=3D"color:#606">Ar=
gs</span><span style=3D"color:#660">...></span><span style=3D"color:#000=
"> args</span><span style=3D"color:#660">)</span><span style=3D"color:#000"=
><br></span><span style=3D"color:#660">{</span><span style=3D"color:#000"><=
br>=C2=A0 =C2=A0 func</span><span style=3D"color:#660">(</span><span style=
=3D"color:#008">auto</span><span style=3D"color:#660">{</span><span style=
=3D"color:#000"> </span><span style=3D"color:#660">...</span><span style=3D=
"color:#000"> </span><span style=3D"color:#660">}</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#660">=3D</span><span style=3D"color:#=
000"> args</span><span style=3D"color:#660">);</span><span style=3D"color:#=
000"><br></span><span style=3D"color:#660">}</span></div></code></div><div>=
=C2=A0</div><div>The syntax is questionable, but I wanted it to follow the =
structured bindings syntax as close as possible. The auto keyword can have =
const, l-value and r-value reference modifiers which will be appended to ea=
ch argument. Also, the decomposition can only be used within a function/con=
structor call.</div><div><br></div><div>Maybe this has already been discuss=
ed somewhere?</div><div><br></div><div>Any feedback is appreciated!</div><d=
iv><br></div><div>Thanks,</div><div>Richard</div></div>
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
kgukxOpXAQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:&=
#39;;return true;" onclick=3D"this.href=3D'javascript:';return true=
;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"kgukxOpXAQAJ" rel=3D"nofollow" onmousedown=3D"=
this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'=
;javascript:';return true;">std-pr...@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/0d627ddf-dec9-4051-abaf-e6e6f8dbeaaa%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank" =
rel=3D"nofollow" onmousedown=3D"this.href=3D'https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/0d627ddf-dec9-4051-abaf-e6e6f8dbeaaa%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter';return true;" on=
click=3D"this.href=3D'https://groups.google.com/a/isocpp.org/d/msgid/st=
d-proposals/0d627ddf-dec9-4051-abaf-e6e6f8dbeaaa%40isocpp.org?utm_medium\x3=
demail\x26utm_source\x3dfooter';return true;">https://groups.google.com=
/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/0d627ddf-dec9-4051-<wbr>abaf-=
e6e6f8dbeaaa%40isocpp.org</a><wbr>.<br>
</div></blockquote></div></blockquote></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/6867504e-d4e5-4e2b-859c-3040f7cdc05f%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/6867504e-d4e5-4e2b-859c-3040f7cdc05f=
%40isocpp.org</a>.<br />
------=_Part_1492_1222889145.1476270541561--
------=_Part_1491_928320850.1476270541560--
.
Author: "D. B." <db0451@gmail.com>
Date: Wed, 12 Oct 2016 12:13:00 +0100
Raw View
--001a1130d430839424053ea913c9
Content-Type: text/plain; charset=UTF-8
On Wed, Oct 12, 2016 at 12:09 PM, Richard Thorell <richard.thorell@king.com>
wrote:
> Hey,
>
> Yeah I'm aware of std::apply but it still only operates on std::tuple. If
> you have your own structure and you want to decompose it, there's no
> generic way to do so.
>
>
I think that's wrong:
http://en.cppreference.com/w/cpp/utility/apply
The tuple need not be std::tuple
> <http://en.cppreference.com/w/cpp/utility/tuple>, and instead may be
> anything that supports std::get and std::tuple_size; in particular,
> std::array <http://en.cppreference.com/w/cpp/container/array> and
> std::pair <http://en.cppreference.com/w/cpp/utility/pair> may be used.
>
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhH1wG3C%3D6VWtUGBd-9i6mrQpQ2MKueGWUD50NNguWRLCQ%40mail.gmail.com.
--001a1130d430839424053ea913c9
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Wed, Oct 12, 2016 at 12:09 PM, Richard Thorell <span dir=3D"ltr"><=
;<a href=3D"mailto:richard.thorell@king.com" target=3D"_blank">richard.thor=
ell@king.com</a>></span> wrote:<br><blockquote class=3D"gmail_quote" sty=
le=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);paddi=
ng-left:1ex"><div dir=3D"ltr">Hey,<div><br></div><div>Yeah I'm aware of=
std::apply but it still only operates on std::tuple. If you have your own =
structure and you want to decompose it, there's no generic way to do so=
..<br><br></div></div></blockquote><div><br></div><div>I think that's wr=
ong:<br><a href=3D"http://en.cppreference.com/w/cpp/utility/apply">http://e=
n.cppreference.com/w/cpp/utility/apply</a><br></div><div><br><blockquote cl=
ass=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid=
rgb(204,204,204);padding-left:1ex">The tuple need not be <span class=3D"gm=
ail-t-lc"><a href=3D"http://en.cppreference.com/w/cpp/utility/tuple" title=
=3D"cpp/utility/tuple">std::tuple</a></span>, and instead may be anything t=
hat supports <span class=3D"gmail-t-lc">std::get</span> and <span class=3D"=
gmail-t-lc">std::tuple_size</span>; in particular, <span class=3D"gmail-t-l=
c"><a href=3D"http://en.cppreference.com/w/cpp/container/array" title=3D"cp=
p/container/array">std::array</a></span> and <span class=3D"gmail-t-lc"><a =
href=3D"http://en.cppreference.com/w/cpp/utility/pair" title=3D"cpp/utility=
/pair">std::pair</a></span> may be used.=C2=A0
<br></blockquote></div></div><br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CACGiwhH1wG3C%3D6VWtUGBd-9i6mrQpQ2MKu=
eGWUD50NNguWRLCQ%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhH1wG3C%3=
D6VWtUGBd-9i6mrQpQ2MKueGWUD50NNguWRLCQ%40mail.gmail.com</a>.<br />
--001a1130d430839424053ea913c9--
.
Author: Simon Brand <simon@codeplay.com>
Date: Wed, 12 Oct 2016 12:13:10 +0100
Raw View
This is a multi-part message in MIME format.
--------------A9C4CF4CD3793FDDC73C4092
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Hi Richard,
std::apply doesn't just operate on std::tuple; it uses std::get and=20
std::tuple_size, which is the same method by which you can add=20
structured binding support to your own class (unless the proposal has=20
been updated since I last looked).
Thanks,
Simon
On 12/10/16 12:09, Richard Thorell wrote:
> Hey,
>
> Yeah I'm aware of std::apply but it still only operates on std::tuple.=20
> If you have your own structure and you want to decompose it, there's=20
> no generic way to do so.
>
> |
> template<classT>
> constexprautostruct_to_fw_tuple(T&any_struct)
> {
> returnstd::forward_as_tuple(auto&{...}=3Dany_struct);
> }
> |
>
> |
> template<classF,classTuple>
> constexprdecltype(auto)apply(F&&func,Tuple&&tuple)
> {
> returnstd::invoke(std::forward<F>(func),auto&&{...}=3Dtuple);
> }
> |
>
> The snippet in both post were just examples of usages.
>
> Cheers,
> Richard
>
> On Wednesday, October 12, 2016 at 11:58:31 AM UTC+1, Alisdair Meredith=20
> wrote:
>
> A library function with these semantics is already present in the
> C++17 CD, called 'apply'. What benefit do you expect by
> complicating the language with a compiler feature to delivery
> (mostly) the same effect?
>
> (By using the INVOKE treatment, the library version is actually
> slightly more capable than a likely language feature, dispatching
> through pointer-to-members etc. as well.)
>
> AlisdairM
>
> Sent from my iPad
>
> On 12 Oct 2016, at 06:51, Richard Thorell <richard...@king.com
> <javascript:>> wrote:
>
>> Hey,
>>
>> After looking at the structured bindings paper
>> [http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0144r0.pdf
>> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0144r0.pdf=
>]
>> I thought, why don't we allow the members to be automatically
>> unpacked into it's components and forwarded to a method?
>> We have this functionality when it comes to tuples today, using
>> std::get<> and std::index_sequence. But what if it was a built-in
>> language feature and a one-liner? And worked with any structure!
>>
>> Proposal:
>> |
>> template<class...Args>
>> voidfoo(void(*func)(Args...),std::tuple<Args...>args)
>> {
>> func(auto{...}=3Dargs);
>> }
>> |
>> The syntax is questionable, but I wanted it to follow the
>> structured bindings syntax as close as possible. The auto keyword
>> can have const, l-value and r-value reference modifiers which
>> will be appended to each argument. Also, the decomposition can
>> only be used within a function/constructor call.
>>
>> Maybe this has already been discussed somewhere?
>>
>> Any feedback is appreciated!
>>
>> Thanks,
>> Richard
>> --=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 email to std-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/0d627dd=
f-dec9-4051-abaf-e6e6f8dbeaaa%40isocpp.org
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/0d627d=
df-dec9-4051-abaf-e6e6f8dbeaaa%40isocpp.org?utm_medium=3Demail&utm_source=
=3Dfooter>.
>
> --=20
> You received this message because you are subscribed to the Google=20
> Groups "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send=20
> an email to std-proposals+unsubscribe@isocpp.org=20
> <mailto:std-proposals+unsubscribe@isocpp.org>.
> To post to this group, send email to std-proposals@isocpp.org=20
> <mailto:std-proposals@isocpp.org>.
> To view this discussion on the web visit=20
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/6867504e-d4e=
5-4e2b-859c-3040f7cdc05f%40isocpp.org=20
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/6867504e-d4=
e5-4e2b-859c-3040f7cdc05f%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoot=
er>.
--=20
Simon Brand
Staff Software Engineer
Codeplay Software Ltd
Level C, Argyle House, 3 Lady Lawson St, Edinburgh, EH3 9DR
Tel: 0131 466 0503
Fax: 0131 557 6600
Website: http://www.codeplay.com
Twitter: https://twitter.com/codeplaysoft
This email and any attachments may contain confidential and /or privileged =
information and is for use by the addressee only. If you are not the intend=
ed recipient, please notify Codeplay Software Ltd immediately and delete th=
e message from your computer. You may not copy or forward it, or use or dis=
close its contents to any other person. Any views or other information in t=
his message which do not relate to our business are not authorized by Codep=
lay software Ltd, nor does this message form part of any contract unless so=
stated.
As internet communications are capable of data corruption Codeplay Software=
Ltd does not accept any responsibility for any changes made to this messag=
e after it was sent. Please note that Codeplay Software Ltd does not accept=
any liability or responsibility for viruses and it is your responsibility =
to scan any attachments.
Company registered in England and Wales, number: 04567874
Registered office: 81 Linkfield Street, Redhill RH1 6BY
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/948ea76d-40a3-b24c-f5d8-25d1e5e6afe2%40codeplay.=
com.
--------------A9C4CF4CD3793FDDC73C4092
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">
<p>Hi Richard,<br>
</p>
<p><tt>std::apply</tt> doesn't just operate on <tt>std::tuple</tt>;
it uses <tt>std::get</tt> and <tt>std::tuple_size</tt>, which is
the same method by which you can add structured binding support to
your own class (unless the proposal has been updated since I last
looked).=C2=A0</p>
Thanks,<br>
Simon<br>
<br>
<div class=3D"moz-cite-prefix">On 12/10/16 12:09, Richard Thorell
wrote:<br>
</div>
<blockquote
cite=3D"mid:6867504e-d4e5-4e2b-859c-3040f7cdc05f@isocpp.org"
type=3D"cite">
<div dir=3D"ltr">Hey,
<div><br>
</div>
<div>Yeah I'm aware of std::apply but it still only operates on
std::tuple. If you have your own structure and you want to
decompose it, there's no generic way to do so.</div>
<div><br>
</div>
<div class=3D"prettyprint" style=3D"background-color: rgb(250, 250,
250); border-color: rgb(187, 187, 187); border-style: solid;
border-width: 1px; word-wrap: break-word;"><code
class=3D"prettyprint">
<div class=3D"subprettyprint"><span style=3D"color: #008;"
class=3D"styled-by-prettify">template</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
style=3D"color: #660;" class=3D"styled-by-prettify"><</s=
pan><span
style=3D"color: #008;" class=3D"styled-by-prettify">class</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> T</spa=
n><span
style=3D"color: #660;" class=3D"styled-by-prettify">></s=
pan><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
</span><span style=3D"color: #008;"
class=3D"styled-by-prettify">constexpr</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </span=
><span
style=3D"color: #008;" class=3D"styled-by-prettify">auto</s=
pan><span
style=3D"color: #000;" class=3D"styled-by-prettify">
struct_to_fw_tuple</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">(</span><span style=3D"color:
#000;" class=3D"styled-by-prettify">T</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">&</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify">
any_struct</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">)</span><span style=3D"color:
#000;" class=3D"styled-by-prettify"><br>
</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">{</span><span style=3D"color:
#000;" class=3D"styled-by-prettify"><br>
=C2=A0 =C2=A0 </span><span style=3D"color: #008;"
class=3D"styled-by-prettify">return</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> std</s=
pan><span
style=3D"color: #660;" class=3D"styled-by-prettify">::</spa=
n><font
color=3D"#000000"><span style=3D"color: #000;"
class=3D"styled-by-prettify">forward_as_tuple</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">auto<=
/span><span
style=3D"color: #660;" class=3D"styled-by-prettify">&=
{...}</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify">
any_struct</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">);</span></font><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">}</span></div>
</code></div>
<div><br>
<div class=3D"prettyprint" style=3D"background-color: rgb(250,
250, 250); border-color: rgb(187, 187, 187); border-style:
solid; border-width: 1px; word-wrap: break-word;"><code
class=3D"prettyprint">
<div class=3D"subprettyprint"><span style=3D"color: #008;"
class=3D"styled-by-prettify">template</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><span
style=3D"color: #008;" class=3D"styled-by-prettify">class=
</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> F</s=
pan><span
style=3D"color: #660;" class=3D"styled-by-prettify">,</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">class=
</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #606;" class=3D"styled-by-prettify">Tuple=
</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">><=
/span><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
</span><span style=3D"color: #008;"
class=3D"styled-by-prettify">constexpr</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">declt=
ype</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">auto<=
/span><span
style=3D"color: #660;" class=3D"styled-by-prettify">)</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"> appl=
y</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify">F</sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">&=
&</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> func=
</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">,</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #606;" class=3D"styled-by-prettify">Tuple=
</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">&=
&</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> tupl=
e</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">)</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">{</span><span style=3D"color=
:
#000;" class=3D"styled-by-prettify"><br>
=C2=A0 =C2=A0 </span><span style=3D"color: #008;"
class=3D"styled-by-prettify">return</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> std<=
/span><span
style=3D"color: #660;" class=3D"styled-by-prettify">::</s=
pan><span
style=3D"color: #000;" class=3D"styled-by-prettify">invok=
e</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify">std</=
span><span
style=3D"color: #660;" class=3D"styled-by-prettify">::</s=
pan><span
style=3D"color: #000;" class=3D"styled-by-prettify">forwa=
rd</span><span
style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><span
style=3D"color: #000;" class=3D"styled-by-prettify">F</sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">>(=
</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">func<=
/span><span
style=3D"color: #660;" class=3D"styled-by-prettify">),</s=
pan><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">auto<=
/span><span
style=3D"color: #660;" class=3D"styled-by-prettify">&=
&{</span><font
color=3D"#000000"><span style=3D"color: #660;"
class=3D"styled-by-prettify">...}</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span
style=3D"color: #660;" class=3D"styled-by-prettify">=3D=
</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">
tuple</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">);</span></font><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">}</span></div>
</code></div>
<div><br>
</div>
The snippet in both post were just examples of usages.</div>
<div><br>
</div>
<div>Cheers,</div>
<div>Richard<br>
<br>
On Wednesday, October 12, 2016 at 11:58:31 AM UTC+1, Alisdair
Meredith wrote:
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<div dir=3D"auto">
<div>
<div style=3D"direction:inherit">A library function with
these semantics is already present in the C++17 CD,
called 'apply'. =C2=A0What benefit do you expect by
complicating the language with a compiler feature to
delivery (mostly) the same effect?</div>
<div style=3D"direction:inherit"><br>
</div>
<div style=3D"direction:inherit">(By using the INVOKE
treatment, the library version is actually slightly
more capable than a likely language feature,
dispatching through pointer-to-members etc. as well.)</di=
v>
<div style=3D"direction:inherit"><br>
</div>
<div style=3D"direction:inherit">AlisdairM</div>
<br>
Sent from my iPad</div>
<div><br>
On 12 Oct 2016, at 06:51, Richard Thorell <<a
moz-do-not-send=3D"true" href=3D"javascript:"
target=3D"_blank" gdf-obfuscated-mailto=3D"kgukxOpXAQAJ"
rel=3D"nofollow"
onmousedown=3D"this.href=3D'javascript:';return true;"
onclick=3D"this.href=3D'javascript:';return true;">richar=
d...@king.com</a>>
wrote:<br>
<br>
</div>
<blockquote type=3D"cite">
<div>
<div dir=3D"ltr">Hey,
<div>
<div><br>
</div>
<div>After looking at the structured bindings
paper [<a moz-do-not-send=3D"true"
href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0144r0.pdf=
"
target=3D"_blank" rel=3D"nofollow"
onmousedown=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww=
..open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2015%2Fp0144r0.pdf\x26=
sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG1MKJjnldtN4lm6MvN4r0b6M0ewA';return
true;"
onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.ope=
n-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2015%2Fp0144r0.pdf\x26sa\x=
3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG1MKJjnldtN4lm6MvN4r0b6M0ewA';return
true;">http://www.open-std.org/jtc1/<wbr>sc22/wg2=
1/docs/papers/2015/<wbr>p0144r0.pdf</a>]
I thought, why don't we allow the members to be
automatically unpacked into it's components and
forwarded to a method?</div>
<div>We have this functionality when it comes to
tuples today, using std::get<> and
std::index_sequence. But what if it was a
built-in language feature and a one-liner? And
worked with any structure!<br>
</div>
<div><br>
</div>
<div>Proposal:</div>
</div>
<div
style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);bo=
rder-style:solid;border-width:1px;word-wrap:break-word"><code>
<div><span style=3D"color:#008">template</span><spa=
n
style=3D"color:#000"> </span><span
style=3D"color:#660"><</span><span
style=3D"color:#008">class</span><span
style=3D"color:#660">...</span><span
style=3D"color:#000"> </span><span
style=3D"color:#606">Args</span><span
style=3D"color:#660">></span><span
style=3D"color:#000"><br>
</span><span style=3D"color:#008">void</span><spa=
n
style=3D"color:#000"> foo</span><span
style=3D"color:#660">(</span><span
style=3D"color:#008">void</span><span
style=3D"color:#660">(*</span><span
style=3D"color:#000">func</span><span
style=3D"color:#660">)(</span><span
style=3D"color:#606">Args</span><span
style=3D"color:#660">...),</span><span
style=3D"color:#000"> std</span><span
style=3D"color:#660">::</span><span
style=3D"color:#000">tuple</span><span
style=3D"color:#660"><</span><span
style=3D"color:#606">Args</span><span
style=3D"color:#660">...></span><span
style=3D"color:#000"> args</span><span
style=3D"color:#660">)</span><span
style=3D"color:#000"><br>
</span><span style=3D"color:#660">{</span><span
style=3D"color:#000"><br>
=C2=A0 =C2=A0 func</span><span style=3D"color:#=
660">(</span><span
style=3D"color:#008">auto</span><span
style=3D"color:#660">{</span><span
style=3D"color:#000"> </span><span
style=3D"color:#660">...</span><span
style=3D"color:#000"> </span><span
style=3D"color:#660">}</span><span
style=3D"color:#000"> </span><span
style=3D"color:#660">=3D</span><span
style=3D"color:#000"> args</span><span
style=3D"color:#660">);</span><span
style=3D"color:#000"><br>
</span><span style=3D"color:#660">}</span></div>
</code></div>
<div>=C2=A0</div>
<div>The syntax is questionable, but I wanted it to
follow the structured bindings syntax as close as
possible. The auto keyword can have const, l-value
and r-value reference modifiers which will be
appended to each argument. Also, the decomposition
can only be used within a function/constructor
call.</div>
<div><br>
</div>
<div>Maybe this has already been discussed
somewhere?</div>
<div><br>
</div>
<div>Any feedback is appreciated!</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Richard</div>
</div>
-- <br>
You received this message because you are subscribed
to the Google Groups "ISO C++ Standard - Future
Proposals" group.<br>
To unsubscribe from this group and stop receiving
emails from it, send an email to <a
moz-do-not-send=3D"true" href=3D"javascript:"
target=3D"_blank" gdf-obfuscated-mailto=3D"kgukxOpXAQAJ=
"
rel=3D"nofollow"
onmousedown=3D"this.href=3D'javascript:';return true;"
onclick=3D"this.href=3D'javascript:';return true;">std-=
proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a
moz-do-not-send=3D"true" href=3D"javascript:"
target=3D"_blank" gdf-obfuscated-mailto=3D"kgukxOpXAQAJ=
"
rel=3D"nofollow"
onmousedown=3D"this.href=3D'javascript:';return true;"
onclick=3D"this.href=3D'javascript:';return true;">std-=
pr...@isocpp.org</a>.<br>
To view this discussion on the web visit <a
moz-do-not-send=3D"true"
href=3D"https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/0d627d=
df-dec9-4051-abaf-e6e6f8dbeaaa%40isocpp.org?utm_medium=3Demail&utm_sour=
ce=3Dfooter"
target=3D"_blank" rel=3D"nofollow"
onmousedown=3D"this.href=3D'https://groups.google.com/a/isocpp.org/d/msgid/=
std-proposals/0d627ddf-dec9-4051-abaf-e6e6f8dbeaaa%40isocpp.org?utm_medium\=
x3demail\x26utm_source\x3dfooter';return
true;"
onclick=3D"this.href=3D'https://groups.google.com/a/isocpp.org/d/msgid/std-=
proposals/0d627ddf-dec9-4051-abaf-e6e6f8dbeaaa%40isocpp.org?utm_medium\x3de=
mail\x26utm_source\x3dfooter';return
true;">https://groups.google.com/a/<wbr>isocpp.org/d/ms=
gid/std-<wbr>proposals/0d627ddf-dec9-4051-<wbr>abaf-e6e6f8dbeaaa%40isocpp.o=
rg</a><wbr>.<br>
</div>
</blockquote>
</div>
</blockquote>
</div>
</div>
-- <br>
You received this message because you are subscribed to the Google
Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it,
send an email to <a moz-do-not-send=3D"true"
href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposals+=
unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a moz-do-not-send=3D"true"
href=3D"mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</=
a>.<br>
To view this discussion on the web visit <a
moz-do-not-send=3D"true"
href=3D"https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/686750=
4e-d4e5-4e2b-859c-3040f7cdc05f%40isocpp.org?utm_medium=3Demail&utm_sour=
ce=3Dfooter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/6=
867504e-d4e5-4e2b-859c-3040f7cdc05f%40isocpp.org</a>.<br>
</blockquote>
<br>
<pre class=3D"moz-signature" cols=3D"72">--=20
Simon Brand
Staff Software Engineer
Codeplay Software Ltd
Level C, Argyle House, 3 Lady Lawson St, Edinburgh, EH3 9DR
Tel: 0131 466 0503
Fax: 0131 557 6600
Website: <a class=3D"moz-txt-link-freetext" href=3D"http://www.codeplay.com=
">http://www.codeplay.com</a>
Twitter: <a class=3D"moz-txt-link-freetext" href=3D"https://twitter.com/cod=
eplaysoft">https://twitter.com/codeplaysoft</a>
This email and any attachments may contain confidential and /or privileged =
information and is for use by the addressee only. If you are not the intend=
ed recipient, please notify Codeplay Software Ltd immediately and delete th=
e message from your computer. You may not copy or forward it, or use or dis=
close its contents to any other person. Any views or other information in t=
his message which do not relate to our business are not authorized by Codep=
lay software Ltd, nor does this message form part of any contract unless so=
stated.
As internet communications are capable of data corruption Codeplay Software=
Ltd does not accept any responsibility for any changes made to this messag=
e after it was sent. Please note that Codeplay Software Ltd does not accept=
any liability or responsibility for viruses and it is your responsibility =
to scan any attachments.
Company registered in England and Wales, number: 04567874
Registered office: 81 Linkfield Street, Redhill RH1 6BY </pre>
</body>
</html>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/948ea76d-40a3-b24c-f5d8-25d1e5e6afe2%=
40codeplay.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.googl=
e.com/a/isocpp.org/d/msgid/std-proposals/948ea76d-40a3-b24c-f5d8-25d1e5e6af=
e2%40codeplay.com</a>.<br />
--------------A9C4CF4CD3793FDDC73C4092--
.
Author: Richard Thorell <richard.thorell@king.com>
Date: Wed, 12 Oct 2016 04:23:13 -0700 (PDT)
Raw View
------=_Part_1611_312464263.1476271393943
Content-Type: multipart/alternative;
boundary="----=_Part_1612_521522092.1476271393944"
------=_Part_1612_521522092.1476271393944
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Hi,
Yes, I take that back. Should've been types that supports=20
std::get/std::tuple_size (to little coffee still). But it still requires=20
you to add an overload for your structure right?
With a variadic decomposition you could use any struct without any=20
overloads and you could benefit from all good stuff that std::tuple gives=
=20
you (# of members, compare operators etc.).
Thanks,
Richard
ps. just got another coffee
On Wednesday, October 12, 2016 at 12:13:16 PM UTC+1, Simon Brand wrote:
>
> Hi Richard,
>
> std::apply doesn't just operate on std::tuple; it uses std::get and=20
> std::tuple_size, which is the same method by which you can add structured=
=20
> binding support to your own class (unless the proposal has been updated=
=20
> since I last looked).=20
> Thanks,
> Simon
>
> On 12/10/16 12:09, Richard Thorell wrote:
>
> Hey,=20
>
> Yeah I'm aware of std::apply but it still only operates on std::tuple. If=
=20
> you have your own structure and you want to decompose it, there's no=20
> generic way to do so.
>
> template <class T>
> constexpr auto struct_to_fw_tuple(T& any_struct)
> {
> return std::forward_as_tuple(auto&{...} =3D any_struct);
> }
>
> template <class F, class Tuple>
> constexpr decltype(auto) apply(F&& func, Tuple&& tuple)
> {
> return std::invoke(std::forward<F>(func), auto&&{...} =3D tuple);
> }
>
> The snippet in both post were just examples of usages.
>
> Cheers,
> Richard
>
> On Wednesday, October 12, 2016 at 11:58:31 AM UTC+1, Alisdair Meredith=20
> wrote:=20
>>
>> A library function with these semantics is already present in the C++17=
=20
>> CD, called 'apply'. What benefit do you expect by complicating the=20
>> language with a compiler feature to delivery (mostly) the same effect?
>>
>> (By using the INVOKE treatment, the library version is actually slightly=
=20
>> more capable than a likely language feature, dispatching through=20
>> pointer-to-members etc. as well.)
>>
>> AlisdairM
>>
>> Sent from my iPad
>>
>> On 12 Oct 2016, at 06:51, Richard Thorell <richard...@king.com> wrote:
>>
>> Hey,=20
>>
>> After looking at the structured bindings paper [
>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0144r0.pdf] I=
=20
>> thought, why don't we allow the members to be automatically unpacked int=
o=20
>> it's components and forwarded to a method?
>> We have this functionality when it comes to tuples today, using=20
>> std::get<> and std::index_sequence. But what if it was a built-in langua=
ge=20
>> feature and a one-liner? And worked with any structure!
>>
>> Proposal:
>> template <class... Args>
>> void foo(void(*func)(Args...), std::tuple<Args...> args)
>> {
>> func(auto{ ... } =3D args);
>> }
>> =20
>> The syntax is questionable, but I wanted it to follow the structured=20
>> bindings syntax as close as possible. The auto keyword can have const,=
=20
>> l-value and r-value reference modifiers which will be appended to each=
=20
>> argument. Also, the decomposition can only be used within a=20
>> function/constructor call.
>>
>> Maybe this has already been discussed somewhere?
>>
>> Any feedback is appreciated!
>>
>> Thanks,
>> Richard
>> --=20
>> You received this message because you are subscribed to the Google Group=
s=20
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n=20
>> email to std-proposal...@isocpp.org.
>> To post to this group, send email to std-pr...@isocpp.org.
>> To view this discussion on the web visit=20
>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/0d627ddf-de=
c9-4051-abaf-e6e6f8dbeaaa%40isocpp.org=20
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/0d627ddf-d=
ec9-4051-abaf-e6e6f8dbeaaa%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoo=
ter>
>> .
>>
>> --=20
> You received this message because you are subscribed to the Google Groups=
=20
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an=
=20
> email to std-proposal...@isocpp.org <javascript:>.
> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
> To view this discussion on the web visit=20
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/6867504e-d4e=
5-4e2b-859c-3040f7cdc05f%40isocpp.org=20
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/6867504e-d4=
e5-4e2b-859c-3040f7cdc05f%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoot=
er>
> .
>
>
> --=20
> Simon Brand
> Staff Software Engineer
> Codeplay Software Ltd
> Level C, Argyle House, 3 Lady Lawson St, Edinburgh, EH3 9DR
> Tel: 0131 466 0503
> Fax: 0131 557 6600
> Website: http://www.codeplay.com
> Twitter: https://twitter.com/codeplaysoft
>
> This email and any attachments may contain confidential and /or privilege=
d information and is for use by the addressee only. If you are not the inte=
nded recipient, please notify Codeplay Software Ltd immediately and delete =
the message from your computer. You may not copy or forward it, or use or d=
isclose its contents to any other person. Any views or other information in=
this message which do not relate to our business are not authorized by Cod=
eplay software Ltd, nor does this message form part of any contract unless =
so stated.
> As internet communications are capable of data corruption Codeplay Softwa=
re Ltd does not accept any responsibility for any changes made to this mess=
age after it was sent. Please note that Codeplay Software Ltd does not acce=
pt any liability or responsibility for viruses and it is your responsibilit=
y to scan any attachments.
> Company registered in England and Wales, number: 04567874
> Registered office: 81 Linkfield Street, Redhill RH1 6BY=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/c28ca0ca-b59d-4e06-8c79-52f7cd859a49%40isocpp.or=
g.
------=_Part_1612_521522092.1476271393944
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hi,<div><br></div><div>Yes, I take that back. Should'v=
e been types that supports std::get/std::tuple_size (to little coffee still=
). But it still requires you to add an overload for your structure right?</=
div><div><br></div><div>With a variadic decomposition you could use any str=
uct without any overloads and you could benefit from all good stuff that st=
d::tuple gives you (# of members, compare operators etc.).</div><div><br></=
div><div>Thanks,</div><div>Richard</div><div><br></div><div>ps. just got an=
other coffee<br><br>On Wednesday, October 12, 2016 at 12:13:16 PM UTC+1, Si=
mon Brand wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
=20
=20
=20
<div bgcolor=3D"#FFFFFF" text=3D"#000000">
<p>Hi Richard,<br>
</p>
<p><tt>std::apply</tt> doesn't just operate on <tt>std::tuple</tt>;
it uses <tt>std::get</tt> and <tt>std::tuple_size</tt>, which is
the same method by which you can add structured binding support to
your own class (unless the proposal has been updated since I last
looked).=C2=A0</p>
Thanks,<br>
Simon<br>
<br>
<div>On 12/10/16 12:09, Richard Thorell
wrote:<br>
</div>
<blockquote type=3D"cite">
<div dir=3D"ltr">Hey,
<div><br>
</div>
<div>Yeah I'm aware of std::apply but it still only operates on
std::tuple. If you have your own structure and you want to
decompose it, there's no generic way to do so.</div>
<div><br>
</div>
<div style=3D"background-color:rgb(250,250,250);border-color:rgb(18=
7,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><code>
<div><span style=3D"color:#008">template</span><span style=3D"c=
olor:#000"> </span><span style=3D"color:#660"><</span><span style=3D"col=
or:#008">class</span><span style=3D"color:#000"> T</span><span style=3D"col=
or:#660">></span><span style=3D"color:#000"><br>
</span><span style=3D"color:#008">constexpr</span><span style=
=3D"color:#000"> </span><span style=3D"color:#008">auto</span><span style=
=3D"color:#000">
struct_to_fw_tuple</span><span style=3D"color:#660">(</span=
><span style=3D"color:#000">T</span><span style=3D"color:#660">&</span>=
<span style=3D"color:#000">
any_struct</span><span style=3D"color:#660">)</span><span s=
tyle=3D"color:#000"><br>
</span><span style=3D"color:#660">{</span><span style=3D"colo=
r:#000"><br>
=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</spa=
n><span style=3D"color:#000"> std</span><span style=3D"color:#660">::</span=
><font color=3D"#000000"><span style=3D"color:#000">forward_as_tuple</span>=
<span style=3D"color:#660">(</span><span style=3D"color:#008">auto</span><s=
pan style=3D"color:#660">&{..<wbr>.}</span><span style=3D"color:#000"> =
</span><span style=3D"color:#660">=3D</span><span style=3D"color:#000">
any_struct</span><span style=3D"color:#660">);</span></fo=
nt><span style=3D"color:#000"><br>
</span><span style=3D"color:#660">}</span></div>
</code></div>
<div><br>
<div style=3D"background-color:rgb(250,250,250);border-color:rgb(=
187,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><cod=
e>
<div><span style=3D"color:#008">template</span><span style=3D=
"color:#000"> </span><span style=3D"color:#660"><</span><span style=3D"c=
olor:#008">class</span><span style=3D"color:#000"> F</span><span style=3D"c=
olor:#660">,</span><span style=3D"color:#000"> </span><span style=3D"color:=
#008">class</span><span style=3D"color:#000"> </span><span style=3D"color:#=
606">Tuple</span><span style=3D"color:#660">></span><span style=3D"color=
:#000"><br>
</span><span style=3D"color:#008">constexpr</span><span sty=
le=3D"color:#000"> </span><span style=3D"color:#008">decltype</span><span s=
tyle=3D"color:#660">(</span><span style=3D"color:#008">auto</span><span sty=
le=3D"color:#660">)</span><span style=3D"color:#000"> apply</span><span sty=
le=3D"color:#660">(</span><span style=3D"color:#000">F</span><span style=3D=
"color:#660">&&</span><span style=3D"color:#000"> func</span><span =
style=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=
=3D"color:#606">Tuple</span><span style=3D"color:#660">&&</span><sp=
an style=3D"color:#000"> tuple</span><span style=3D"color:#660">)</span><sp=
an style=3D"color:#000"><br>
</span><span style=3D"color:#660">{</span><span style=3D"co=
lor:#000"><br>
=C2=A0 =C2=A0 </span><span style=3D"color:#008">return</s=
pan><span style=3D"color:#000"> std</span><span style=3D"color:#660">::</sp=
an><span style=3D"color:#000">invoke</span><span style=3D"color:#660">(</sp=
an><span style=3D"color:#000">std</span><span style=3D"color:#660">::</span=
><span style=3D"color:#000">forward</span><span style=3D"color:#660"><</=
span><span style=3D"color:#000">F</span><span style=3D"color:#660">>(</s=
pan><span style=3D"color:#000">fu<wbr>nc</span><span style=3D"color:#660">)=
,</span><span style=3D"color:#000"> </span><span style=3D"color:#008">auto<=
/span><span style=3D"color:#660">&&{</span><font color=3D"#000000">=
<span style=3D"color:#660">...}</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#660">=3D</span><span style=3D"color:#000">
tuple</span><span style=3D"color:#660">);</span></font>=
<span style=3D"color:#000"><br>
</span><span style=3D"color:#660">}</span></div>
</code></div>
<div><br>
</div>
The snippet in both post were just examples of usages.</div>
<div><br>
</div>
<div>Cheers,</div>
<div>Richard<br>
<br>
On Wednesday, October 12, 2016 at 11:58:31 AM UTC+1, Alisdair
Meredith wrote:
<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0=
..8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"auto">
<div>
<div style=3D"direction:inherit">A library function with
these semantics is already present in the C++17 CD,
called 'apply'. =C2=A0What benefit do you expect =
by
complicating the language with a compiler feature to
delivery (mostly) the same effect?</div>
<div style=3D"direction:inherit"><br>
</div>
<div style=3D"direction:inherit">(By using the INVOKE
treatment, the library version is actually slightly
more capable than a likely language feature,
dispatching through pointer-to-members etc. as well.)</di=
v>
<div style=3D"direction:inherit"><br>
</div>
<div style=3D"direction:inherit">AlisdairM</div>
<br>
Sent from my iPad</div>
<div><br>
On 12 Oct 2016, at 06:51, Richard Thorell <<a rel=3D"nof=
ollow">richard...@king.com</a>>
wrote:<br>
<br>
</div>
<blockquote type=3D"cite">
<div>
<div dir=3D"ltr">Hey,
<div>
<div><br>
</div>
<div>After looking at the structured bindings
paper [<a href=3D"http://www.open-std.org/jtc1/sc22=
/wg21/docs/papers/2015/p0144r0.pdf" rel=3D"nofollow" target=3D"_blank" onmo=
usedown=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww=
..open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2015%2Fp0144r0.pdf\x26=
sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG1MKJjnldtN4lm6MvN4r0b6M0ewA';retu=
rn true;" onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3=
A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2015%2Fp0144=
r0.pdf\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG1MKJjnldtN4lm6MvN4r0b6M0ewA=
';return true;">http://www.open-std.org/jtc1/<wbr>sc22/wg21/docs/papers=
/2015/<wbr>p0144r0.pdf</a>]
I thought, why don't we allow the members to be
automatically unpacked into it's components and
forwarded to a method?</div>
<div>We have this functionality when it comes to
tuples today, using std::get<> and
std::index_sequence. But what if it was a
built-in language feature and a one-liner? And
worked with any structure!<br>
</div>
<div><br>
</div>
<div>Proposal:</div>
</div>
<div style=3D"background-color:rgb(250,250,250);border-=
color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-=
word"><code>
<div><span style=3D"color:#008">template</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#660"><</span><span =
style=3D"color:#008">class</span><span style=3D"color:#660">...</span><span=
style=3D"color:#000"> </span><span style=3D"color:#606">Args</span><span s=
tyle=3D"color:#660">></span><span style=3D"color:#000"><br>
</span><span style=3D"color:#008">void</span><spa=
n style=3D"color:#000"> foo</span><span style=3D"color:#660">(</span><span =
style=3D"color:#008">void</span><span style=3D"color:#660">(*</span><span s=
tyle=3D"color:#000">func</span><span style=3D"color:#660">)(</span><span st=
yle=3D"color:#606">Args</span><span style=3D"color:#660">...),</span><span =
style=3D"color:#000"> std</span><span style=3D"color:#660">::</span><span s=
tyle=3D"color:#000">tuple</span><span style=3D"color:#660"><</span><span=
style=3D"color:#606">Args</span><span style=3D"color:#660">...></span><=
span style=3D"color:#000"> args</span><span style=3D"color:#660">)</span><s=
pan style=3D"color:#000"><br>
</span><span style=3D"color:#660">{</span><span s=
tyle=3D"color:#000"><br>
=C2=A0 =C2=A0 func</span><span style=3D"color:#=
660">(</span><span style=3D"color:#008">auto</span><span style=3D"color:#66=
0">{</span><span style=3D"color:#000"> </span><span style=3D"color:#660">..=
..</span><span style=3D"color:#000"> </span><span style=3D"color:#660">}</sp=
an><span style=3D"color:#000"> </span><span style=3D"color:#660">=3D</span>=
<span style=3D"color:#000"> args</span><span style=3D"color:#660">);</span>=
<span style=3D"color:#000"><br>
</span><span style=3D"color:#660">}</span></div>
</code></div>
<div>=C2=A0</div>
<div>The syntax is questionable, but I wanted it to
follow the structured bindings syntax as close as
possible. The auto keyword can have const, l-value
and r-value reference modifiers which will be
appended to each argument. Also, the decomposition
can only be used within a function/constructor
call.</div>
<div><br>
</div>
<div>Maybe this has already been discussed
somewhere?</div>
<div><br>
</div>
<div>Any feedback is appreciated!</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Richard</div>
</div>
-- <br>
You received this message because you are subscribed
to the Google Groups "ISO C++ Standard - Future
Proposals" group.<br>
To unsubscribe from this group and stop receiving
emails from it, send an email to <a rel=3D"nofollow">std-=
proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a rel=3D"nofollow">=
std-pr...@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https=
://groups.google.com/a/isocpp.org/d/msgid/std-proposals/0d627ddf-dec9-4051-=
abaf-e6e6f8dbeaaa%40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" =
rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D'https://=
groups.google.com/a/isocpp.org/d/msgid/std-proposals/0d627ddf-dec9-4051-aba=
f-e6e6f8dbeaaa%40isocpp.org?utm_medium\x3demail\x26utm_source\x3dfooter'=
;;return true;" onclick=3D"this.href=3D'https://groups.google.com/a/iso=
cpp.org/d/msgid/std-proposals/0d627ddf-dec9-4051-abaf-e6e6f8dbeaaa%40isocpp=
..org?utm_medium\x3demail\x26utm_source\x3dfooter';return true;">https:/=
/groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/0d627ddf-de=
c9-4051-<wbr>abaf-e6e6f8dbeaaa%40isocpp.org</a><wbr>.<br>
</div>
</blockquote>
</div>
</blockquote>
</div>
</div>
-- <br>
You received this message because you are subscribed to the Google
Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it,
send an email to <a href=3D"javascript:" target=3D"_blank" gdf-obfusc=
ated-mailto=3D"b1x0_rhYAQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#=
39;javascript:';return true;" onclick=3D"this.href=3D'javascript:&#=
39;;return true;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=
=3D"_blank" gdf-obfuscated-mailto=3D"b1x0_rhYAQAJ" rel=3D"nofollow" onmouse=
down=3D"this.href=3D'javascript:';return true;" onclick=3D"this.hre=
f=3D'javascript:';return true;">std-pr...@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.go=
ogle.com/a/isocpp.org/d/msgid/std-proposals/6867504e-d4e5-4e2b-859c-3040f7c=
dc05f%40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_b=
lank" rel=3D"nofollow" onmousedown=3D"this.href=3D'https://groups.googl=
e.com/a/isocpp.org/d/msgid/std-proposals/6867504e-d4e5-4e2b-859c-3040f7cdc0=
5f%40isocpp.org?utm_medium\x3demail\x26utm_source\x3dfooter';return tru=
e;" onclick=3D"this.href=3D'https://groups.google.com/a/isocpp.org/d/ms=
gid/std-proposals/6867504e-d4e5-4e2b-859c-3040f7cdc05f%40isocpp.org?utm_med=
ium\x3demail\x26utm_source\x3dfooter';return true;">https://groups.goog=
le.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/6867504e-d4e5-4e2b-<wbr=
>859c-3040f7cdc05f%40isocpp.org</a><wbr>.<br>
</blockquote>
<br>
<pre cols=3D"72">--=20
Simon Brand
Staff Software Engineer
Codeplay Software Ltd
Level C, Argyle House, 3 Lady Lawson St, Edinburgh, EH3 9DR
Tel: 0131 466 0503
Fax: 0131 557 6600
Website: <a href=3D"http://www.codeplay.com" target=3D"_blank" rel=3D"nofol=
low" onmousedown=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A=
%2F%2Fwww.codeplay.com\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEPP-Z-LmQScR=
yZl0Qs6WGmnQhbbQ';return true;" onclick=3D"this.href=3D'http://www.=
google.com/url?q\x3dhttp%3A%2F%2Fwww.codeplay.com\x26sa\x3dD\x26sntz\x3d1\x=
26usg\x3dAFQjCNEPP-Z-LmQScRyZl0Qs6WGmnQhbbQ';return true;">http://www.c=
odeplay.com</a>
Twitter: <a href=3D"https://twitter.com/codeplaysoft" target=3D"_blank" rel=
=3D"nofollow" onmousedown=3D"this.href=3D'https://www.google.com/url?q\=
x3dhttps%3A%2F%2Ftwitter.com%2Fcodeplaysoft\x26sa\x3dD\x26sntz\x3d1\x26usg\=
x3dAFQjCNGRmr12ghhIG15wbFm_KSYscMZftw';return true;" onclick=3D"this.hr=
ef=3D'https://www.google.com/url?q\x3dhttps%3A%2F%2Ftwitter.com%2Fcodep=
laysoft\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGRmr12ghhIG15wbFm_KSYscMZft=
w';return true;">https://twitter.com/<wbr>codeplaysoft</a>
This email and any attachments may contain confidential and /or privileged =
information and is for use by the addressee only. If you are not the intend=
ed recipient, please notify Codeplay Software Ltd immediately and delete th=
e message from your computer. You may not copy or forward it, or use or dis=
close its contents to any other person. Any views or other information in t=
his message which do not relate to our business are not authorized by Codep=
lay software Ltd, nor does this message form part of any contract unless so=
stated.
As internet communications are capable of data corruption Codeplay Software=
Ltd does not accept any responsibility for any changes made to this messag=
e after it was sent. Please note that Codeplay Software Ltd does not accept=
any liability or responsibility for viruses and it is your responsibility =
to scan any attachments.
Company registered in England and Wales, number: 04567874
Registered office: 81 Linkfield Street, Redhill RH1 6BY </pre>
</div>
</blockquote></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/c28ca0ca-b59d-4e06-8c79-52f7cd859a49%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/c28ca0ca-b59d-4e06-8c79-52f7cd859a49=
%40isocpp.org</a>.<br />
------=_Part_1612_521522092.1476271393944--
------=_Part_1611_312464263.1476271393943--
.
Author: Simon Brand <simon@codeplay.com>
Date: Wed, 12 Oct 2016 12:30:57 +0100
Raw View
This is a multi-part message in MIME format.
--------------3606974F709600A44B2FC220
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
I believe that with variadic decomposition you would only be able to use=20
it for classes which only have public member data (or have those data=20
members in a single direct base class). For any class without that=20
property, you'd still need to write implementations of get and=20
tuple_size. So the main benefit of your suggestion would be removing the=20
need to implement a couple of functions for a small set of classes, but=20
to get that it's mandating a language change and some new syntax.
I do like the idea of the proposal, but I think that the costs outweigh=20
the benefits over the std::apply solution.
On 12/10/16 12:23, Richard Thorell wrote:
> Hi,
>
> Yes, I take that back. Should've been types that supports=20
> std::get/std::tuple_size (to little coffee still). But it still=20
> requires you to add an overload for your structure right?
>
> With a variadic decomposition you could use any struct without any=20
> overloads and you could benefit from all good stuff that std::tuple=20
> gives you (# of members, compare operators etc.).
>
> Thanks,
> Richard
>
> ps. just got another coffee
>
> On Wednesday, October 12, 2016 at 12:13:16 PM UTC+1, Simon Brand wrote:
>
> Hi Richard,
>
> std::apply doesn't just operate on std::tuple; it uses std::get
> and std::tuple_size, which is the same method by which you can add
> structured binding support to your own class (unless the proposal
> has been updated since I last looked).
>
> Thanks,
> Simon
>
> On 12/10/16 12:09, Richard Thorell wrote:
>> Hey,
>>
>> Yeah I'm aware of std::apply but it still only operates on
>> std::tuple. If you have your own structure and you want to
>> decompose it, there's no generic way to do so.
>>
>> |
>> template<classT>
>> constexprautostruct_to_fw_tuple(T&any_struct)
>> {
>> returnstd::forward_as_tuple(auto&{...}=3Dany_struct);
>> }
>> |
>>
>> |
>> template<classF,classTuple>
>> constexprdecltype(auto)apply(F&&func,Tuple&&tuple)
>> {
>> returnstd::invoke(std::forward<F>(func),auto&&{...}=3Dtuple);
>> }
>> |
>>
>> The snippet in both post were just examples of usages.
>>
>> Cheers,
>> Richard
>>
>> On Wednesday, October 12, 2016 at 11:58:31 AM UTC+1, Alisdair
>> Meredith wrote:
>>
>> A library function with these semantics is already present in
>> the C++17 CD, called 'apply'. What benefit do you expect by
>> complicating the language with a compiler feature to delivery
>> (mostly) the same effect?
>>
>> (By using the INVOKE treatment, the library version is
>> actually slightly more capable than a likely language
>> feature, dispatching through pointer-to-members etc. as well.)
>>
>> AlisdairM
>>
>> Sent from my iPad
>>
>> On 12 Oct 2016, at 06:51, Richard Thorell
>> <richard...@king.com> wrote:
>>
>>> Hey,
>>>
>>> After looking at the structured bindings paper
>>> [http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0144r=
0.pdf
>>> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0144r=
0.pdf>]
>>> I thought, why don't we allow the members to be
>>> automatically unpacked into it's components and forwarded to
>>> a method?
>>> We have this functionality when it comes to tuples today,
>>> using std::get<> and std::index_sequence. But what if it was
>>> a built-in language feature and a one-liner? And worked with
>>> any structure!
>>>
>>> Proposal:
>>> |
>>> template<class...Args>
>>> voidfoo(void(*func)(Args...),std::tuple<Args...>args)
>>> {
>>> func(auto{...}=3Dargs);
>>> }
>>> |
>>> The syntax is questionable, but I wanted it to follow the
>>> structured bindings syntax as close as possible. The auto
>>> keyword can have const, l-value and r-value reference
>>> modifiers which will be appended to each argument. Also, the
>>> decomposition can only be used within a function/constructor
>>> call.
>>>
>>> Maybe this has already been discussed somewhere?
>>>
>>> Any feedback is appreciated!
>>>
>>> Thanks,
>>> Richard
>>> --=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 email to std-proposal...@isocpp.org.
>>> To post to this group, send email to std-pr...@isocpp.org.
>>> To view this discussion on the web visit
>>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/0d=
627ddf-dec9-4051-abaf-e6e6f8dbeaaa%40isocpp.org
>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/0=
d627ddf-dec9-4051-abaf-e6e6f8dbeaaa%40isocpp.org?utm_medium=3Demail&utm_sou=
rce=3Dfooter>.
>>
>> --=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 email to std-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org
>> <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/6867504=
e-d4e5-4e2b-859c-3040f7cdc05f%40isocpp.org
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/686750=
4e-d4e5-4e2b-859c-3040f7cdc05f%40isocpp.org?utm_medium=3Demail&utm_source=
=3Dfooter>.
>
> --=20
> Simon Brand
> Staff Software Engineer
> Codeplay Software Ltd
> Level C, Argyle House, 3 Lady Lawson St, Edinburgh, EH3 9DR
> Tel: 0131 466 0503
> Fax: 0131 557 6600
> Website:http://www.codeplay.com
> Twitter:https://twitter.com/codeplaysoft <https://twitter.com/codepla=
ysoft>
>
> This email and any attachments may contain confidential and /or privi=
leged information and is for use by the addressee only. If you are not the =
intended recipient, please notify Codeplay Software Ltd immediately and del=
ete the message from your computer. You may not copy or forward it, or use =
or disclose its contents to any other person. Any views or other informatio=
n in this message which do not relate to our business are not authorized by=
Codeplay software Ltd, nor does this message form part of any contract unl=
ess so stated.
> As internet communications are capable of data corruption Codeplay So=
ftware Ltd does not accept any responsibility for any changes made to this =
message after it was sent. Please note that Codeplay Software Ltd does not =
accept any liability or responsibility for viruses and it is your responsib=
ility to scan any attachments.
> Company registered in England and Wales, number: 04567874
> Registered office: 81 Linkfield Street, Redhill RH1 6BY
>
> -- You received this message because you are subscribed to the Google=20
> Groups "ISO C++ Standard - Future Proposals" group. To unsubscribe=20
> from this group and stop receiving emails from it, send an email to=20
> std-proposals+unsubscribe@isocpp.org=20
> <mailto:std-proposals+unsubscribe@isocpp.org>. To post to this group,=20
> send email to std-proposals@isocpp.org=20
> <mailto:std-proposals@isocpp.org>. To view this discussion on the web=20
> visit=20
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/c28ca0ca-b59=
d-4e06-8c79-52f7cd859a49%40isocpp.org=20
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/c28ca0ca-b5=
9d-4e06-8c79-52f7cd859a49%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoot=
er>.=20
--=20
Simon Brand
Staff Software Engineer
Codeplay Software Ltd
Level C, Argyle House, 3 Lady Lawson St, Edinburgh, EH3 9DR
Tel: 0131 466 0503
Fax: 0131 557 6600
Website: http://www.codeplay.com
Twitter: https://twitter.com/codeplaysoft
This email and any attachments may contain confidential and /or privileged =
information and is for use by the addressee only. If you are not the intend=
ed recipient, please notify Codeplay Software Ltd immediately and delete th=
e message from your computer. You may not copy or forward it, or use or dis=
close its contents to any other person. Any views or other information in t=
his message which do not relate to our business are not authorized by Codep=
lay software Ltd, nor does this message form part of any contract unless so=
stated.
As internet communications are capable of data corruption Codeplay Software=
Ltd does not accept any responsibility for any changes made to this messag=
e after it was sent. Please note that Codeplay Software Ltd does not accept=
any liability or responsibility for viruses and it is your responsibility =
to scan any attachments.
Company registered in England and Wales, number: 04567874
Registered office: 81 Linkfield Street, Redhill RH1 6BY
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/bf68a3f3-79af-eac4-4a04-f1be2920ded7%40codeplay.=
com.
--------------3606974F709600A44B2FC220
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">
<p>I believe that with variadic decomposition you would only be able
to use it for classes which only have public member data (or have
those data members in a single direct base class). For any class
without that property, you'd still need to write implementations
of <tt>get </tt>and <tt>tuple_size</tt>. So the main benefit of
your suggestion would be removing the need to implement a couple
of functions for a small set of classes, but to get that it's
mandating a language change and some new syntax.</p>
<p>I do like the idea of the proposal, but I think that the costs
outweigh the benefits over the <tt>std::apply</tt> solution.<br>
</p>
<div class=3D"moz-cite-prefix">On 12/10/16 12:23, Richard Thorell
wrote:<br>
</div>
<blockquote
cite=3D"mid:c28ca0ca-b59d-4e06-8c79-52f7cd859a49@isocpp.org"
type=3D"cite">
<div dir=3D"ltr">Hi,
<div><br>
</div>
<div>Yes, I take that back. Should've been types that supports
std::get/std::tuple_size (to little coffee still). But it
still requires you to add an overload for your structure
right?</div>
<div><br>
</div>
<div>With a variadic decomposition you could use any struct
without any overloads and you could benefit from all good
stuff that std::tuple gives you (# of members, compare
operators etc.).</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Richard</div>
<div><br>
</div>
<div>ps. just got another coffee<br>
<br>
On Wednesday, October 12, 2016 at 12:13:16 PM UTC+1, Simon
Brand 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">
<p>Hi Richard,<br>
</p>
<p><tt>std::apply</tt> doesn't just operate on <tt>std::tuple=
</tt>;
it uses <tt>std::get</tt> and <tt>std::tuple_size</tt>,
which is the same method by which you can add structured
binding support to your own class (unless the proposal
has been updated since I last looked).=C2=A0</p>
Thanks,<br>
Simon<br>
<br>
<div>On 12/10/16 12:09, Richard Thorell wrote:<br>
</div>
<blockquote type=3D"cite">
<div dir=3D"ltr">Hey,
<div><br>
</div>
<div>Yeah I'm aware of std::apply but it still only
operates on std::tuple. If you have your own
structure and you want to decompose it, there's no
generic way to do so.</div>
<div><br>
</div>
<div
style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);bo=
rder-style:solid;border-width:1px;word-wrap:break-word"><code>
<div><span style=3D"color:#008">template</span><span
style=3D"color:#000"> </span><span
style=3D"color:#660"><</span><span
style=3D"color:#008">class</span><span
style=3D"color:#000"> T</span><span
style=3D"color:#660">></span><span
style=3D"color:#000"><br>
</span><span style=3D"color:#008">constexpr</span><=
span
style=3D"color:#000"> </span><span
style=3D"color:#008">auto</span><span
style=3D"color:#000"> struct_to_fw_tuple</span><s=
pan
style=3D"color:#660">(</span><span
style=3D"color:#000">T</span><span
style=3D"color:#660">&</span><span
style=3D"color:#000"> any_struct</span><span
style=3D"color:#660">)</span><span
style=3D"color:#000"><br>
</span><span style=3D"color:#660">{</span><span
style=3D"color:#000"><br>
=C2=A0 =C2=A0 </span><span style=3D"color:#008">r=
eturn</span><span
style=3D"color:#000"> std</span><span
style=3D"color:#660">::</span><font
color=3D"#000000"><span style=3D"color:#000">forw=
ard_as_tuple</span><span
style=3D"color:#660">(</span><span
style=3D"color:#008">auto</span><span
style=3D"color:#660">&{..<wbr>.}</span><spa=
n
style=3D"color:#000"> </span><span
style=3D"color:#660">=3D</span><span
style=3D"color:#000"> any_struct</span><span
style=3D"color:#660">);</span></font><span
style=3D"color:#000"><br>
</span><span style=3D"color:#660">}</span></div>
</code></div>
<div><br>
<div
style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);bo=
rder-style:solid;border-width:1px;word-wrap:break-word"><code>
<div><span style=3D"color:#008">template</span><spa=
n
style=3D"color:#000"> </span><span
style=3D"color:#660"><</span><span
style=3D"color:#008">class</span><span
style=3D"color:#000"> F</span><span
style=3D"color:#660">,</span><span
style=3D"color:#000"> </span><span
style=3D"color:#008">class</span><span
style=3D"color:#000"> </span><span
style=3D"color:#606">Tuple</span><span
style=3D"color:#660">></span><span
style=3D"color:#000"><br>
</span><span style=3D"color:#008">constexpr</span=
><span
style=3D"color:#000"> </span><span
style=3D"color:#008">decltype</span><span
style=3D"color:#660">(</span><span
style=3D"color:#008">auto</span><span
style=3D"color:#660">)</span><span
style=3D"color:#000"> apply</span><span
style=3D"color:#660">(</span><span
style=3D"color:#000">F</span><span
style=3D"color:#660">&&</span><span
style=3D"color:#000"> func</span><span
style=3D"color:#660">,</span><span
style=3D"color:#000"> </span><span
style=3D"color:#606">Tuple</span><span
style=3D"color:#660">&&</span><span
style=3D"color:#000"> tuple</span><span
style=3D"color:#660">)</span><span
style=3D"color:#000"><br>
</span><span style=3D"color:#660">{</span><span
style=3D"color:#000"><br>
=C2=A0 =C2=A0 </span><span style=3D"color:#008"=
>return</span><span
style=3D"color:#000"> std</span><span
style=3D"color:#660">::</span><span
style=3D"color:#000">invoke</span><span
style=3D"color:#660">(</span><span
style=3D"color:#000">std</span><span
style=3D"color:#660">::</span><span
style=3D"color:#000">forward</span><span
style=3D"color:#660"><</span><span
style=3D"color:#000">F</span><span
style=3D"color:#660">>(</span><span
style=3D"color:#000">fu<wbr>nc</span><span
style=3D"color:#660">),</span><span
style=3D"color:#000"> </span><span
style=3D"color:#008">auto</span><span
style=3D"color:#660">&&{</span><font
color=3D"#000000"><span style=3D"color:#660">..=
..}</span><span
style=3D"color:#000"> </span><span
style=3D"color:#660">=3D</span><span
style=3D"color:#000"> tuple</span><span
style=3D"color:#660">);</span></font><span
style=3D"color:#000"><br>
</span><span style=3D"color:#660">}</span></div>
</code></div>
<div><br>
</div>
The snippet in both post were just examples of
usages.</div>
<div><br>
</div>
<div>Cheers,</div>
<div>Richard<br>
<br>
On Wednesday, October 12, 2016 at 11:58:31 AM UTC+1,
Alisdair Meredith wrote:
<blockquote class=3D"gmail_quote"
style=3D"margin:0;margin-left:0.8ex;border-left:1px
#ccc solid;padding-left:1ex">
<div dir=3D"auto">
<div>
<div style=3D"direction:inherit">A library
function with these semantics is already
present in the C++17 CD, called 'apply'.
=C2=A0What benefit do you expect by complicatin=
g
the language with a compiler feature to
delivery (mostly) the same effect?</div>
<div style=3D"direction:inherit"><br>
</div>
<div style=3D"direction:inherit">(By using the
INVOKE treatment, the library version is
actually slightly more capable than a likely
language feature, dispatching through
pointer-to-members etc. as well.)</div>
<div style=3D"direction:inherit"><br>
</div>
<div style=3D"direction:inherit">AlisdairM</div>
<br>
Sent from my iPad</div>
<div><br>
On 12 Oct 2016, at 06:51, Richard Thorell <<a
moz-do-not-send=3D"true" rel=3D"nofollow">richa=
rd...@king.com</a>>
wrote:<br>
<br>
</div>
<blockquote type=3D"cite">
<div>
<div dir=3D"ltr">Hey,
<div>
<div><br>
</div>
<div>After looking at the structured
bindings paper [<a
moz-do-not-send=3D"true"
href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0144r0.pdf=
"
rel=3D"nofollow" target=3D"_blank"
onmousedown=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww=
..open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2015%2Fp0144r0.pdf\x26=
sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG1MKJjnldtN4lm6MvN4r0b6M0ewA';return
true;"
onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.ope=
n-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2015%2Fp0144r0.pdf\x26sa\x=
3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG1MKJjnldtN4lm6MvN4r0b6M0ewA';return
true;">http://www.open-std.org/jtc1/<wb=
r>sc22/wg21/docs/papers/2015/<wbr>p0144r0.pdf</a>]
I thought, why don't we allow the
members to be automatically unpacked
into it's components and forwarded to
a method?</div>
<div>We have this functionality when it
comes to tuples today, using
std::get<> and
std::index_sequence. But what if it
was a built-in language feature and a
one-liner? And worked with any
structure!<br>
</div>
<div><br>
</div>
<div>Proposal:</div>
</div>
<div
style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);bo=
rder-style:solid;border-width:1px;word-wrap:break-word"><code>
<div><span style=3D"color:#008">template<=
/span><span
style=3D"color:#000"> </span><span
style=3D"color:#660"><</span><span
style=3D"color:#008">class</span><spa=
n
style=3D"color:#660">...</span><span
style=3D"color:#000"> </span><span
style=3D"color:#606">Args</span><span
style=3D"color:#660">></span><span
style=3D"color:#000"><br>
</span><span style=3D"color:#008">void<=
/span><span
style=3D"color:#000"> foo</span><span
style=3D"color:#660">(</span><span
style=3D"color:#008">void</span><span
style=3D"color:#660">(*</span><span
style=3D"color:#000">func</span><span
style=3D"color:#660">)(</span><span
style=3D"color:#606">Args</span><span
style=3D"color:#660">...),</span><spa=
n
style=3D"color:#000"> std</span><span
style=3D"color:#660">::</span><span
style=3D"color:#000">tuple</span><spa=
n
style=3D"color:#660"><</span><span
style=3D"color:#606">Args</span><span
style=3D"color:#660">...></span><s=
pan
style=3D"color:#000"> args</span><spa=
n
style=3D"color:#660">)</span><span
style=3D"color:#000"><br>
</span><span style=3D"color:#660">{</sp=
an><span
style=3D"color:#000"><br>
=C2=A0 =C2=A0 func</span><span
style=3D"color:#660">(</span><span
style=3D"color:#008">auto</span><span
style=3D"color:#660">{</span><span
style=3D"color:#000"> </span><span
style=3D"color:#660">...</span><span
style=3D"color:#000"> </span><span
style=3D"color:#660">}</span><span
style=3D"color:#000"> </span><span
style=3D"color:#660">=3D</span><span
style=3D"color:#000"> args</span><spa=
n
style=3D"color:#660">);</span><span
style=3D"color:#000"><br>
</span><span style=3D"color:#660">}</sp=
an></div>
</code></div>
<div>=C2=A0</div>
<div>The syntax is questionable, but I
wanted it to follow the structured
bindings syntax as close as possible.
The auto keyword can have const, l-value
and r-value reference modifiers which
will be appended to each argument. Also,
the decomposition can only be used
within a function/constructor call.</div>
<div><br>
</div>
<div>Maybe this has already been discussed
somewhere?</div>
<div><br>
</div>
<div>Any feedback is appreciated!</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Richard</div>
</div>
-- <br>
You received this message because you are
subscribed to the Google Groups "ISO C++
Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop
receiving emails from it, send an email to <a
moz-do-not-send=3D"true" rel=3D"nofollow">std=
-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a
moz-do-not-send=3D"true" rel=3D"nofollow">std=
-pr...@isocpp.org</a>.<br>
To view this discussion on the web visit <a
moz-do-not-send=3D"true"
href=3D"https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/0d627d=
df-dec9-4051-abaf-e6e6f8dbeaaa%40isocpp.org?utm_medium=3Demail&utm_sour=
ce=3Dfooter"
rel=3D"nofollow" target=3D"_blank"
onmousedown=3D"this.href=3D'https://groups.google.com/a/isocpp.org/d/msgid/=
std-proposals/0d627ddf-dec9-4051-abaf-e6e6f8dbeaaa%40isocpp.org?utm_medium\=
x3demail\x26utm_source\x3dfooter';return
true;"
onclick=3D"this.href=3D'https://groups.google.com/a/isocpp.org/d/msgid/std-=
proposals/0d627ddf-dec9-4051-abaf-e6e6f8dbeaaa%40isocpp.org?utm_medium\x3de=
mail\x26utm_source\x3dfooter';return
true;">https://groups.google.com/a/<wbr>isocp=
p.org/d/msgid/std-<wbr>proposals/0d627ddf-dec9-4051-<wbr>abaf-e6e6f8dbeaaa%=
40isocpp.org</a><wbr>.<br>
</div>
</blockquote>
</div>
</blockquote>
</div>
</div>
-- <br>
You received this message because you are subscribed to
the Google Groups "ISO C++ Standard - Future Proposals"
group.<br>
To unsubscribe from this group and stop receiving emails
from it, send an email to <a moz-do-not-send=3D"true"
href=3D"javascript:" target=3D"_blank"
gdf-obfuscated-mailto=3D"b1x0_rhYAQAJ" rel=3D"nofollow"
onmousedown=3D"this.href=3D'javascript:';return true;"
onclick=3D"this.href=3D'javascript:';return true;">std-pr=
oposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a
moz-do-not-send=3D"true" href=3D"javascript:"
target=3D"_blank" gdf-obfuscated-mailto=3D"b1x0_rhYAQAJ"
rel=3D"nofollow"
onmousedown=3D"this.href=3D'javascript:';return true;"
onclick=3D"this.href=3D'javascript:';return true;">std-pr=
....@isocpp.org</a>.<br>
To view this discussion on the web visit <a
moz-do-not-send=3D"true"
href=3D"https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/686750=
4e-d4e5-4e2b-859c-3040f7cdc05f%40isocpp.org?utm_medium=3Demail&utm_sour=
ce=3Dfooter"
target=3D"_blank" rel=3D"nofollow"
onmousedown=3D"this.href=3D'https://groups.google.com/a/isocpp.org/d/msgid/=
std-proposals/6867504e-d4e5-4e2b-859c-3040f7cdc05f%40isocpp.org?utm_medium\=
x3demail\x26utm_source\x3dfooter';return
true;"
onclick=3D"this.href=3D'https://groups.google.com/a/isocpp.org/d/msgid/std-=
proposals/6867504e-d4e5-4e2b-859c-3040f7cdc05f%40isocpp.org?utm_medium\x3de=
mail\x26utm_source\x3dfooter';return
true;">https://groups.google.com/a/<wbr>isocpp.org/d/msgi=
d/std-<wbr>proposals/6867504e-d4e5-4e2b-<wbr>859c-3040f7cdc05f%40isocpp.org=
</a><wbr>.<br>
</blockquote>
<br>
<pre cols=3D"72">--=20
Simon Brand
Staff Software Engineer
Codeplay Software Ltd
Level C, Argyle House, 3 Lady Lawson St, Edinburgh, EH3 9DR
Tel: 0131 466 0503
Fax: 0131 557 6600
Website: <a moz-do-not-send=3D"true" href=3D"http://www.codeplay.com" targe=
t=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www.google=
..com/url?q\x3dhttp%3A%2F%2Fwww.codeplay.com\x26sa\x3dD\x26sntz\x3d1\x26usg\=
x3dAFQjCNEPP-Z-LmQScRyZl0Qs6WGmnQhbbQ';return true;" onclick=3D"this.href=
=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.codeplay.com\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNEPP-Z-LmQScRyZl0Qs6WGmnQhbbQ';return true;">h=
ttp://www.codeplay.com</a>
Twitter: <a moz-do-not-send=3D"true" href=3D"https://twitter.com/codeplayso=
ft" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'https://=
www.google.com/url?q\x3dhttps%3A%2F%2Ftwitter.com%2Fcodeplaysoft\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNGRmr12ghhIG15wbFm_KSYscMZftw';return true;" o=
nclick=3D"this.href=3D'https://www.google.com/url?q\x3dhttps%3A%2F%2Ftwitte=
r.com%2Fcodeplaysoft\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGRmr12ghhIG15w=
bFm_KSYscMZftw';return true;">https://twitter.com/<wbr>codeplaysoft</a>
This email and any attachments may contain confidential and /or privileged =
information and is for use by the addressee only. If you are not the intend=
ed recipient, please notify Codeplay Software Ltd immediately and delete th=
e message from your computer. You may not copy or forward it, or use or dis=
close its contents to any other person. Any views or other information in t=
his message which do not relate to our business are not authorized by Codep=
lay software Ltd, nor does this message form part of any contract unless so=
stated.
As internet communications are capable of data corruption Codeplay Software=
Ltd does not accept any responsibility for any changes made to this messag=
e after it was sent. Please note that Codeplay Software Ltd does not accept=
any liability or responsibility for viruses and it is your responsibility =
to scan any attachments.
Company registered in England and Wales, number: 04567874
Registered office: 81 Linkfield Street, Redhill RH1 6BY </pre>
</div>
</blockquote></div></div>
--=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 <a moz-do-not-send=3D"true" href=3D"mailto:std-proposals+unsubscrib=
e@isocpp.org">std-proposals+unsubscribe@isocpp.org</a>.
To post to this group, send email to <a moz-do-not-send=3D"true" href=3D"ma=
ilto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>.
To view this discussion on the web visit <a moz-do-not-send=3D"true" href=
=3D"https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/c28ca0ca-b=
59d-4e06-8c79-52f7cd859a49%40isocpp.org?utm_medium=3Demail&utm_source=
=3Dfooter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/c28=
ca0ca-b59d-4e06-8c79-52f7cd859a49%40isocpp.org</a>.
</blockquote>
<pre class=3D"moz-signature" cols=3D"72">--=20
Simon Brand
Staff Software Engineer
Codeplay Software Ltd
Level C, Argyle House, 3 Lady Lawson St, Edinburgh, EH3 9DR
Tel: 0131 466 0503
Fax: 0131 557 6600
Website: <a class=3D"moz-txt-link-freetext" href=3D"http://www.codeplay.com=
">http://www.codeplay.com</a>
Twitter: <a class=3D"moz-txt-link-freetext" href=3D"https://twitter.com/cod=
eplaysoft">https://twitter.com/codeplaysoft</a>
This email and any attachments may contain confidential and /or privileged =
information and is for use by the addressee only. If you are not the intend=
ed recipient, please notify Codeplay Software Ltd immediately and delete th=
e message from your computer. You may not copy or forward it, or use or dis=
close its contents to any other person. Any views or other information in t=
his message which do not relate to our business are not authorized by Codep=
lay software Ltd, nor does this message form part of any contract unless so=
stated.
As internet communications are capable of data corruption Codeplay Software=
Ltd does not accept any responsibility for any changes made to this messag=
e after it was sent. Please note that Codeplay Software Ltd does not accept=
any liability or responsibility for viruses and it is your responsibility =
to scan any attachments.
Company registered in England and Wales, number: 04567874
Registered office: 81 Linkfield Street, Redhill RH1 6BY </pre></body></html=
>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/bf68a3f3-79af-eac4-4a04-f1be2920ded7%=
40codeplay.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.googl=
e.com/a/isocpp.org/d/msgid/std-proposals/bf68a3f3-79af-eac4-4a04-f1be2920de=
d7%40codeplay.com</a>.<br />
--------------3606974F709600A44B2FC220--
.
Author: Barry Revzin <barry.revzin@gmail.com>
Date: Wed, 12 Oct 2016 06:31:32 -0700 (PDT)
Raw View
------=_Part_839_1630006599.1476279092226
Content-Type: multipart/alternative;
boundary="----=_Part_840_515100658.1476279092226"
------=_Part_840_515100658.1476279092226
Content-Type: text/plain; charset=UTF-8
>
>
> Proposal:
> template <class... Args>
> void foo(void(*func)(Args...), std::tuple<Args...> args)
> {
> func(auto{ ... } = args);
> }
>
> The syntax is questionable, but I wanted it to follow the structured
> bindings syntax as close as possible. The auto keyword can have const,
> l-value and r-value reference modifiers which will be appended to each
> argument. Also, the decomposition can only be used within a
> function/constructor call.
>
>
I think the closer thing to structured bindings would be to extend the
latter to allow for introducing variadic names. That would allow:
template <class F, class... Args>
void foo(F func, std::tuple<Args...> tup)
{
auto& [args...] = tup;
func(args...);
}
That's not all in one line, but I think it's actually not terrible.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/f2ed7a82-dc95-48aa-9716-f727670f2a03%40isocpp.org.
------=_Part_840_515100658.1476279092226
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;bor=
der-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><div><br=
></div><div>Proposal:</div></div><div style=3D"background-color:rgb(250,250=
,250);border-color:rgb(187,187,187);border-style:solid;border-width:1px;wor=
d-wrap:break-word"><code><div><span style=3D"color:#008">template</span><sp=
an style=3D"color:#000"> </span><span style=3D"color:#660"><</span><span=
style=3D"color:#008">class</span><span style=3D"color:#660">...</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#606">Args</span><span =
style=3D"color:#660">></span><span style=3D"color:#000"><br></span><span=
style=3D"color:#008">void</span><span style=3D"color:#000"> foo</span><spa=
n style=3D"color:#660">(</span><span style=3D"color:#008">void</span><span =
style=3D"color:#660">(*</span><span style=3D"color:#000">func</span><span s=
tyle=3D"color:#660">)(</span><span style=3D"color:#606">Args</span><span st=
yle=3D"color:#660">...),</span><span style=3D"color:#000"> std</span><span =
style=3D"color:#660">::</span><span style=3D"color:#000">tuple</span><span =
style=3D"color:#660"><</span><span style=3D"color:#606">Args</span><span=
style=3D"color:#660">...></span><span style=3D"color:#000"> args</span>=
<span style=3D"color:#660">)</span><span style=3D"color:#000"><br></span><s=
pan style=3D"color:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=
=A0 func</span><span style=3D"color:#660">(</span><span style=3D"color:#008=
">auto</span><span style=3D"color:#660">{</span><span style=3D"color:#000">=
</span><span style=3D"color:#660">...</span><span style=3D"color:#000"> </=
span><span style=3D"color:#660">}</span><span style=3D"color:#000"> </span>=
<span style=3D"color:#660">=3D</span><span style=3D"color:#000"> args</span=
><span style=3D"color:#660">);</span><span style=3D"color:#000"><br></span>=
<span style=3D"color:#660">}</span></div></code></div><div>=C2=A0</div><div=
>The syntax is questionable, but I wanted it to follow the structured bindi=
ngs syntax as close as possible. The auto keyword can have const, l-value a=
nd r-value reference modifiers which will be appended to each argument. Als=
o, the decomposition can only be used within a function/constructor call.</=
div><div><br></div></div></blockquote><div><br></div><div>I think the close=
r thing to structured bindings would be to extend the latter to allow for i=
ntroducing variadic names. That would allow:=C2=A0</div><div><br></div><div=
><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); =
border-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; w=
ord-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyp=
rint"><span style=3D"color: rgb(0, 0, 136);"><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">template</span></span><span style=3D"color: rgb=
(0, 0, 0);"><span style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an></span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span><=
font color=3D"#666600"><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> F</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span></f=
ont><span style=3D"color: rgb(0, 0, 136);"><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">class</span></span><span style=3D"color: rgb(102,=
102, 0);"><span style=3D"color: #660;" class=3D"styled-by-prettify">...</s=
pan></span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;=
" class=3D"styled-by-prettify"> </span></span><span style=3D"color: rgb(102=
, 0, 102);"><span style=3D"color: #606;" class=3D"styled-by-prettify">Args<=
/span></span><span style=3D"color: rgb(102, 102, 0);"><span style=3D"color:=
#660;" class=3D"styled-by-prettify">></span></span><span style=3D"color=
: rgb(0, 0, 0);"><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br></span></span><span style=3D"color: rgb(0, 0, 136);"><span style=3D"col=
or: #008;" class=3D"styled-by-prettify">void</span></span><span style=3D"co=
lor: rgb(0, 0, 0);"><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> foo</span></span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">(</span><font color=3D"#000088"><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">F func</span></font><span style=3D"color: rgb(102, 102, =
0);"><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span></sp=
an><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> std</span></span><span style=3D"color: rgb(102, 10=
2, 0);"><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span>=
</span><span style=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">tuple</span></span><span style=3D"color: rgb(102=
, 102, 0);"><span style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span></span><span style=3D"color: rgb(102, 0, 102);"><span style=3D"color:=
#606;" class=3D"styled-by-prettify">Args</span></span><span style=3D"color=
: rgb(102, 102, 0);"><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">...></span></span><span style=3D"color: rgb(0, 0, 0);"><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> tup</span></span><span styl=
e=3D"color: rgb(102, 102, 0);"><span style=3D"color: #660;" class=3D"styled=
-by-prettify">)</span></span><span style=3D"color: rgb(0, 0, 0);"><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"><br></span></span><span st=
yle=3D"color: rgb(102, 102, 0);"><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br></span></span><span style=3D"color: rgb(0, 0, 0);"><span style=
=3D"color: #000;" class=3D"styled-by-prettify">=C2=A0 =C2=A0 </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">&</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">[</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">args</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">...]</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> tup=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 f=
unc</span></span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
(</span><font color=3D"#000088"><span style=3D"color: #000;" class=3D"style=
d-by-prettify">args</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">...</span></font><span style=3D"color: rgb(102, 102, 0);"><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">);</span></span><span sty=
le=3D"color: rgb(0, 0, 0);"><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br></span></span><span style=3D"color: rgb(102, 102, 0);"><span=
style=3D"color: #660;" class=3D"styled-by-prettify">}</span></span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></code>=
</div><br>That's not all in one line, but I think it's actually not=
terrible.=C2=A0</div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/f2ed7a82-dc95-48aa-9716-f727670f2a03%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/f2ed7a82-dc95-48aa-9716-f727670f2a03=
%40isocpp.org</a>.<br />
------=_Part_840_515100658.1476279092226--
------=_Part_839_1630006599.1476279092226--
.
Author: Richard Thorell <richard.thorell@king.com>
Date: Wed, 12 Oct 2016 06:36:44 -0700 (PDT)
Raw View
------=_Part_1559_7287960.1476279404819
Content-Type: multipart/alternative;
boundary="----=_Part_1560_361006981.1476279404819"
------=_Part_1560_361006981.1476279404819
Content-Type: text/plain; charset=UTF-8
That was my first thought actually, like an extension to structured
bindings. Maybe this syntax is even better, since it allows the pack to be
re-used.
Thanks,
Richard
On Wednesday, October 12, 2016 at 2:31:32 PM UTC+1, Barry Revzin wrote:
>
>
>> Proposal:
>> template <class... Args>
>> void foo(void(*func)(Args...), std::tuple<Args...> args)
>> {
>> func(auto{ ... } = args);
>> }
>>
>> The syntax is questionable, but I wanted it to follow the structured
>> bindings syntax as close as possible. The auto keyword can have const,
>> l-value and r-value reference modifiers which will be appended to each
>> argument. Also, the decomposition can only be used within a
>> function/constructor call.
>>
>>
> I think the closer thing to structured bindings would be to extend the
> latter to allow for introducing variadic names. That would allow:
>
> template <class F, class... Args>
> void foo(F func, std::tuple<Args...> tup)
> {
> auto& [args...] = tup;
> func(args...);
> }
>
> That's not all in one line, but I think it's actually not terrible.
>
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/19658099-e65c-4fa2-ae61-e9cbbc2547b5%40isocpp.org.
------=_Part_1560_361006981.1476279404819
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">That was my first thought actually, like an extension to s=
tructured bindings. Maybe this syntax is even=C2=A0better,=C2=A0since it al=
lows the pack to be re-used.<div><br></div><div>Thanks,</div><div>Richard<b=
r><br>On Wednesday, October 12, 2016 at 2:31:32 PM UTC+1, Barry Revzin wrot=
e:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;b=
order-left: 1px #ccc solid;padding-left: 1ex;"><blockquote class=3D"gmail_q=
uote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;paddin=
g-left:1ex"><div dir=3D"ltr"><div><div><br></div><div>Proposal:</div></div>=
<div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,18=
7);border-style:solid;border-width:1px;word-wrap:break-word"><code><div><sp=
an style=3D"color:#008">template</span><span style=3D"color:#000"> </span><=
span style=3D"color:#660"><</span><span style=3D"color:#008">class</span=
><span style=3D"color:#660">...</span><span style=3D"color:#000"> </span><s=
pan style=3D"color:#606">Args</span><span style=3D"color:#660">></span><=
span style=3D"color:#000"><br></span><span style=3D"color:#008">void</span>=
<span style=3D"color:#000"> foo</span><span style=3D"color:#660">(</span><s=
pan style=3D"color:#008">void</span><span style=3D"color:#660">(*</span><sp=
an style=3D"color:#000">func</span><span style=3D"color:#660">)(</span><spa=
n style=3D"color:#606">Args</span><span style=3D"color:#660">...),</span><s=
pan style=3D"color:#000"> std</span><span style=3D"color:#660">::</span><sp=
an style=3D"color:#000">tuple</span><span style=3D"color:#660"><</span><=
span style=3D"color:#606">Args</span><span style=3D"color:#660">...></sp=
an><span style=3D"color:#000"> args</span><span style=3D"color:#660">)</spa=
n><span style=3D"color:#000"><br></span><span style=3D"color:#660">{</span>=
<span style=3D"color:#000"><br>=C2=A0 =C2=A0 func</span><span style=3D"colo=
r:#660">(</span><span style=3D"color:#008">auto</span><span style=3D"color:=
#660">{</span><span style=3D"color:#000"> </span><span style=3D"color:#660"=
>...</span><span style=3D"color:#000"> </span><span style=3D"color:#660">}<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#660">=3D</sp=
an><span style=3D"color:#000"> args</span><span style=3D"color:#660">);</sp=
an><span style=3D"color:#000"><br></span><span style=3D"color:#660">}</span=
></div></code></div><div>=C2=A0</div><div>The syntax is questionable, but I=
wanted it to follow the structured bindings syntax as close as possible. T=
he auto keyword can have const, l-value and r-value reference modifiers whi=
ch will be appended to each argument. Also, the decomposition can only be u=
sed within a function/constructor call.</div><div><br></div></div></blockqu=
ote><div><br></div><div>I think the closer thing to structured bindings wou=
ld be to extend the latter to allow for introducing variadic names. That wo=
uld allow:=C2=A0</div><div><br></div><div><div style=3D"background-color:rg=
b(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-widt=
h:1px;word-wrap:break-word"><code><div><span style=3D"color:rgb(0,0,136)"><=
span style=3D"color:#008">template</span></span><span style=3D"color:rgb(0,=
0,0)"><span style=3D"color:#000"> </span></span><span style=3D"color:#660">=
<</span><span style=3D"color:#008">class</span><font color=3D"#666600"><=
span style=3D"color:#000"> F</span><span style=3D"color:#660">,</span><span=
style=3D"color:#000"> </span></font><span style=3D"color:rgb(0,0,136)"><sp=
an style=3D"color:#008">class</span></span><span style=3D"color:rgb(102,102=
,0)"><span style=3D"color:#660">...</span></span><span style=3D"color:rgb(0=
,0,0)"><span style=3D"color:#000"> </span></span><span style=3D"color:rgb(1=
02,0,102)"><span style=3D"color:#606">Args</span></span><span style=3D"colo=
r:rgb(102,102,0)"><span style=3D"color:#660">></span></span><span style=
=3D"color:rgb(0,0,0)"><span style=3D"color:#000"><br></span></span><span st=
yle=3D"color:rgb(0,0,136)"><span style=3D"color:#008">void</span></span><sp=
an style=3D"color:rgb(0,0,0)"><span style=3D"color:#000"> foo</span></span>=
<span style=3D"color:#660">(</span><font color=3D"#000088"><span style=3D"c=
olor:#000">F func</span></font><span style=3D"color:rgb(102,102,0)"><span s=
tyle=3D"color:#660">,</span></span><span style=3D"color:rgb(0,0,0)"><span s=
tyle=3D"color:#000"> std</span></span><span style=3D"color:rgb(102,102,0)">=
<span style=3D"color:#660">::</span></span><span style=3D"color:rgb(0,0,0)"=
><span style=3D"color:#000">tuple</span></span><span style=3D"color:rgb(102=
,102,0)"><span style=3D"color:#660"><</span></span><span style=3D"color:=
rgb(102,0,102)"><span style=3D"color:#606">Args</span></span><span style=3D=
"color:rgb(102,102,0)"><span style=3D"color:#660">...></span></span><spa=
n style=3D"color:rgb(0,0,0)"><span style=3D"color:#000"> tup</span></span><=
span style=3D"color:rgb(102,102,0)"><span style=3D"color:#660">)</span></sp=
an><span style=3D"color:rgb(0,0,0)"><span style=3D"color:#000"><br></span><=
/span><span style=3D"color:rgb(102,102,0)"><span style=3D"color:#660">{</sp=
an><span style=3D"color:#000"><br></span></span><span style=3D"color:rgb(0,=
0,0)"><span style=3D"color:#000">=C2=A0 =C2=A0 </span><span style=3D"color:=
#008">auto</span><span style=3D"color:#660">&</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#660">[</span><span style=3D"color:#00=
0">args</span><span style=3D"color:#660">...]</span><span style=3D"color:#0=
00"> </span><span style=3D"color:#660">=3D</span><span style=3D"color:#000"=
> tup</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><=
br>=C2=A0 =C2=A0 func</span></span><span style=3D"color:#660">(</span><font=
color=3D"#000088"><span style=3D"color:#000">args</span><span style=3D"col=
or:#660">...</span></font><span style=3D"color:rgb(102,102,0)"><span style=
=3D"color:#660">);</span></span><span style=3D"color:rgb(0,0,0)"><span styl=
e=3D"color:#000"><br></span></span><span style=3D"color:rgb(102,102,0)"><sp=
an style=3D"color:#660">}</span></span><span style=3D"color:#000"><br></spa=
n></div></code></div><br>That's not all in one line, but I think it'=
;s actually not terrible.=C2=A0</div></blockquote></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/19658099-e65c-4fa2-ae61-e9cbbc2547b5%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/19658099-e65c-4fa2-ae61-e9cbbc2547b5=
%40isocpp.org</a>.<br />
------=_Part_1560_361006981.1476279404819--
------=_Part_1559_7287960.1476279404819--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Wed, 12 Oct 2016 06:56:13 -0700 (PDT)
Raw View
------=_Part_463_1587707873.1476280573742
Content-Type: multipart/alternative;
boundary="----=_Part_464_989900624.1476280573742"
------=_Part_464_989900624.1476280573742
Content-Type: text/plain; charset=UTF-8
On Wednesday, October 12, 2016 at 6:51:24 AM UTC-4, Richard Thorell wrote:
>
> Hey,
>
> After looking at the structured bindings paper [
> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0144r0.pdf] I
> thought, why don't we allow the members to be automatically unpacked into
> it's components and forwarded to a method?
> We have this functionality when it comes to tuples today, using std::get<>
> and std::index_sequence. But what if it was a built-in language feature and
> a one-liner? And worked with any structure!
>
> Proposal:
> template <class... Args>
> void foo(void(*func)(Args...), std::tuple<Args...> args)
> {
> func(auto{ ... } = args);
> }
>
> The syntax is questionable, but I wanted it to follow the structured
> bindings syntax as close as possible. The auto keyword can have const,
> l-value and r-value reference modifiers which will be appended to each
> argument. Also, the decomposition can only be used within a
> function/constructor call.
>
> Maybe this has already been discussed somewhere?
>
> Any feedback is appreciated!
>
> Thanks,
> Richard
>
There have already been discussions about having a way to transform tuples
and tuple-like types into parameter packs of their elements. One suggested
syntax would look like this:
template <class F, class... Args>
void foo(std::tuple<Args...> args)
{
func([:]args...);
}
This syntax allows you to do things like
`func(std::forward<Args>([:]args)...)`. It would even allow you to call
arbitrary expressions on tuple elements, or allow them to participate in
fold expressions. To get the sum of all elements of a tuple, you do `(0 +
.... + [:]args)`.
That's much more flexible than your "structured binding"-based stuff here.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/743dd7c5-bec3-41c4-a787-1554f43cbe81%40isocpp.org.
------=_Part_464_989900624.1476280573742
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Wednesday, October 12, 2016 at 6:51:24 AM UTC-4, Richar=
d Thorell wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"lt=
r">Hey,<div><div><br></div><div>After looking at the structured bindings pa=
per [<a href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p01=
44r0.pdf" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D=
9;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc2=
2%2Fwg21%2Fdocs%2Fpapers%2F2015%2Fp0144r0.pdf\x26sa\x3dD\x26sntz\x3d1\x26us=
g\x3dAFQjCNG1MKJjnldtN4lm6MvN4r0b6M0ewA';return true;" onclick=3D"this.=
href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.open-std.org%2F=
jtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2015%2Fp0144r0.pdf\x26sa\x3dD\x26sntz\=
x3d1\x26usg\x3dAFQjCNG1MKJjnldtN4lm6MvN4r0b6M0ewA';return true;">http:/=
/www.open-std.org/jtc1/<wbr>sc22/wg21/docs/papers/2015/<wbr>p0144r0.pdf</a>=
] I thought, why don't we allow the members to be automatically unpacke=
d into it's components and forwarded to a method?</div><div>We have thi=
s functionality when it comes to tuples today, using std::get<> and s=
td::index_sequence. But what if it was a built-in language feature and a on=
e-liner? And worked with any structure!<br></div><div><br></div><div>Propos=
al:</div></div><div style=3D"background-color:rgb(250,250,250);border-color=
:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word"=
><code><div><span style=3D"color:#008">template</span><span style=3D"color:=
#000"> </span><span style=3D"color:#660"><</span><span style=3D"color:#0=
08">class</span><span style=3D"color:#660">...</span><span style=3D"color:#=
000"> </span><span style=3D"color:#606">Args</span><span style=3D"color:#66=
0">></span><span style=3D"color:#000"><br></span><span style=3D"color:#0=
08">void</span><span style=3D"color:#000"> foo</span><span style=3D"color:#=
660">(</span><span style=3D"color:#008">void</span><span style=3D"color:#66=
0">(*</span><span style=3D"color:#000">func</span><span style=3D"color:#660=
">)(</span><span style=3D"color:#606">Args</span><span style=3D"color:#660"=
>...),</span><span style=3D"color:#000"> std</span><span style=3D"color:#66=
0">::</span><span style=3D"color:#000">tuple</span><span style=3D"color:#66=
0"><</span><span style=3D"color:#606">Args</span><span style=3D"color:#6=
60">...></span><span style=3D"color:#000"> args</span><span style=3D"col=
or:#660">)</span><span style=3D"color:#000"><br></span><span style=3D"color=
:#660">{</span><span style=3D"color:#000"><br>=C2=A0 =C2=A0 func</span><spa=
n style=3D"color:#660">(</span><span style=3D"color:#008">auto</span><span =
style=3D"color:#660">{</span><span style=3D"color:#000"> </span><span style=
=3D"color:#660">...</span><span style=3D"color:#000"> </span><span style=3D=
"color:#660">}</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#660">=3D</span><span style=3D"color:#000"> args</span><span style=3D"col=
or:#660">);</span><span style=3D"color:#000"><br></span><span style=3D"colo=
r:#660">}</span></div></code></div><div>=C2=A0</div><div>The syntax is ques=
tionable, but I wanted it to follow the structured bindings syntax as close=
as possible. The auto keyword can have const, l-value and r-value referenc=
e modifiers which will be appended to each argument. Also, the decompositio=
n can only be used within a function/constructor call.</div><div><br></div>=
<div>Maybe this has already been discussed somewhere?</div><div><br></div><=
div>Any feedback is appreciated!</div><div><br></div><div>Thanks,</div><div=
>Richard</div></div></blockquote><div><br><br>There have already been discu=
ssions about having a way to transform tuples and tuple-like types into par=
ameter packs of their elements. One suggested syntax would look like this:<=
br><br><div style=3D"background-color: rgb(250, 250, 250); border-color: rg=
b(187, 187, 187); border-style: solid; border-width: 1px; overflow-wrap: br=
eak-word;" class=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"=
subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">t=
emplate</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </=
span><span style=3D"color: #660;" class=3D"styled-by-prettify"><</span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">class</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"> F</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">class</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">...</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> </span><span style=3D"color: #606;" class=3D"styled-by-prett=
ify">Args</span><span style=3D"color: #660;" class=3D"styled-by-prettify">&=
gt;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> foo</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">std</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">::</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify">tuple</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify"><</span><span style=3D"color: #606;" class=3D"style=
d-by-prettify">Args</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">...></span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> args</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br>=C2=A0 =C2=A0 func<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">([:]</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify">args</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">...);</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">}</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br></span></div></code></div><br>This synt=
ax allows you to do things like `func(std::forward<Args>([:]args)...)=
`. It would even allow you to call arbitrary expressions on tuple elements,=
or allow them to participate in fold expressions. To get the sum of all el=
ements of a tuple, you do `(0 + ... + [:]args)`.<br><br>That's much mor=
e flexible than your "structured binding"-based stuff here.<br></=
div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/743dd7c5-bec3-41c4-a787-1554f43cbe81%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/743dd7c5-bec3-41c4-a787-1554f43cbe81=
%40isocpp.org</a>.<br />
------=_Part_464_989900624.1476280573742--
------=_Part_463_1587707873.1476280573742--
.
Author: Tony V E <tvaneerd@gmail.com>
Date: Wed, 12 Oct 2016 11:29:34 -0400
Raw View
<html><head></head><body bgcolor=3D"#FFFFFF" text=3D"#000000" lang=3D"en-US=
" style=3D"background-color: rgb(255, 255, 255); line-height: initial;"> =
=
<div style=3D"width: 100%; font-size: initial; font-family: Calibri=
, 'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125); text-align:=
initial; background-color: rgb(255, 255, 255);">Should we just make get an=
d tuple_size automatically work on all PODs?</div><div style=3D"width: 100%=
; font-size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-s=
erif; color: rgb(31, 73, 125); text-align: initial; background-color: rgb(2=
55, 255, 255);"><br></div> =
=
<div style=3D"width: 100%; font-size: initial; font-family: Calibr=
i, 'Slate Pro', sans-serif, sans-serif; color: rgb(31, 73, 125); text-align=
: initial; background-color: rgb(255, 255, 255);"><br style=3D"display:init=
ial"></div> =
=
<div style=3D"font-=
size: initial; font-family: Calibri, 'Slate Pro', sans-serif, sans-serif; c=
olor: rgb(31, 73, 125); text-align: initial; background-color: rgb(255, 255=
, 255);">Sent from my BlackBerry portable Babbage&=
nbsp;Device</div> =
=
<table width=3D"100%" style=3D=
"background-color:white;border-spacing:0px;"> <tbody><tr><td colspan=3D"2" =
style=3D"font-size: initial; text-align: initial; background-color: rgb(255=
, 255, 255);"> <div style=3D"border-style: solid =
none none; border-top-color: rgb(181, 196, 223); border-top-width: 1pt; pad=
ding: 3pt 0in 0in; font-family: Tahoma, 'BB Alpha Sans', 'Slate Pro'; font-=
size: 10pt;"> <div><b>From: </b>Simon Brand</div><div><b>Sent: </b>Wednesd=
ay, October 12, 2016 7:31 AM</div><div><b>To: </b>std-proposals@isocpp.org<=
/div><div><b>Reply To: </b>std-proposals@isocpp.org</div><div><b>Subject: <=
/b>Re: [std-proposals] Variadic decomposition</div></div></td></tr></tbody>=
</table><div style=3D"border-style: solid none none; border-top-color: rgb(=
186, 188, 209); border-top-width: 1pt; font-size: initial; text-align: init=
ial; background-color: rgb(255, 255, 255);"></div><br><div id=3D"_originalC=
ontent" style=3D"background-color: rgb(255, 255, 255);">
=20
<meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type=
">
=20
=20
<p>I believe that with variadic decomposition you would only be able
to use it for classes which only have public member data (or have
those data members in a single direct base class). For any class
without that property, you'd still need to write implementations
of <tt>get </tt>and <tt>tuple_size</tt>. So the main benefit of
your suggestion would be removing the need to implement a couple
of functions for a small set of classes, but to get that it's
mandating a language change and some new syntax.</p>
<p>I do like the idea of the proposal, but I think that the costs
outweigh the benefits over the <tt>std::apply</tt> solution.<br>
</p>
<div class=3D"moz-cite-prefix">On 12/10/16 12:23, Richard Thorell
wrote:<br>
</div>
<blockquote cite=3D"mid:c28ca0ca-b59d-4e06-8c79-52f7cd859a49@isocpp.org=
" type=3D"cite">
<div dir=3D"ltr">Hi,
<div><br>
</div>
<div>Yes, I take that back. Should've been types that supports
std::get/std::tuple_size (to little coffee still). But it
still requires you to add an overload for your structure
right?</div>
<div><br>
</div>
<div>With a variadic decomposition you could use any struct
without any overloads and you could benefit from all good
stuff that std::tuple gives you (# of members, compare
operators etc.).</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Richard</div>
<div><br>
</div>
<div>ps. just got another coffee<br>
<br>
On Wednesday, October 12, 2016 at 12:13:16 PM UTC+1, Simon
Brand 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">
<p>Hi Richard,<br>
</p>
<p><tt>std::apply</tt> doesn't just operate on <tt>std::tuple=
</tt>;
it uses <tt>std::get</tt> and <tt>std::tuple_size</tt>,
which is the same method by which you can add structured
binding support to your own class (unless the proposal
has been updated since I last looked). </p>
Thanks,<br>
Simon<br>
<br>
<div>On 12/10/16 12:09, Richard Thorell wrote:<br>
</div>
<blockquote type=3D"cite">
<div dir=3D"ltr">Hey,
<div><br>
</div>
<div>Yeah I'm aware of std::apply but it still only
operates on std::tuple. If you have your own
structure and you want to decompose it, there's no
generic way to do so.</div>
<div><br>
</div>
<div style=3D"background-color:rgb(250,250,250);border-co=
lor:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-wo=
rd"><code>
<div><span style=3D"color:#008">template</span><span =
style=3D"color:#000"> </span><span style=3D"color:#660"><</span><span st=
yle=3D"color:#008">class</span><span style=3D"color:#000"> T</span><span st=
yle=3D"color:#660">></span><span style=3D"color:#000"><br>
</span><span style=3D"color:#008">constexpr</span><=
span style=3D"color:#000"> </span><span style=3D"color:#008">auto</span><sp=
an style=3D"color:#000"> struct_to_fw_tuple</span><span style=3D"color:#660=
">(</span><span style=3D"color:#000">T</span><span style=3D"color:#660">&am=
p;</span><span style=3D"color:#000"> any_struct</span><span style=3D"color:=
#660">)</span><span style=3D"color:#000"><br>
</span><span style=3D"color:#660">{</span><span sty=
le=3D"color:#000"><br>
</span><span style=3D"color:#008">r=
eturn</span><span style=3D"color:#000"> std</span><span style=3D"color:#660=
">::</span><font color=3D"#000000"><span style=3D"color:#000">forward_as_tu=
ple</span><span style=3D"color:#660">(</span><span style=3D"color:#008">aut=
o</span><span style=3D"color:#660">&{..<wbr>.}</span><span style=3D"col=
or:#000"> </span><span style=3D"color:#660">=3D</span><span style=3D"color:=
#000"> any_struct</span><span style=3D"color:#660">);</span></font><span st=
yle=3D"color:#000"><br>
</span><span style=3D"color:#660">}</span></div>
</code></div>
<div><br>
<div style=3D"background-color:rgb(250,250,250);border-=
color:rgb(187,187,187);border-style:solid;border-width:1px;word-wrap:break-=
word"><code>
<div><span style=3D"color:#008">template</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#660"><</span><span =
style=3D"color:#008">class</span><span style=3D"color:#000"> F</span><span =
style=3D"color:#660">,</span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">class</span><span style=3D"color:#000"> </span><span style=
=3D"color:#606">Tuple</span><span style=3D"color:#660">></span><span sty=
le=3D"color:#000"><br>
</span><span style=3D"color:#008">constexpr</span=
><span style=3D"color:#000"> </span><span style=3D"color:#008">decltype</sp=
an><span style=3D"color:#660">(</span><span style=3D"color:#008">auto</span=
><span style=3D"color:#660">)</span><span style=3D"color:#000"> apply</span=
><span style=3D"color:#660">(</span><span style=3D"color:#000">F</span><spa=
n style=3D"color:#660">&&</span><span style=3D"color:#000"> func</s=
pan><span style=3D"color:#660">,</span><span style=3D"color:#000"> </span><=
span style=3D"color:#606">Tuple</span><span style=3D"color:#660">&&=
</span><span style=3D"color:#000"> tuple</span><span style=3D"color:#660">)=
</span><span style=3D"color:#000"><br>
</span><span style=3D"color:#660">{</span><span s=
tyle=3D"color:#000"><br>
</span><span style=3D"color:#008"=
>return</span><span style=3D"color:#000"> std</span><span style=3D"color:#6=
60">::</span><span style=3D"color:#000">invoke</span><span style=3D"color:#=
660">(</span><span style=3D"color:#000">std</span><span style=3D"color:#660=
">::</span><span style=3D"color:#000">forward</span><span style=3D"color:#6=
60"><</span><span style=3D"color:#000">F</span><span style=3D"color:#660=
">>(</span><span style=3D"color:#000">fu<wbr>nc</span><span style=3D"col=
or:#660">),</span><span style=3D"color:#000"> </span><span style=3D"color:#=
008">auto</span><span style=3D"color:#660">&&{</span><font color=3D=
"#000000"><span style=3D"color:#660">...}</span><span style=3D"color:#000">=
</span><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> tu=
ple</span><span style=3D"color:#660">);</span></font><span style=3D"color:#=
000"><br>
</span><span style=3D"color:#660">}</span></div>
</code></div>
<div><br>
</div>
The snippet in both post were just examples of
usages.</div>
<div><br>
</div>
<div>Cheers,</div>
<div>Richard<br>
<br>
On Wednesday, October 12, 2016 at 11:58:31 AM UTC+1,
Alisdair Meredith wrote:
<blockquote class=3D"gmail_quote" style=3D"margin:0;mar=
gin-left:0.8ex;border-left:1px
#ccc solid;padding-left:1ex">
<div dir=3D"auto">
<div>
<div style=3D"direction:inherit">A library
function with these semantics is already
present in the C++17 CD, called 'apply'.
What benefit do you expect by complicatin=
g
the language with a compiler feature to
delivery (mostly) the same effect?</div>
<div style=3D"direction:inherit"><br>
</div>
<div style=3D"direction:inherit">(By using the
INVOKE treatment, the library version is
actually slightly more capable than a likely
language feature, dispatching through
pointer-to-members etc. as well.)</div>
<div style=3D"direction:inherit"><br>
</div>
<div style=3D"direction:inherit">AlisdairM</div>
<br>
Sent from my iPad</div>
<div><br>
On 12 Oct 2016, at 06:51, Richard Thorell <<a =
moz-do-not-send=3D"true" rel=3D"nofollow">richard...@king.com</a>>
wrote:<br>
<br>
</div>
<blockquote type=3D"cite">
<div>
<div dir=3D"ltr">Hey,
<div>
<div><br>
</div>
<div>After looking at the structured
bindings paper [<a moz-do-not-send=3D"tru=
e" href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0144r0.=
pdf" rel=3D"nofollow" target=3D"_blank" onmousedown=3D"this.href=3D'http://=
www.google.com/url?q\x3dhttp%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%=
2Fdocs%2Fpapers%2F2015%2Fp0144r0.pdf\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQj=
CNG1MKJjnldtN4lm6MvN4r0b6M0ewA';return
true;" onclick=3D"this.href=3D'http://w=
ww.google.com/url?q\x3dhttp%3A%2F%2Fwww.open-std.org%2Fjtc1%2Fsc22%2Fwg21%2=
Fdocs%2Fpapers%2F2015%2Fp0144r0.pdf\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjC=
NG1MKJjnldtN4lm6MvN4r0b6M0ewA';return
true;">http://www.open-std.org/jtc1/<wb=
r>sc22/wg21/docs/papers/2015/<wbr>p0144r0.pdf</a>]
I thought, why don't we allow the
members to be automatically unpacked
into it's components and forwarded to
a method?</div>
<div>We have this functionality when it
comes to tuples today, using
std::get<> and
std::index_sequence. But what if it
was a built-in language feature and a
one-liner? And worked with any
structure!<br>
</div>
<div><br>
</div>
<div>Proposal:</div>
</div>
<div style=3D"background-color:rgb(250,250,25=
0);border-color:rgb(187,187,187);border-style:solid;border-width:1px;word-w=
rap:break-word"><code>
<div><span style=3D"color:#008">template<=
/span><span style=3D"color:#000"> </span><span style=3D"color:#660"><</s=
pan><span style=3D"color:#008">class</span><span style=3D"color:#660">...</=
span><span style=3D"color:#000"> </span><span style=3D"color:#606">Args</sp=
an><span style=3D"color:#660">></span><span style=3D"color:#000"><br>
</span><span style=3D"color:#008">void<=
/span><span style=3D"color:#000"> foo</span><span style=3D"color:#660">(</s=
pan><span style=3D"color:#008">void</span><span style=3D"color:#660">(*</sp=
an><span style=3D"color:#000">func</span><span style=3D"color:#660">)(</spa=
n><span style=3D"color:#606">Args</span><span style=3D"color:#660">...),</s=
pan><span style=3D"color:#000"> std</span><span style=3D"color:#660">::</sp=
an><span style=3D"color:#000">tuple</span><span style=3D"color:#660"><</=
span><span style=3D"color:#606">Args</span><span style=3D"color:#660">...&g=
t;</span><span style=3D"color:#000"> args</span><span style=3D"color:#660">=
)</span><span style=3D"color:#000"><br>
</span><span style=3D"color:#660">{</sp=
an><span style=3D"color:#000"><br>
func</span><span style=
=3D"color:#660">(</span><span style=3D"color:#008">auto</span><span style=
=3D"color:#660">{</span><span style=3D"color:#000"> </span><span style=3D"c=
olor:#660">...</span><span style=3D"color:#000"> </span><span style=3D"colo=
r:#660">}</span><span style=3D"color:#000"> </span><span style=3D"color:#66=
0">=3D</span><span style=3D"color:#000"> args</span><span style=3D"color:#6=
60">);</span><span style=3D"color:#000"><br>
</span><span style=3D"color:#660">}</sp=
an></div>
</code></div>
<div> </div>
<div>The syntax is questionable, but I
wanted it to follow the structured
bindings syntax as close as possible.
The auto keyword can have const, l-value
and r-value reference modifiers which
will be appended to each argument. Also,
the decomposition can only be used
within a function/constructor call.</div>
<div><br>
</div>
<div>Maybe this has already been discussed
somewhere?</div>
<div><br>
</div>
<div>Any feedback is appreciated!</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Richard</div>
</div>
-- <br>
You received this message because you are
subscribed to the Google Groups "ISO C++
Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop
receiving emails from it, send an email to <a m=
oz-do-not-send=3D"true" rel=3D"nofollow">std-proposal...@isocpp.org</a>.<br=
>
To post to this group, send email to <a moz-do-=
not-send=3D"true" rel=3D"nofollow">std-pr...@isocpp.org</a>.<br>
To view this discussion on the web visit <a moz=
-do-not-send=3D"true" href=3D"https://groups.google.com/a/isocpp.org/d/msgi=
d/std-proposals/0d627ddf-dec9-4051-abaf-e6e6f8dbeaaa%40isocpp.org?utm_mediu=
m=3Demail&utm_source=3Dfooter" rel=3D"nofollow" target=3D"_blank" onmou=
sedown=3D"this.href=3D'https://groups.google.com/a/isocpp.org/d/msgid/std-p=
roposals/0d627ddf-dec9-4051-abaf-e6e6f8dbeaaa%40isocpp.org?utm_medium\x3dem=
ail\x26utm_source\x3dfooter';return
true;" onclick=3D"this.href=3D'https://groups=
..google.com/a/isocpp.org/d/msgid/std-proposals/0d627ddf-dec9-4051-abaf-e6e6=
f8dbeaaa%40isocpp.org?utm_medium\x3demail\x26utm_source\x3dfooter';return
true;">https://groups.google.com/a/<wbr>isocp=
p.org/d/msgid/std-<wbr>proposals/0d627ddf-dec9-4051-<wbr>abaf-e6e6f8dbeaaa%=
40isocpp.org</a><wbr>.<br>
</div>
</blockquote>
</div>
</blockquote>
</div>
</div>
-- <br>
You received this message because you are subscribed to
the Google Groups "ISO C++ Standard - Future Proposals"
group.<br>
To unsubscribe from this group and stop receiving emails
from it, send an email to <a moz-do-not-send=3D"true" href=
=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"b1x0_rhYAQAJ" r=
el=3D"nofollow" onmousedown=3D"this.href=3D'javascript:';return true;" oncl=
ick=3D"this.href=3D'javascript:';return true;">std-proposal...@<wbr>isocpp.=
org</a>.<br>
To post to this group, send email to <a moz-do-not-send=3D"=
true" href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"b1x0_=
rhYAQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:';return t=
rue;" onclick=3D"this.href=3D'javascript:';return true;">std-pr...@isocpp.o=
rg</a>.<br>
To view this discussion on the web visit <a moz-do-not-send=
=3D"true" href=3D"https://groups.google.com/a/isocpp.org/d/msgid/std-propos=
als/6867504e-d4e5-4e2b-859c-3040f7cdc05f%40isocpp.org?utm_medium=3Demail&am=
p;utm_source=3Dfooter" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"th=
is.href=3D'https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/686=
7504e-d4e5-4e2b-859c-3040f7cdc05f%40isocpp.org?utm_medium\x3demail\x26utm_s=
ource\x3dfooter';return
true;" onclick=3D"this.href=3D'https://groups.google.com/=
a/isocpp.org/d/msgid/std-proposals/6867504e-d4e5-4e2b-859c-3040f7cdc05f%40i=
socpp.org?utm_medium\x3demail\x26utm_source\x3dfooter';return
true;">https://groups.google.com/a/<wbr>isocpp.org/d/msgi=
d/std-<wbr>proposals/6867504e-d4e5-4e2b-<wbr>859c-3040f7cdc05f%40isocpp.org=
</a><wbr>.<br>
</blockquote>
<br>
<pre cols=3D"72">--=20
Simon Brand
Staff Software Engineer
Codeplay Software Ltd
Level C, Argyle House, 3 Lady Lawson St, Edinburgh, EH3 9DR
Tel: 0131 466 0503
Fax: 0131 557 6600
Website: <a moz-do-not-send=3D"true" href=3D"http://www.codeplay.com" targe=
t=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'http://www.google=
..com/url?q\x3dhttp%3A%2F%2Fwww.codeplay.com\x26sa\x3dD\x26sntz\x3d1\x26usg\=
x3dAFQjCNEPP-Z-LmQScRyZl0Qs6WGmnQhbbQ';return true;" onclick=3D"this.href=
=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.codeplay.com\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNEPP-Z-LmQScRyZl0Qs6WGmnQhbbQ';return true;">h=
ttp://www.codeplay.com</a>
Twitter: <a moz-do-not-send=3D"true" href=3D"https://twitter.com/codeplayso=
ft" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D'https://=
www.google.com/url?q\x3dhttps%3A%2F%2Ftwitter.com%2Fcodeplaysoft\x26sa\x3dD=
\x26sntz\x3d1\x26usg\x3dAFQjCNGRmr12ghhIG15wbFm_KSYscMZftw';return true;" o=
nclick=3D"this.href=3D'https://www.google.com/url?q\x3dhttps%3A%2F%2Ftwitte=
r.com%2Fcodeplaysoft\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGRmr12ghhIG15w=
bFm_KSYscMZftw';return true;">https://twitter.com/<wbr>codeplaysoft</a>
This email and any attachments may contain confidential and /or privileged =
information and is for use by the addressee only. If you are not the intend=
ed recipient, please notify Codeplay Software Ltd immediately and delete th=
e message from your computer. You may not copy or forward it, or use or dis=
close its contents to any other person. Any views or other information in t=
his message which do not relate to our business are not authorized by Codep=
lay software Ltd, nor does this message form part of any contract unless so=
stated.
As internet communications are capable of data corruption Codeplay Software=
Ltd does not accept any responsibility for any changes made to this messag=
e after it was sent. Please note that Codeplay Software Ltd does not accept=
any liability or responsibility for viruses and it is your responsibility =
to scan any attachments.
Company registered in England and Wales, number: 04567874
Registered office: 81 Linkfield Street, Redhill RH1 6BY </pre>
</div>
</blockquote></div></div>
--=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 <a moz-do-not-send=3D"true" href=3D"mailto:std-proposals+unsubscrib=
e@isocpp.org">std-proposals+unsubscribe@isocpp.org</a>.
To post to this group, send email to <a moz-do-not-send=3D"true" href=3D"ma=
ilto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>.
To view this discussion on the web visit <a moz-do-not-send=3D"true" href=
=3D"https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/c28ca0ca-b=
59d-4e06-8c79-52f7cd859a49%40isocpp.org?utm_medium=3Demail&utm_source=
=3Dfooter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/c28=
ca0ca-b59d-4e06-8c79-52f7cd859a49%40isocpp.org</a>.
</blockquote>
<pre class=3D"moz-signature" cols=3D"72">--=20
Simon Brand
Staff Software Engineer
Codeplay Software Ltd
Level C, Argyle House, 3 Lady Lawson St, Edinburgh, EH3 9DR
Tel: 0131 466 0503
Fax: 0131 557 6600
Website: <a class=3D"moz-txt-link-freetext" href=3D"http://www.codeplay.com=
">http://www.codeplay.com</a>
Twitter: <a class=3D"moz-txt-link-freetext" href=3D"https://twitter.com/cod=
eplaysoft">https://twitter.com/codeplaysoft</a>
This email and any attachments may contain confidential and /or privileged =
information and is for use by the addressee only. If you are not the intend=
ed recipient, please notify Codeplay Software Ltd immediately and delete th=
e message from your computer. You may not copy or forward it, or use or dis=
close its contents to any other person. Any views or other information in t=
his message which do not relate to our business are not authorized by Codep=
lay software Ltd, nor does this message form part of any contract unless so=
stated.
As internet communications are capable of data corruption Codeplay Software=
Ltd does not accept any responsibility for any changes made to this messag=
e after it was sent. Please note that Codeplay Software Ltd does not accept=
any liability or responsibility for viruses and it is your responsibility =
to scan any attachments.
Company registered in England and Wales, number: 04567874
Registered office: 81 Linkfield Street, Redhill RH1 6BY </pre>
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/bf68a3f3-79af-eac4-4a04-f1be2920ded7%=
40codeplay.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.g=
oogle.com/a/isocpp.org/d/msgid/std-proposals/bf68a3f3-79af-eac4-4a04-f1be29=
20ded7%40codeplay.com</a>.<br>
<br><!--end of _originalContent --></div></body></html>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/20161012152934.4882513.63206.18280%40=
gmail.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.com=
/a/isocpp.org/d/msgid/std-proposals/20161012152934.4882513.63206.18280%40gm=
ail.com</a>.<br />
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Wed, 12 Oct 2016 18:37:04 +0300
Raw View
--001a1144984ee18b75053eacc389
Content-Type: text/plain; charset=UTF-8
On 12 October 2016 at 18:29, Tony V E <tvaneerd@gmail.com> wrote:
> Should we just make get and tuple_size automatically work on all PODs?
>
>
>
Yes. Proposals welcome, I can co-author.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFk2RUYiUZqbEpYYJWkQvDG58pYZA%3D_5s4Vkc4n5_fMvOFskVw%40mail.gmail.com.
--001a1144984ee18b75053eacc389
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On 12 October 2016 at 18:29, Tony V E <span dir=3D"ltr"><<a href=3D"=
mailto:tvaneerd@gmail.com" target=3D"_blank">tvaneerd@gmail.com</a>></sp=
an> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;=
border-left:1px #ccc solid;padding-left:1ex"><div bgcolor=3D"#FFFFFF" text=
=3D"#000000" style=3D"background-color:rgb(255,255,255);line-height:initial=
" lang=3D"en-US"> =
<div style=3D"width:100%;font-size:initial;font=
-family:Calibri,'Slate Pro',sans-serif,sans-serif;color:rgb(31,73,1=
25);text-align:initial;background-color:rgb(255,255,255)">Should we just ma=
ke get and tuple_size automatically work on all PODs?</div><div style=3D"wi=
dth:100%;font-size:initial;font-family:Calibri,'Slate Pro',sans-ser=
if,sans-serif;color:rgb(31,73,125);text-align:initial;background-color:rgb(=
255,255,255)"><br><br></div></div></blockquote><div><br></div><div>Yes. Pro=
posals welcome, I can co-author. <br></div></div><br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAFk2RUYiUZqbEpYYJWkQvDG58pYZA%3D_5s4=
Vkc4n5_fMvOFskVw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">h=
ttps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFk2RUYiUZqbEp=
YYJWkQvDG58pYZA%3D_5s4Vkc4n5_fMvOFskVw%40mail.gmail.com</a>.<br />
--001a1144984ee18b75053eacc389--
.
Author: Peter Koch Larsen <peter.koch.larsen@gmail.com>
Date: Wed, 12 Oct 2016 19:28:23 +0200
Raw View
--001a11437b54f9c61d053eae51a3
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
That sounds like a very nice idea.
On Wed, Oct 12, 2016 at 5:29 PM, Tony V E <tvaneerd@gmail.com> wrote:
> Should we just make get and tuple_size automatically work on all PODs?
>
>
> Sent from my BlackBerry portable Babbage Device
> *From: *Simon Brand
> *Sent: *Wednesday, October 12, 2016 7:31 AM
> *To: *std-proposals@isocpp.org
> *Reply To: *std-proposals@isocpp.org
> *Subject: *Re: [std-proposals] Variadic decomposition
>
> I believe that with variadic decomposition you would only be able to use
> it for classes which only have public member data (or have those data
> members in a single direct base class). For any class without that
> property, you'd still need to write implementations of get and tuple_size=
..
> So the main benefit of your suggestion would be removing the need to
> implement a couple of functions for a small set of classes, but to get th=
at
> it's mandating a language change and some new syntax.
>
> I do like the idea of the proposal, but I think that the costs outweigh
> the benefits over the std::apply solution.
> On 12/10/16 12:23, Richard Thorell wrote:
>
> Hi,
>
> Yes, I take that back. Should've been types that supports
> std::get/std::tuple_size (to little coffee still). But it still requires
> you to add an overload for your structure right?
>
> With a variadic decomposition you could use any struct without any
> overloads and you could benefit from all good stuff that std::tuple gives
> you (# of members, compare operators etc.).
>
> Thanks,
> Richard
>
> ps. just got another coffee
>
> On Wednesday, October 12, 2016 at 12:13:16 PM UTC+1, Simon Brand wrote:
>>
>> Hi Richard,
>>
>> std::apply doesn't just operate on std::tuple; it uses std::get and
>> std::tuple_size, which is the same method by which you can add
>> structured binding support to your own class (unless the proposal has be=
en
>> updated since I last looked).
>> Thanks,
>> Simon
>>
>> On 12/10/16 12:09, Richard Thorell wrote:
>>
>> Hey,
>>
>> Yeah I'm aware of std::apply but it still only operates on std::tuple. I=
f
>> you have your own structure and you want to decompose it, there's no
>> generic way to do so.
>>
>> template <class T>
>> constexpr auto struct_to_fw_tuple(T& any_struct)
>> {
>> return std::forward_as_tuple(auto&{...} =3D any_struct);
>> }
>>
>> template <class F, class Tuple>
>> constexpr decltype(auto) apply(F&& func, Tuple&& tuple)
>> {
>> return std::invoke(std::forward<F>(func), auto&&{...} =3D tuple);
>> }
>>
>> The snippet in both post were just examples of usages.
>>
>> Cheers,
>> Richard
>>
>> On Wednesday, October 12, 2016 at 11:58:31 AM UTC+1, Alisdair Meredith
>> wrote:
>>>
>>> A library function with these semantics is already present in the C++17
>>> CD, called 'apply'. What benefit do you expect by complicating the
>>> language with a compiler feature to delivery (mostly) the same effect?
>>>
>>> (By using the INVOKE treatment, the library version is actually slightl=
y
>>> more capable than a likely language feature, dispatching through
>>> pointer-to-members etc. as well.)
>>>
>>> AlisdairM
>>>
>>> Sent from my iPad
>>>
>>> On 12 Oct 2016, at 06:51, Richard Thorell <richard...@king.com> wrote:
>>>
>>> Hey,
>>>
>>> After looking at the structured bindings paper [
>>> http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0144r0.pdf] I
>>> thought, why don't we allow the members to be automatically unpacked in=
to
>>> it's components and forwarded to a method?
>>> We have this functionality when it comes to tuples today, using
>>> std::get<> and std::index_sequence. But what if it was a built-in langu=
age
>>> feature and a one-liner? And worked with any structure!
>>>
>>> Proposal:
>>> template <class... Args>
>>> void foo(void(*func)(Args...), std::tuple<Args...> args)
>>> {
>>> func(auto{ ... } =3D args);
>>> }
>>>
>>> The syntax is questionable, but I wanted it to follow the structured
>>> bindings syntax as close as possible. The auto keyword can have const,
>>> l-value and r-value reference modifiers which will be appended to each
>>> argument. Also, the decomposition can only be used within a
>>> function/constructor call.
>>>
>>> Maybe this has already been discussed somewhere?
>>>
>>> Any feedback is appreciated!
>>>
>>> Thanks,
>>> Richard
>>> --
>>> 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-proposal...@isocpp.org.
>>> To post to this group, send email to std-pr...@isocpp.org.
>>> To view this discussion on the web visit https://groups.google.com/a/is
>>> ocpp.org/d/msgid/std-proposals/0d627ddf-dec9-4051-abaf-
>>> e6e6f8dbeaaa%40isocpp.org
>>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/0d627ddf-=
dec9-4051-abaf-e6e6f8dbeaaa%40isocpp.org?utm_medium=3Demail&utm_source=3Dfo=
oter>
>>> .
>>>
>>> --
>> You received this message because you are subscribed to the Google Group=
s
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n
>> email to std-proposal...@isocpp.org.
>> To post to this group, send email to std-pr...@isocpp.org.
>> To view this discussion on the web visit https://groups.google.com/a/is
>> ocpp.org/d/msgid/std-proposals/6867504e-d4e5-4e2b-859c-
>> 3040f7cdc05f%40isocpp.org
>> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/6867504e-d=
4e5-4e2b-859c-3040f7cdc05f%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoo=
ter>
>> .
>>
>>
>> --
>> Simon Brand
>> Staff Software Engineer
>> Codeplay Software Ltd
>> Level C, Argyle House, 3 Lady Lawson St, Edinburgh, EH3 9DR
>> Tel: 0131 466 0503
>> Fax: 0131 557 6600
>> Website: http://www.codeplay.com
>> Twitter: https://twitter.com/codeplaysoft
>>
>> This email and any attachments may contain confidential and /or privileg=
ed information and is for use by the addressee only. If you are not the int=
ended recipient, please notify Codeplay Software Ltd immediately and delete=
the message from your computer. You may not copy or forward it, or use or =
disclose its contents to any other person. Any views or other information i=
n this message which do not relate to our business are not authorized by Co=
deplay software Ltd, nor does this message form part of any contract unless=
so stated.
>> As internet communications are capable of data corruption Codeplay Softw=
are Ltd does not accept any responsibility for any changes made to this mes=
sage after it was sent. Please note that Codeplay Software Ltd does not acc=
ept any liability or responsibility for viruses and it is your responsibili=
ty to scan any attachments.
>> Company registered in England and Wales, number: 04567874
>> Registered office: 81 Linkfield Street, Redhill RH1 6BY
>>
>> -- You received this message because you are subscribed to the Google
> Groups "ISO C++ Standard - Future Proposals" group. To unsubscribe from
> this group and stop receiving emails from it, send an email to
> std-proposals+unsubscribe@isocpp.org. To post to this group, send email
> to std-proposals@isocpp.org. To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-
> proposals/c28ca0ca-b59d-4e06-8c79-52f7cd859a49%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/c28ca0ca-b5=
9d-4e06-8c79-52f7cd859a49%40isocpp.org?utm_medium=3Demail&utm_source=3Dfoot=
er>.
>
>
> --
> Simon Brand
> Staff Software Engineer
> Codeplay Software Ltd
> Level C, Argyle House, 3 Lady Lawson St, Edinburgh, EH3 9DR
> Tel: 0131 466 0503
> Fax: 0131 557 6600
> Website: http://www.codeplay.com
> Twitter: https://twitter.com/codeplaysoft
>
> This email and any attachments may contain confidential and /or privilege=
d information and is for use by the addressee only. If you are not the inte=
nded recipient, please notify Codeplay Software Ltd immediately and delete =
the message from your computer. You may not copy or forward it, or use or d=
isclose its contents to any other person. Any views or other information in=
this message which do not relate to our business are not authorized by Cod=
eplay software Ltd, nor does this message form part of any contract unless =
so stated.
> As internet communications are capable of data corruption Codeplay Softwa=
re Ltd does not accept any responsibility for any changes made to this mess=
age after it was sent. Please note that Codeplay Software Ltd does not acce=
pt any liability or responsibility for viruses and it is your responsibilit=
y to scan any attachments.
> Company registered in England and Wales, number: 04567874
> Registered office: 81 Linkfield Street, Redhill RH1 6BY
>
> --
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit https://groups.google.com/a/
> isocpp.org/d/msgid/std-proposals/bf68a3f3-79af-eac4-
> 4a04-f1be2920ded7%40codeplay.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/bf68a3f3-79=
af-eac4-4a04-f1be2920ded7%40codeplay.com?utm_medium=3Demail&utm_source=3Dfo=
oter>
> .
>
> --
> You received this message because you are subscribed to the Google Groups
> "ISO C++ Standard - Future Proposals" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to std-proposals+unsubscribe@isocpp.org.
> To post to this group, send email to std-proposals@isocpp.org.
> To view this discussion on the web visit https://groups.google.com/a/
> isocpp.org/d/msgid/std-proposals/20161012152934.
> 4882513.63206.18280%40gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/20161012152=
934.4882513.63206.18280%40gmail.com?utm_medium=3Demail&utm_source=3Dfooter>
> .
>
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CANPtknw__0gguJHHWHqy8WfkrB4RuxD05pOa_Ed4uUEG2Rx=
5-w%40mail.gmail.com.
--001a11437b54f9c61d053eae51a3
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">That sounds like a very nice idea.</div><div class=3D"gmai=
l_extra"><br><div class=3D"gmail_quote">On Wed, Oct 12, 2016 at 5:29 PM, To=
ny V E <span dir=3D"ltr"><<a href=3D"mailto:tvaneerd@gmail.com" target=
=3D"_blank">tvaneerd@gmail.com</a>></span> wrote:<br><blockquote class=
=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padd=
ing-left:1ex"><div lang=3D"en-US" style=3D"background-color:rgb(255,255,255=
)" bgcolor=3D"#FFFFFF" text=3D"#000000"> =
<div style=3D"width:100%=
;color:rgb(31,73,125);font-family:Calibri,"Slate Pro",sans-serif,=
sans-serif;background-color:rgb(255,255,255)">Should we just make get and t=
uple_size automatically work on all PODs?</div><div style=3D"width:100%;col=
or:rgb(31,73,125);font-family:Calibri,"Slate Pro",sans-serif,sans=
-serif;background-color:rgb(255,255,255)"><br></div> =
=
<div style=3D"width:100%;color:rgb(31,73=
,125);font-family:Calibri,"Slate Pro",sans-serif,sans-serif;backg=
round-color:rgb(255,255,255)"><br></div> =
=
=
<div style=3D"color:rgb(31,73,125);font-family:Calibri,"Slat=
e Pro",sans-serif,sans-serif;background-color:rgb(255,255,255)">Sent=
=C2=A0from=C2=A0my=C2=A0BlackBerry=C2=A0<wbr>portable=C2=A0Babbage=C2=A0Dev=
ice</div> =
=
<table width=3D"100%" style=3D"border-=
spacing:0px;background-color:white"> <tbody><tr><td style=3D"background-col=
or:rgb(255,255,255)" colspan=3D"2"> <div style=3D=
"border-style:solid none none;padding:3pt 0in 0in;font-family:Tahoma,"=
BB Alpha Sans","Slate Pro";font-size:10pt;border-top-color:r=
gb(181,196,223);border-top-width:1pt"> <div><b>From: </b>Simon Brand</div>=
<div><b>Sent: </b>Wednesday, October 12, 2016 7:31 AM</div><div><b>To: </b>=
<a href=3D"mailto:std-proposals@isocpp.org" target=3D"_blank">std-proposals=
@isocpp.org</a></div><div><b>Reply To: </b><a href=3D"mailto:std-proposals@=
isocpp.org" target=3D"_blank">std-proposals@isocpp.org</a></div><div><b>Sub=
ject: </b>Re: [std-proposals] Variadic decomposition</div></div></td></tr><=
/tbody></table><div><div class=3D"h5"><div style=3D"border-style:solid none=
none;border-top-color:rgb(186,188,209);border-top-width:1pt;background-col=
or:rgb(255,255,255)"></div><br><div id=3D"m_7991076170877184622_originalCon=
tent" style=3D"background-color:rgb(255,255,255)">
=20
=20
=20
=20
<p>I believe that with variadic decomposition you would only be able
to use it for classes which only have public member data (or have
those data members in a single direct base class). For any class
without that property, you'd still need to write implementations
of <tt>get </tt>and <tt>tuple_size</tt>. So the main benefit of
your suggestion would be removing the need to implement a couple
of functions for a small set of classes, but to get that it's
mandating a language change and some new syntax.</p>
<p>I do like the idea of the proposal, but I think that the costs
outweigh the benefits over the <tt>std::apply</tt> solution.<br>
</p>
<div class=3D"m_7991076170877184622moz-cite-prefix">On 12/10/16 12:23, =
Richard Thorell
wrote:<br>
</div>
<blockquote type=3D"cite">
<div dir=3D"ltr">Hi,
<div><br>
</div>
<div>Yes, I take that back. Should've been types that supports
std::get/std::tuple_size (to little coffee still). But it
still requires you to add an overload for your structure
right?</div>
<div><br>
</div>
<div>With a variadic decomposition you could use any struct
without any overloads and you could benefit from all good
stuff that std::tuple gives you (# of members, compare
operators etc.).</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Richard</div>
<div><br>
</div>
<div>ps. just got another coffee<br>
<br>
On Wednesday, October 12, 2016 at 12:13:16 PM UTC+1, Simon
Brand wrote:
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8=
ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1p=
x;border-left-style:solid">
<div bgcolor=3D"#FFFFFF" text=3D"#000000">
<p>Hi Richard,<br>
</p>
<p><tt>std::apply</tt> doesn't just operate on <tt>std::t=
uple</tt>;
it uses <tt>std::get</tt> and <tt>std::tuple_size</tt>,
which is the same method by which you can add structured
binding support to your own class (unless the proposal
has been updated since I last looked).=C2=A0</p>
Thanks,<br>
Simon<br>
<br>
<div>On 12/10/16 12:09, Richard Thorell wrote:<br>
</div>
<blockquote type=3D"cite">
<div dir=3D"ltr">Hey,
<div><br>
</div>
<div>Yeah I'm aware of std::apply but it still only
operates on std::tuple. If you have your own
structure and you want to decompose it, there's no
generic way to do so.</div>
<div><br>
</div>
<div style=3D"border:1px solid rgb(187,187,187);backgroun=
d-color:rgb(250,250,250)"><code>
<div><span style=3D"color:rgb(0,0,136)">template</spa=
n><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102=
,0)"><</span><span style=3D"color:rgb(0,0,136)">class</span><span style=
=3D"color:rgb(0,0,0)"> T</span><span style=3D"color:rgb(102,102,0)">></s=
pan><span style=3D"color:rgb(0,0,0)"><br>
</span><span style=3D"color:rgb(0,0,136)">constexpr=
</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,=
0,136)">auto</span><span style=3D"color:rgb(0,0,0)"> struct_to_fw_tuple</sp=
an><span style=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,=
0,0)">T</span><span style=3D"color:rgb(102,102,0)">&</span><span style=
=3D"color:rgb(0,0,0)"> any_struct</span><span style=3D"color:rgb(102,102,0)=
">)</span><span style=3D"color:rgb(0,0,0)"><br>
</span><span style=3D"color:rgb(102,102,0)">{</span=
><span style=3D"color:rgb(0,0,0)"><br>
=C2=A0 =C2=A0 </span><span style=3D"color:rgb(0,0=
,136)">return</span><span style=3D"color:rgb(0,0,0)"> std</span><span style=
=3D"color:rgb(102,102,0)">::</span><font color=3D"#000000"><span style=3D"c=
olor:rgb(0,0,0)">forward_as_tuple</span><span style=3D"color:rgb(102,102,0)=
">(</span><span style=3D"color:rgb(0,0,136)">auto</span><span style=3D"colo=
r:rgb(102,102,0)">&{..<wbr>.}</span><span style=3D"color:rgb(0,0,0)"> <=
/span><span style=3D"color:rgb(102,102,0)">=3D</span><span style=3D"color:r=
gb(0,0,0)"> any_struct</span><span style=3D"color:rgb(102,102,0)">);</span>=
</font><span style=3D"color:rgb(0,0,0)"><br>
</span><span style=3D"color:rgb(102,102,0)">}</span=
></div>
</code></div>
<div><br>
<div style=3D"border:1px solid rgb(187,187,187);backgro=
und-color:rgb(250,250,250)"><code>
<div><span style=3D"color:rgb(0,0,136)">template</s=
pan><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,1=
02,0)"><</span><span style=3D"color:rgb(0,0,136)">class</span><span styl=
e=3D"color:rgb(0,0,0)"> F</span><span style=3D"color:rgb(102,102,0)">,</spa=
n><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(0,0,136=
)">class</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"colo=
r:rgb(102,0,102)">Tuple</span><span style=3D"color:rgb(102,102,0)">></sp=
an><span style=3D"color:rgb(0,0,0)"><br>
</span><span style=3D"color:rgb(0,0,136)">constex=
pr</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(=
0,0,136)">decltype</span><span style=3D"color:rgb(102,102,0)">(</span><span=
style=3D"color:rgb(0,0,136)">auto</span><span style=3D"color:rgb(102,102,0=
)">)</span><span style=3D"color:rgb(0,0,0)"> apply</span><span style=3D"col=
or:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,0)">F</span><span s=
tyle=3D"color:rgb(102,102,0)">&&</span><span style=3D"color:rgb(0,0=
,0)"> func</span><span style=3D"color:rgb(102,102,0)">,</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,0,102)">Tuple</s=
pan><span style=3D"color:rgb(102,102,0)">&&</span><span style=3D"co=
lor:rgb(0,0,0)"> tuple</span><span style=3D"color:rgb(102,102,0)">)</span><=
span style=3D"color:rgb(0,0,0)"><br>
</span><span style=3D"color:rgb(102,102,0)">{</sp=
an><span style=3D"color:rgb(0,0,0)"><br>
=C2=A0 =C2=A0 </span><span style=3D"color:rgb(0=
,0,136)">return</span><span style=3D"color:rgb(0,0,0)"> std</span><span sty=
le=3D"color:rgb(102,102,0)">::</span><span style=3D"color:rgb(0,0,0)">invok=
e</span><span style=3D"color:rgb(102,102,0)">(</span><span style=3D"color:r=
gb(0,0,0)">std</span><span style=3D"color:rgb(102,102,0)">::</span><span st=
yle=3D"color:rgb(0,0,0)">forward</span><span style=3D"color:rgb(102,102,0)"=
><</span><span style=3D"color:rgb(0,0,0)">F</span><span style=3D"color:r=
gb(102,102,0)">>(</span><span style=3D"color:rgb(0,0,0)">fu<wbr>nc</span=
><span style=3D"color:rgb(102,102,0)">),</span><span style=3D"color:rgb(0,0=
,0)"> </span><span style=3D"color:rgb(0,0,136)">auto</span><span style=3D"c=
olor:rgb(102,102,0)">&&{</span><font color=3D"#000000"><span style=
=3D"color:rgb(102,102,0)">...}</span><span style=3D"color:rgb(0,0,0)"> </sp=
an><span style=3D"color:rgb(102,102,0)">=3D</span><span style=3D"color:rgb(=
0,0,0)"> tuple</span><span style=3D"color:rgb(102,102,0)">);</span></font><=
span style=3D"color:rgb(0,0,0)"><br>
</span><span style=3D"color:rgb(102,102,0)">}</sp=
an></div>
</code></div>
<div><br>
</div>
The snippet in both post were just examples of
usages.</div>
<div><br>
</div>
<div>Cheers,</div>
<div>Richard<br>
<br>
On Wednesday, October 12, 2016 at 11:58:31 AM UTC+1,
Alisdair Meredith wrote:
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0=
px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-lef=
t-width:1px;border-left-style:solid">
<div dir=3D"auto">
<div>
<div style=3D"direction:inherit">A library
function with these semantics is already
present in the C++17 CD, called 'apply'=
..
=C2=A0What benefit do you expect by complicatin=
g
the language with a compiler feature to
delivery (mostly) the same effect?</div>
<div style=3D"direction:inherit"><br>
</div>
<div style=3D"direction:inherit">(By using the
INVOKE treatment, the library version is
actually slightly more capable than a likely
language feature, dispatching through
pointer-to-members etc. as well.)</div>
<div style=3D"direction:inherit"><br>
</div>
<div style=3D"direction:inherit">AlisdairM</div>
<br>
Sent from my iPad</div>
<div><br>
On 12 Oct 2016, at 06:51, Richard Thorell <<a =
rel=3D"nofollow">richard...@king.com</a>>
wrote:<br>
<br>
</div>
<blockquote type=3D"cite">
<div>
<div dir=3D"ltr">Hey,
<div>
<div><br>
</div>
<div>After looking at the structured
bindings paper [<a href=3D"http://www.ope=
n-std.org/jtc1/sc22/wg21/docs/papers/2015/p0144r0.pdf" target=3D"_blank" re=
l=3D"nofollow">http://www.open-std.org/jtc1/<wbr>sc22/wg21/docs/papers/2015=
/p01<wbr>44r0.pdf</a>]
I thought, why don't we allow the
members to be automatically unpacked
into it's components and forwarded to
a method?</div>
<div>We have this functionality when it
comes to tuples today, using
std::get<> and
std::index_sequence. But what if it
was a built-in language feature and a
one-liner? And worked with any
structure!<br>
</div>
<div><br>
</div>
<div>Proposal:</div>
</div>
<div style=3D"border:1px solid rgb(187,187,18=
7);background-color:rgb(250,250,250)"><code>
<div><span style=3D"color:rgb(0,0,136)">t=
emplate</span><span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color=
:rgb(102,102,0)"><</span><span style=3D"color:rgb(0,0,136)">class</span>=
<span style=3D"color:rgb(102,102,0)">...</span><span style=3D"color:rgb(0,0=
,0)"> </span><span style=3D"color:rgb(102,0,102)">Args</span><span style=3D=
"color:rgb(102,102,0)">></span><span style=3D"color:rgb(0,0,0)"><br>
</span><span style=3D"color:rgb(0,0,136=
)">void</span><span style=3D"color:rgb(0,0,0)"> foo</span><span style=3D"co=
lor:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,136)">void</span><=
span style=3D"color:rgb(102,102,0)">(*</span><span style=3D"color:rgb(0,0,0=
)">func</span><span style=3D"color:rgb(102,102,0)">)(</span><span style=3D"=
color:rgb(102,0,102)">Args</span><span style=3D"color:rgb(102,102,0)">...),=
</span><span style=3D"color:rgb(0,0,0)"> std</span><span style=3D"color:rgb=
(102,102,0)">::</span><span style=3D"color:rgb(0,0,0)">tuple</span><span st=
yle=3D"color:rgb(102,102,0)"><</span><span style=3D"color:rgb(102,0,102)=
">Args</span><span style=3D"color:rgb(102,102,0)">...></span><span style=
=3D"color:rgb(0,0,0)"> args</span><span style=3D"color:rgb(102,102,0)">)</s=
pan><span style=3D"color:rgb(0,0,0)"><br>
</span><span style=3D"color:rgb(102,102=
,0)">{</span><span style=3D"color:rgb(0,0,0)"><br>
=C2=A0 =C2=A0 func</span><span style=
=3D"color:rgb(102,102,0)">(</span><span style=3D"color:rgb(0,0,136)">auto</=
span><span style=3D"color:rgb(102,102,0)">{</span><span style=3D"color:rgb(=
0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">...</span><span style=
=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102,0)">}</span>=
<span style=3D"color:rgb(0,0,0)"> </span><span style=3D"color:rgb(102,102,0=
)">=3D</span><span style=3D"color:rgb(0,0,0)"> args</span><span style=3D"co=
lor:rgb(102,102,0)">);</span><span style=3D"color:rgb(0,0,0)"><br>
</span><span style=3D"color:rgb(102,102=
,0)">}</span></div>
</code></div>
<div>=C2=A0</div>
<div>The syntax is questionable, but I
wanted it to follow the structured
bindings syntax as close as possible.
The auto keyword can have const, l-value
and r-value reference modifiers which
will be appended to each argument. Also,
the decomposition can only be used
within a function/constructor call.</div>
<div><br>
</div>
<div>Maybe this has already been discussed
somewhere?</div>
<div><br>
</div>
<div>Any feedback is appreciated!</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Richard</div>
</div>
-- <br>
You received this message because you are
subscribed to the Google Groups "ISO C++
Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop
receiving emails from it, send an email to <a r=
el=3D"nofollow">std-proposal...@isocpp.org</a>.<br>
To post to this group, send email to <a rel=3D"=
nofollow">std-pr...@isocpp.org</a>.<br>
To view this discussion on the web visit <a hre=
f=3D"https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/0d627ddf-=
dec9-4051-abaf-e6e6f8dbeaaa%40isocpp.org?utm_medium=3Demail&utm_source=
=3Dfooter" target=3D"_blank" rel=3D"nofollow">https://groups.google.com/a/i=
s<wbr>ocpp.org/d/msgid/std-proposals<wbr>/0d627ddf-dec9-4051-abaf-<wbr>e6e6=
f8dbeaaa%40isocpp.org</a>.<br>
</div>
</blockquote>
</div>
</blockquote>
</div>
</div>
-- <br>
You received this message because you are subscribed to
the Google Groups "ISO C++ Standard - Future Proposals=
"
group.<br>
To unsubscribe from this group and stop receiving emails
from it, send an email to <a rel=3D"nofollow">std-proposal.=
...@isocpp.org</a>.<br>
To post to this group, send email to <a rel=3D"nofollow">st=
d-pr...@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https:/=
/groups.google.com/a/isocpp.org/d/msgid/std-proposals/6867504e-d4e5-4e2b-85=
9c-3040f7cdc05f%40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" ta=
rget=3D"_blank" rel=3D"nofollow">https://groups.google.com/a/is<wbr>ocpp.or=
g/d/msgid/std-proposals<wbr>/6867504e-d4e5-4e2b-859c-<wbr>3040f7cdc05f%40is=
ocpp.org</a>.<br>
</blockquote>
<br>
<pre cols=3D"72">--=20
Simon Brand
Staff Software Engineer
Codeplay Software Ltd
Level C, Argyle House, 3 Lady Lawson St, Edinburgh, EH3 9DR
Tel: 0131 466 0503
Fax: 0131 557 6600
Website: <a href=3D"http://www.codeplay.com" target=3D"_blank" rel=3D"nofol=
low">http://www.codeplay.com</a>
Twitter: <a href=3D"https://twitter.com/codeplaysoft" target=3D"_blank" rel=
=3D"nofollow">https://twitter.com/codeplayso<wbr>ft</a>
This email and any attachments may contain confidential and /or privileged =
information and is for use by the addressee only. If you are not the intend=
ed recipient, please notify Codeplay Software Ltd immediately and delete th=
e message from your computer. You may not copy or forward it, or use or dis=
close its contents to any other person. Any views or other information in t=
his message which do not relate to our business are not authorized by Codep=
lay software Ltd, nor does this message form part of any contract unless so=
stated.
As internet communications are capable of data corruption Codeplay Software=
Ltd does not accept any responsibility for any changes made to this messag=
e after it was sent. Please note that Codeplay Software Ltd does not accept=
any liability or responsibility for viruses and it is your responsibility =
to scan any attachments.
Company registered in England and Wales, number: 04567874
Registered office: 81 Linkfield Street, Redhill RH1 6BY </pre>
</div>
</blockquote></div></div>
--=20
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/c28ca0ca-b59d-4e06-8c79-52f7cd859a49%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/c28c=
a0ca-b59d-4e06-<wbr>8c79-52f7cd859a49%40isocpp.org</a><wbr>.
</blockquote>
<pre class=3D"m_7991076170877184622moz-signature" cols=3D"72">--=20
Simon Brand
Staff Software Engineer
Codeplay Software Ltd
Level C, Argyle House, 3 Lady Lawson St, Edinburgh, EH3 9DR
Tel: 0131 466 0503
Fax: 0131 557 6600
Website: <a class=3D"m_7991076170877184622moz-txt-link-freetext" href=3D"ht=
tp://www.codeplay.com" target=3D"_blank">http://www.codeplay.com</a>
Twitter: <a class=3D"m_7991076170877184622moz-txt-link-freetext" href=3D"ht=
tps://twitter.com/codeplaysoft" target=3D"_blank">https://twitter.com/<wbr>=
codeplaysoft</a>
This email and any attachments may contain confidential and /or privileged =
information and is for use by the addressee only. If you are not the intend=
ed recipient, please notify Codeplay Software Ltd immediately and delete th=
e message from your computer. You may not copy or forward it, or use or dis=
close its contents to any other person. Any views or other information in t=
his message which do not relate to our business are not authorized by Codep=
lay software Ltd, nor does this message form part of any contract unless so=
stated.
As internet communications are capable of data corruption Codeplay Software=
Ltd does not accept any responsibility for any changes made to this messag=
e after it was sent. Please note that Codeplay Software Ltd does not accept=
any liability or responsibility for viruses and it is your responsibility =
to scan any attachments.
Company registered in England and Wales, number: 04567874
Registered office: 81 Linkfield Street, Redhill RH1 6BY </pre>
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/bf68a3f3-79af-eac4-4a04-f1be2920ded7%=
40codeplay.com?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank=
">https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/bf=
68a3f3-79af-eac4-<wbr>4a04-f1be2920ded7%40codeplay.<wbr>com</a>.<br>
<br></div></div></div></div><div><div class=3D"h5">
<p></p>
-- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></div></div>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/20161012152934.4882513.63206.18280%40=
gmail.com?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank">htt=
ps://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/2016101=
2152934.<wbr>4882513.63206.18280%40gmail.<wbr>com</a>.<br>
</blockquote></div><br></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CANPtknw__0gguJHHWHqy8WfkrB4RuxD05pOa=
_Ed4uUEG2Rx5-w%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CANPtknw__0gguJHH=
WHqy8WfkrB4RuxD05pOa_Ed4uUEG2Rx5-w%40mail.gmail.com</a>.<br />
--001a11437b54f9c61d053eae51a3--
.
Author: Simon Brand <simon@codeplay.com>
Date: Wed, 12 Oct 2016 21:32:16 +0100
Raw View
This is a multi-part message in MIME format.
--------------6D994C634D2DEE155FBD1BBE
Content-Type: text/plain; charset=UTF-8; format=flowed
That sounds like a good possibility. I'd also be interested in
co-authoring a proposal about it, although it's not something I've done
for the C++ standard before.
On 12/10/16 16:37, Ville Voutilainen wrote:
>
>
> On 12 October 2016 at 18:29, Tony V E <tvaneerd@gmail.com
> <mailto:tvaneerd@gmail.com>> wrote:
>
> Should we just make get and tuple_size automatically work on all PODs?
>
>
>
> Yes. Proposals welcome, I can co-author.
>
> --
> 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
> <mailto:std-proposals+unsubscribe@isocpp.org>.
> To post to this group, send email to std-proposals@isocpp.org
> <mailto:std-proposals@isocpp.org>.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFk2RUYiUZqbEpYYJWkQvDG58pYZA%3D_5s4Vkc4n5_fMvOFskVw%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFk2RUYiUZqbEpYYJWkQvDG58pYZA%3D_5s4Vkc4n5_fMvOFskVw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/af0862c0-e2b6-8c40-2e41-b58b9177e711%40codeplay.com.
--------------6D994C634D2DEE155FBD1BBE
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 text=3D"#000000" bgcolor=3D"#FFFFFF">
<p>That sounds like a good possibility. I'd also be interested in
co-authoring a proposal about it, although it's not something I've
done for the C++ standard before.<br>
</p>
<br>
<div class=3D"moz-cite-prefix">On 12/10/16 16:37, Ville Voutilainen
wrote:<br>
</div>
<blockquote
cite=3D"mid:CAFk2RUYiUZqbEpYYJWkQvDG58pYZA=3D_5s4Vkc4n5_fMvOFskVw@mail.gmai=
l.com"
type=3D"cite">
<div dir=3D"ltr"><br>
<div class=3D"gmail_extra"><br>
<div class=3D"gmail_quote">On 12 October 2016 at 18:29, Tony V E
<span dir=3D"ltr"><<a moz-do-not-send=3D"true"
href=3D"mailto:tvaneerd@gmail.com" target=3D"_blank">tvanee=
rd@gmail.com</a>></span>
wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor=3D"#FFFFFF" text=3D"#000000"
style=3D"background-color:rgb(255,255,255);line-height:init=
ial"
lang=3D"en-US">
<div
style=3D"width:100%;font-size:initial;font-family:Calibri=
,'Slate
Pro',sans-serif,sans-serif;color:rgb(31,73,125);text-align:initial;backgrou=
nd-color:rgb(255,255,255)">Should
we just make get and tuple_size automatically work on
all PODs?</div>
<div
style=3D"width:100%;font-size:initial;font-family:Calibri=
,'Slate
Pro',sans-serif,sans-serif;color:rgb(31,73,125);text-align:initial;backgrou=
nd-color:rgb(255,255,255)"><br>
<br>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>Yes. Proposals welcome, I can co-author. <br>
</div>
</div>
<br>
</div>
</div>
-- <br>
You received this message because you are subscribed to the Google
Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it,
send an email to <a moz-do-not-send=3D"true"
href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposals+=
unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a moz-do-not-send=3D"true"
href=3D"mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</=
a>.<br>
To view this discussion on the web visit <a
moz-do-not-send=3D"true"
href=3D"https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFk2R=
UYiUZqbEpYYJWkQvDG58pYZA%3D_5s4Vkc4n5_fMvOFskVw%40mail.gmail.com?utm_medium=
=3Demail&utm_source=3Dfooter">https://groups.google.com/a/isocpp.org/d/=
msgid/std-proposals/CAFk2RUYiUZqbEpYYJWkQvDG58pYZA%3D_5s4Vkc4n5_fMvOFskVw%4=
0mail.gmail.com</a>.<br>
</blockquote>
<br>
</body>
</html>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/af0862c0-e2b6-8c40-2e41-b58b9177e711%=
40codeplay.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.googl=
e.com/a/isocpp.org/d/msgid/std-proposals/af0862c0-e2b6-8c40-2e41-b58b9177e7=
11%40codeplay.com</a>.<br />
--------------6D994C634D2DEE155FBD1BBE--
.
Author: Arthur O'Dwyer <arthur.j.odwyer@gmail.com>
Date: Thu, 13 Oct 2016 01:07:12 -0700 (PDT)
Raw View
------=_Part_580_1173227792.1476346032821
Content-Type: multipart/alternative;
boundary="----=_Part_581_1798880156.1476346032821"
------=_Part_581_1798880156.1476346032821
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Wednesday, October 12, 2016 at 8:29:47 AM UTC-7, Tony V E wrote:
>
> Should we just make get and tuple_size automatically work on all PODs?
>
Nitpick: You don't mean "PODs", you mean "structs with no non-public=20
non-static data members".
Not a nitpick: std::apply and decomposition declarations are inconsistent=
=20
in how they do things.
namespace X { struct S {}; /* ... */ };
X::S x;
std::apply(f, x); // Line 1
auto [a,b,c] =3D x; // Line 2
Line 1 above will result in instantiation of std::tuple_size<S>::value,=20
std::get<0>(x), and so on; it explicitly will not attempt to look in=20
namespace X, because it is not defined in terms of ADL.
Line 2 above will result in instantiation of std::tuple_size<S>::value,=20
X::get<0>(x), and so on; it explicitly will not attempt to instantiate=20
std::get<0>(x), because all it does is plain old ADL lookup. Namespace std=
=20
is privileged for "tuple_size" but NOT privileged for "get".
Making std::get magically DTRT for struct types will help with Line 1, but=
=20
it will not allow you to simplify the wording that controls Line 2;=20
decomposition declarations will still need a special magic exemption for=20
struct types.
IMO the current state of affairs is a mess, but I have no silver bullet to=
=20
get us out of trouble.
=E2=80=93Arthur
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/1e1b7f72-ebbd-4344-b8b0-44b17c99462d%40isocpp.or=
g.
------=_Part_581_1798880156.1476346032821
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Wednesday, October 12, 2016 at 8:29:47 AM UTC-7, Tony V=
E 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"#FFFF=
FF" text=3D"#000000" lang=3D"en-US" style=3D"background-color:rgb(255,255,2=
55);line-height:initial"> =
<div style=3D"width:100%;font-size:init=
ial;font-family:Calibri,'Slate Pro',sans-serif,sans-serif;color:rgb=
(31,73,125);text-align:initial;background-color:rgb(255,255,255)">Should we=
just make get and tuple_size automatically work on all PODs?</div></div></=
blockquote><div><br></div><div>Nitpick: You don't mean "PODs"=
, you mean "structs with no non-public non-static data members".<=
/div><div><br></div><div>Not a nitpick: std::apply and decomposition declar=
ations are inconsistent in how they do things.</div><div><br></div><div>=C2=
=A0 =C2=A0 namespace X { struct S {}; /* ... */ };</div><div><br></div><div=
>=C2=A0 =C2=A0 X::S x;</div><div>=C2=A0 =C2=A0 std::apply(f, x); =C2=A0// L=
ine 1</div><div>=C2=A0 =C2=A0 auto [a,b,c] =3D x; =C2=A0// Line 2</div><div=
><br></div><div>Line 1 above will result in instantiation of std::tuple_siz=
e<S>::value, std::get<0>(x), and so on; it explicitly will not =
attempt to look in namespace X, because it is not defined in terms of ADL.<=
/div><div>Line 2 above will result in instantiation of std::tuple_size<S=
>::value, X::get<0>(x), and so on; it explicitly will not attempt =
to instantiate std::get<0>(x), because all it does is plain old ADL l=
ookup. Namespace std is privileged for "tuple_size" but NOT privi=
leged for "get".</div><div><br></div><div>Making std::get magical=
ly DTRT for struct types will help with Line 1, but it will not allow you t=
o simplify the wording that controls Line 2; decomposition declarations wil=
l still need a special magic exemption for struct types.</div><div><br></di=
v><div>IMO the current state of affairs is a mess, but I have no silver bul=
let to get us out of trouble.</div><div><br></div><div>=E2=80=93Arthur</div=
></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/1e1b7f72-ebbd-4344-b8b0-44b17c99462d%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/1e1b7f72-ebbd-4344-b8b0-44b17c99462d=
%40isocpp.org</a>.<br />
------=_Part_581_1798880156.1476346032821--
------=_Part_580_1173227792.1476346032821--
.
Author: Richard Thorell <richard.thorell@king.com>
Date: Thu, 13 Oct 2016 06:19:07 -0700 (PDT)
Raw View
------=_Part_332_114146421.1476364747428
Content-Type: multipart/alternative;
boundary="----=_Part_333_279097443.1476364747428"
------=_Part_333_279097443.1476364747428
Content-Type: text/plain; charset=UTF-8
This seems to cover what has been discussed here:
https://groups.google.com/a/isocpp.org/forum/?#!topic/std-proposals/Umm9lHwUMxo
I do like the idea of extending std::get and std::tuple_size for any
standard layout type.
Cheers,
Richard
On Wednesday, October 12, 2016 at 9:32:21 PM UTC+1, Simon Brand wrote:
>
> That sounds like a good possibility. I'd also be interested in
> co-authoring a proposal about it, although it's not something I've done for
> the C++ standard before.
>
> On 12/10/16 16:37, Ville Voutilainen wrote:
>
>
>
> On 12 October 2016 at 18:29, Tony V E <tvan...@gmail.com <javascript:>>
> wrote:
>
>> Should we just make get and tuple_size automatically work on all PODs?
>>
>>
>>
> Yes. Proposals welcome, I can co-author.
>
> --
> 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-proposal...@isocpp.org <javascript:>.
> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
> To view this discussion on the web visit
> https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFk2RUYiUZqbEpYYJWkQvDG58pYZA%3D_5s4Vkc4n5_fMvOFskVw%40mail.gmail.com
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFk2RUYiUZqbEpYYJWkQvDG58pYZA%3D_5s4Vkc4n5_fMvOFskVw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
>
>
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/017486fa-6d89-4a27-9c7e-805d2a102d8e%40isocpp.org.
------=_Part_333_279097443.1476364747428
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>This seems to cover what has been discussed here:</di=
v>https://groups.google.com/a/isocpp.org/forum/?#!topic/std-proposals/Umm9l=
HwUMxo<div><br></div><div>I do like the idea of extending std::get and std:=
:tuple_size for any standard layout type.</div><div><br></div><div>Cheers,<=
/div><div>Richard<br><br>On Wednesday, October 12, 2016 at 9:32:21 PM UTC+1=
, Simon Brand wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
=20
=20
=20
<div text=3D"#000000" bgcolor=3D"#FFFFFF">
<p>That sounds like a good possibility. I'd also be interested in
co-authoring a proposal about it, although it's not something I&#=
39;ve
done for the C++ standard before.<br>
</p>
<br>
<div>On 12/10/16 16:37, Ville Voutilainen
wrote:<br>
</div>
<blockquote type=3D"cite">
<div dir=3D"ltr"><br>
<div><br>
<div class=3D"gmail_quote">On 12 October 2016 at 18:29, Tony V E
<span dir=3D"ltr"><<a href=3D"javascript:" target=3D"_blank"=
gdf-obfuscated-mailto=3D"9ytjUTt3AQAJ" rel=3D"nofollow" onmousedown=3D"thi=
s.href=3D'javascript:';return true;" onclick=3D"this.href=3D'ja=
vascript:';return true;">tvan...@gmail.com</a>></span>
wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bo=
rder-left:1px #ccc solid;padding-left:1ex">
<div bgcolor=3D"#FFFFFF" text=3D"#000000" style=3D"background=
-color:rgb(255,255,255);line-height:initial" lang=3D"en-US">
<div>Should
we just make get and tuple_size automatically work on
all PODs?</div>
<div><br>
<br>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>Yes. Proposals welcome, I can co-author. <br>
</div>
</div>
<br>
</div>
</div>
-- <br>
You received this message because you are subscribed to the Google
Groups "ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it,
send an email to <a href=3D"javascript:" target=3D"_blank" gdf-obfusc=
ated-mailto=3D"9ytjUTt3AQAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D&#=
39;javascript:';return true;" onclick=3D"this.href=3D'javascript:&#=
39;;return true;">std-proposal...@<wbr>isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=
=3D"_blank" gdf-obfuscated-mailto=3D"9ytjUTt3AQAJ" rel=3D"nofollow" onmouse=
down=3D"this.href=3D'javascript:';return true;" onclick=3D"this.hre=
f=3D'javascript:';return true;">std-pr...@isocpp.org</a>.<br>
To view this discussion on the web visit <a href=3D"https://groups.go=
ogle.com/a/isocpp.org/d/msgid/std-proposals/CAFk2RUYiUZqbEpYYJWkQvDG58pYZA%=
3D_5s4Vkc4n5_fMvOFskVw%40mail.gmail.com?utm_medium=3Demail&utm_source=
=3Dfooter" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=3D&#=
39;https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFk2RUYiUZ=
qbEpYYJWkQvDG58pYZA%3D_5s4Vkc4n5_fMvOFskVw%40mail.gmail.com?utm_medium\x3de=
mail\x26utm_source\x3dfooter';return true;" onclick=3D"this.href=3D'=
;https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAFk2RUYiUZqb=
EpYYJWkQvDG58pYZA%3D_5s4Vkc4n5_fMvOFskVw%40mail.gmail.com?utm_medium\x3dema=
il\x26utm_source\x3dfooter';return true;">https://groups.google.com/a/<=
wbr>isocpp.org/d/msgid/std-<wbr>proposals/<wbr>CAFk2RUYiUZqbEpYYJWkQvDG58pY=
ZA<wbr>%3D_5s4Vkc4n5_fMvOFskVw%<wbr>40mail.gmail.com</a>.<br>
</blockquote>
<br>
</div>
</blockquote></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/017486fa-6d89-4a27-9c7e-805d2a102d8e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/017486fa-6d89-4a27-9c7e-805d2a102d8e=
%40isocpp.org</a>.<br />
------=_Part_333_279097443.1476364747428--
------=_Part_332_114146421.1476364747428--
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Thu, 13 Oct 2016 20:08:52 +0200
Raw View
This is a multi-part message in MIME format.
--------------4FD32A201A676BF79F556E99
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Le 12/10/2016 =C3=A0 17:37, Ville Voutilainen a =C3=A9crit :
>
>
> On 12 October 2016 at 18:29, Tony V E <tvaneerd@gmail.com=20
> <mailto:tvaneerd@gmail.com>> wrote:
>
> Should we just make get and tuple_size automatically work on all PODs=
?
>
>
>
> Yes. Proposals welcome, I can co-author.
>
Hi,
I have taken a little different approach in
Product-Type access -=20
https://github.com/viboes/std-make/blob/master/doc/proposal/reflection/p032=
7r1.md
I have added a nested product_type scope for size/get/element.
I understand that been able to define by default=20
tuple_size<T>/tuple_element<I,T>/get<I> for "structs with no non-public=20
non-static data members" would be super. However,
I don't know how we can define them by default for "structs with no=20
non-public non-static data members" and h tuple_size/ tuple_element/ave=20
get as customization points for de-structure binding at the same time.=20
Maybe I'm missing something evident.
Any comment welcome.
Vicente
P.S. Unfortunately I will not have time to change the wording respect to=20
p0327r0.
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/ec6fdedc-4f32-a805-1dd5-917f590a3567%40wanadoo.f=
r.
--------------4FD32A201A676BF79F556E99
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 12/10/2016 =C3=A0 17:37, Ville
Voutilainen a =C3=A9crit=C2=A0:<br>
</div>
<blockquote
cite=3D"mid:CAFk2RUYiUZqbEpYYJWkQvDG58pYZA=3D_5s4Vkc4n5_fMvOFskVw@mail.gmai=
l.com"
type=3D"cite">
<div dir=3D"ltr"><br>
<div class=3D"gmail_extra"><br>
<div class=3D"gmail_quote">On 12 October 2016 at 18:29, Tony V E
<span dir=3D"ltr"><<a moz-do-not-send=3D"true"
href=3D"mailto:tvaneerd@gmail.com" target=3D"_blank">tvanee=
rd@gmail.com</a>></span>
wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor=3D"#FFFFFF" text=3D"#000000"
style=3D"background-color:rgb(255,255,255);line-height:init=
ial"
lang=3D"en-US">
<div
style=3D"width:100%;font-size:initial;font-family:Calibri=
,'Slate
Pro',sans-serif,sans-serif;color:rgb(31,73,125);text-align:initial;backgrou=
nd-color:rgb(255,255,255)">Should
we just make get and tuple_size automatically work on
all PODs?</div>
<div
style=3D"width:100%;font-size:initial;font-family:Calibri=
,'Slate
Pro',sans-serif,sans-serif;color:rgb(31,73,125);text-align:initial;backgrou=
nd-color:rgb(255,255,255)"><br>
<br>
</div>
</div>
</blockquote>
<div><br>
</div>
<div>Yes. Proposals welcome, I can co-author. <br>
</div>
</div>
<br>
</div>
</div>
</blockquote>
<br>
Hi,<br>
<br>
I have taken a little different approach in <br>
<br>
=C2=A0=C2=A0=C2=A0 Product-Type access=C2=A0 -
<a class=3D"moz-txt-link-freetext" href=3D"https://github.com/viboes/std-ma=
ke/blob/master/doc/proposal/reflection/p0327r1.md">https://github.com/viboe=
s/std-make/blob/master/doc/proposal/reflection/p0327r1.md</a><br>
<br>
I have added a nested product_type scope for size/get/element.<br>
<br>
I understand that been able to define by default
tuple_size<T>/tuple_element<I,T>/get<I> for
"structs with no non-public non-static data members" would be super.
However, <br>
I don't know how we can define them by default for "structs with no
non-public non-static data members" and h tuple_size/
tuple_element/ave get as customization points for de-structure
binding at the same time. Maybe I'm missing something evident.<br>
<br>
Any comment welcome.<br>
<br>
Vicente<br>
<br>
P.S. Unfortunately I will not have time to change the wording
respect to p0327r0.<br>
<br>
<br>
<br>
</body>
</html>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/ec6fdedc-4f32-a805-1dd5-917f590a3567%=
40wanadoo.fr?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/ec6fdedc-4f32-a805-1dd5-917f590a3567=
%40wanadoo.fr</a>.<br />
--------------4FD32A201A676BF79F556E99--
.
Author: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Date: Thu, 13 Oct 2016 21:02:22 +0200
Raw View
This is a multi-part message in MIME format.
--------------C8FAF69DDC93811F9323A81A
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Le 12/10/2016 =C3=A0 15:56, Nicol Bolas a =C3=A9crit :
> On Wednesday, October 12, 2016 at 6:51:24 AM UTC-4, Richard Thorell=20
> wrote:
>
> Hey,
>
> After looking at the structured bindings paper
> [http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0144r0.pdf
> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0144r0.pdf>=
]
> I thought, why don't we allow the members to be automatically
> unpacked into it's components and forwarded to a method?
> We have this functionality when it comes to tuples today, using
> std::get<> and std::index_sequence. But what if it was a built-in
> language feature and a one-liner? And worked with any structure!
>
> Proposal:
> |
> template<class...Args>
> voidfoo(void(*func)(Args...),std::tuple<Args...>args)
> {
> func(auto{...}=3Dargs);
> }
> |
> The syntax is questionable, but I wanted it to follow the
> structured bindings syntax as close as possible. The auto keyword
> can have const, l-value and r-value reference modifiers which will
> be appended to each argument. Also, the decomposition can only be
> used within a function/constructor call.
>
> Maybe this has already been discussed somewhere?
>
> Any feedback is appreciated!
>
> Thanks,
> Richard
>
>
>
> There have already been discussions about having a way to transform=20
> tuples and tuple-like types into parameter packs of their elements.=20
> One suggested syntax would look like this:
>
> |
> template<classF,class...Args>
> voidfoo(std::tuple<Args...>args)
> {
> func([:]args...);
> }
> |
>
> This syntax allows you to do things like=20
> `func(std::forward<Args>([:]args)...)`. It would even allow you to=20
> call arbitrary expressions on tuple elements, or allow them to=20
> participate in fold expressions. To get the sum of all elements of a=20
> tuple, you do `(0 + ... + [:]args)`.
>
> That's much more flexible than your "structured binding"-based stuff here=
..
See " parameter packs outside of templates" -=20
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0341r0.html
Vicente
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/398c0970-d96f-4ecc-cbe8-c407e8434e67%40wanadoo.f=
r.
--------------C8FAF69DDC93811F9323A81A
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 12/10/2016 =C3=A0 15:56, Nicol Bolas =
a
=C3=A9crit=C2=A0:<br>
</div>
<blockquote
cite=3D"mid:743dd7c5-bec3-41c4-a787-1554f43cbe81@isocpp.org"
type=3D"cite">
<div dir=3D"ltr">On Wednesday, October 12, 2016 at 6:51:24 AM UTC-4,
Richard Thorell wrote:
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<div dir=3D"ltr">Hey,
<div>
<div><br>
</div>
<div>After looking at the structured bindings paper [<a
moz-do-not-send=3D"true"
href=3D"http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0144r0.pdf=
"
target=3D"_blank" rel=3D"nofollow"
onmousedown=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww=
..open-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2015%2Fp0144r0.pdf\x26=
sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG1MKJjnldtN4lm6MvN4r0b6M0ewA';return
true;"
onclick=3D"this.href=3D'http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.ope=
n-std.org%2Fjtc1%2Fsc22%2Fwg21%2Fdocs%2Fpapers%2F2015%2Fp0144r0.pdf\x26sa\x=
3dD\x26sntz\x3d1\x26usg\x3dAFQjCNG1MKJjnldtN4lm6MvN4r0b6M0ewA';return
true;">http://www.open-std.org/jtc1/<wbr>sc22/wg21/docs/p=
apers/2015/<wbr>p0144r0.pdf</a>]
I thought, why don't we allow the members to be
automatically unpacked into it's components and
forwarded to a method?</div>
<div>We have this functionality when it comes to tuples
today, using std::get<> and std::index_sequence.
But what if it was a built-in language feature and a
one-liner? And worked with any structure!<br>
</div>
<div><br>
</div>
<div>Proposal:</div>
</div>
<div
style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);bo=
rder-style:solid;border-width:1px;word-wrap:break-word"><code>
<div><span style=3D"color:#008">template</span><span
style=3D"color:#000"> </span><span style=3D"color:#660"=
><</span><span
style=3D"color:#008">class</span><span
style=3D"color:#660">...</span><span
style=3D"color:#000"> </span><span style=3D"color:#606"=
>Args</span><span
style=3D"color:#660">></span><span
style=3D"color:#000"><br>
</span><span style=3D"color:#008">void</span><span
style=3D"color:#000"> foo</span><span
style=3D"color:#660">(</span><span style=3D"color:#008"=
>void</span><span
style=3D"color:#660">(*</span><span style=3D"color:#000=
">func</span><span
style=3D"color:#660">)(</span><span style=3D"color:#606=
">Args</span><span
style=3D"color:#660">...),</span><span
style=3D"color:#000"> std</span><span
style=3D"color:#660">::</span><span style=3D"color:#000=
">tuple</span><span
style=3D"color:#660"><</span><span
style=3D"color:#606">Args</span><span
style=3D"color:#660">...></span><span
style=3D"color:#000"> args</span><span
style=3D"color:#660">)</span><span style=3D"color:#000"=
><br>
</span><span style=3D"color:#660">{</span><span
style=3D"color:#000"><br>
=C2=A0 =C2=A0 func</span><span style=3D"color:#660">(</=
span><span
style=3D"color:#008">auto</span><span
style=3D"color:#660">{</span><span style=3D"color:#000"=
>
</span><span style=3D"color:#660">...</span><span
style=3D"color:#000"> </span><span style=3D"color:#660"=
>}</span><span
style=3D"color:#000"> </span><span style=3D"color:#660"=
>=3D</span><span
style=3D"color:#000"> args</span><span
style=3D"color:#660">);</span><span style=3D"color:#000=
"><br>
</span><span style=3D"color:#660">}</span></div>
</code></div>
<div>=C2=A0</div>
<div>The syntax is questionable, but I wanted it to follow
the structured bindings syntax as close as possible. The
auto keyword can have const, l-value and r-value reference
modifiers which will be appended to each argument. Also,
the decomposition can only be used within a
function/constructor call.</div>
<div><br>
</div>
<div>Maybe this has already been discussed somewhere?</div>
<div><br>
</div>
<div>Any feedback is appreciated!</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Richard</div>
</div>
</blockquote>
<div><br>
<br>
There have already been discussions about having a way to
transform tuples and tuple-like types into parameter packs of
their elements. One suggested syntax would look like this:<br>
<br>
<div style=3D"background-color: rgb(250, 250, 250);
border-color: rgb(187, 187, 187); border-style: solid;
border-width: 1px; overflow-wrap: break-word;"
class=3D"prettyprint"><code class=3D"prettyprint">
<div class=3D"subprettyprint"><span style=3D"color: #008;"
class=3D"styled-by-prettify">template</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><span
style=3D"color: #008;" class=3D"styled-by-prettify">class=
</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> F</s=
pan><span
style=3D"color: #660;" class=3D"styled-by-prettify">,</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #008;" class=3D"styled-by-prettify">class=
</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">...</=
span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> </sp=
an><span
style=3D"color: #606;" class=3D"styled-by-prettify">Args<=
/span><span
style=3D"color: #660;" class=3D"styled-by-prettify">><=
/span><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
</span><span style=3D"color: #008;"
class=3D"styled-by-prettify">void</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> foo<=
/span><span
style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify">std</=
span><span
style=3D"color: #660;" class=3D"styled-by-prettify">::</s=
pan><span
style=3D"color: #000;" class=3D"styled-by-prettify">tuple=
</span><span
style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><span
style=3D"color: #606;" class=3D"styled-by-prettify">Args<=
/span><span
style=3D"color: #660;" class=3D"styled-by-prettify">...&g=
t;</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> args=
</span><span
style=3D"color: #660;" class=3D"styled-by-prettify">)</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">{</span><span style=3D"color=
:
#000;" class=3D"styled-by-prettify"><br>
=C2=A0 =C2=A0 func</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">([:]</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">args<=
/span><span
style=3D"color: #660;" class=3D"styled-by-prettify">...);=
</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
</span><span style=3D"color: #660;"
class=3D"styled-by-prettify">}</span><span style=3D"color=
:
#000;" class=3D"styled-by-prettify"><br>
</span></div>
</code></div>
<br>
This syntax allows you to do things like
`func(std::forward<Args>([:]args)...)`. It would even
allow you to call arbitrary expressions on tuple elements, or
allow them to participate in fold expressions. To get the sum
of all elements of a tuple, you do `(0 + ... + [:]args)`.<br>
<br>
That's much more flexible than your "structured binding"-based
stuff here.<br>
</div>
</div>
</blockquote>
<br>
See "
<meta http-equiv=3D"content-type" content=3D"text/html; charset=3Dutf-8=
">
parameter packs outside of templates" -
<a class=3D"moz-txt-link-freetext" href=3D"http://www.open-std.org/jtc1=
/sc22/wg21/docs/papers/2016/p0341r0.html">http://www.open-std.org/jtc1/sc22=
/wg21/docs/papers/2016/p0341r0.html</a><br>
<br>
<br>
<br>
Vicente<br>
<br>
</body>
</html>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/398c0970-d96f-4ecc-cbe8-c407e8434e67%=
40wanadoo.fr?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/398c0970-d96f-4ecc-cbe8-c407e8434e67=
%40wanadoo.fr</a>.<br />
--------------C8FAF69DDC93811F9323A81A--
.
Author: Matthew Woehlke <mwoehlke.floss@gmail.com>
Date: Fri, 14 Oct 2016 10:52:54 -0400
Raw View
On 2016-10-12 06:51, Richard Thorell wrote:
> After looking at the structured bindings paper I thought, why don't
> we allow the members to be automatically unpacked into it's
> components and forwarded to a method?
>
> Proposal:
> template <class... Args>
> void foo(void(*func)(Args...), std::tuple<Args...> args)
> {
> func(auto{ ... } = args);
> }
>
> Maybe this has already been discussed somewhere?
First, to the folks pointing at std::apply / std::invoke... those can't
call constructors. They are not sufficient.
As for prior art... I've (not yet officially) proposed:
foo([:]tuple_like...);
auto f = Foo([:]tuple_like...);
foo([2:4]tuple_like...);
foo([1:]tuple_like...);
foo([:-2]tuple_like...);
// ...etc.
Note that the above syntax is proposed that `tuple_like` can be either a
concrete, tuple-like type *or* a parameter pack. That is, given a
parameter pack `pp`, the syntax `[:]pp` is a legal no-op.
Note: The output of a non-singular pack indexing operation is a
parameter pack (i.e. `[:]tuple_like` yields a parameter pack).
(A singular pack indexing operation is e.g. `[0]pp`. Note that
`[0]tuple_like` is equivalent to `get<0>(tuple_like)`.)
--
Matthew
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/5800F146.8040302%40gmail.com.
.
Author: "D. B." <db0451@gmail.com>
Date: Fri, 14 Oct 2016 15:57:40 +0100
Raw View
--001a114c01dca1015c053ed472ff
Content-Type: text/plain; charset=UTF-8
On Fri, Oct 14, 2016 at 3:52 PM, Matthew Woehlke <mwoehlke.floss@gmail.com>
wrote:
>
> First, to the folks pointing at std::apply / std::invoke... those can't
> call constructors. They are not sufficient.
>
>
>
That's what std::make_from_tuple is for.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhFirdAQgkgSRcRCVtmkQ%2B-TekL%2B1PNYGOzzSSeqTMxE_g%40mail.gmail.com.
--001a114c01dca1015c053ed472ff
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Fri, Oct 14, 2016 at 3:52 PM, Matthew Woehlke <span dir=3D"ltr"><=
<a href=3D"mailto:mwoehlke.floss@gmail.com" target=3D"_blank">mwoehlke.flos=
s@gmail.com</a>></span> wrote:<br><blockquote class=3D"gmail_quote" styl=
e=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span c=
lass=3D""><br>
</span>First, to the folks pointing at std::apply / std::invoke... those ca=
n't<br>
call constructors. They are not sufficient.<br>
<br><br></blockquote><div><br></div><div>That's what std::make_from_tup=
le is for. <br></div></div><br></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CACGiwhFirdAQgkgSRcRCVtmkQ%2B-TekL%2B=
1PNYGOzzSSeqTMxE_g%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CACGiwhFirdAQ=
gkgSRcRCVtmkQ%2B-TekL%2B1PNYGOzzSSeqTMxE_g%40mail.gmail.com</a>.<br />
--001a114c01dca1015c053ed472ff--
.
Author: Matthew Woehlke <mwoehlke.floss@gmail.com>
Date: Fri, 14 Oct 2016 11:09:12 -0400
Raw View
On 2016-10-14 10:57, D. B. wrote:
> On Fri, Oct 14, 2016 at 3:52 PM, Matthew Woehlke wrote:
>> First, to the folks pointing at std::apply / std::invoke... those can't
>> call constructors. They are not sufficient.
>
> That's what std::make_from_tuple is for.
Please show the library equivalent of this:
auto x = Foo{[:]t1..., [-1]t2, [0]t2, [2:-1]t2..., v};
A language feature is easy to use and works in every context without
having to remember several library functions.
You can *probably* do the above using only only library features (though
start throwing in references, and things likely get more interesting),
but it's going to be *hugely* more typing and will involve temporaries
(that the compiler may or may not be able to optimize away).
--
Matthew
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/ntqsem%24p33%241%40blaine.gmane.org.
.
Author: Richard Thorell <richard.thorell@king.com>
Date: Fri, 14 Oct 2016 08:16:25 -0700 (PDT)
Raw View
------=_Part_1098_1855575954.1476458185875
Content-Type: multipart/alternative;
boundary="----=_Part_1099_966565300.1476458185875"
------=_Part_1099_966565300.1476458185875
Content-Type: text/plain; charset=UTF-8
Hi Matthew,
I do like your suggestion a lot. Solves the problem I wanted and with
better functionality.
Cheers,
Richard
On Friday, October 14, 2016 at 4:09:51 PM UTC+1, Matthew Woehlke wrote:
>
> On 2016-10-14 10:57, D. B. wrote:
> > On Fri, Oct 14, 2016 at 3:52 PM, Matthew Woehlke wrote:
> >> First, to the folks pointing at std::apply / std::invoke... those can't
> >> call constructors. They are not sufficient.
> >
> > That's what std::make_from_tuple is for.
>
> Please show the library equivalent of this:
>
> auto x = Foo{[:]t1..., [-1]t2, [0]t2, [2:-1]t2..., v};
>
> A language feature is easy to use and works in every context without
> having to remember several library functions.
>
> You can *probably* do the above using only only library features (though
> start throwing in references, and things likely get more interesting),
> but it's going to be *hugely* more typing and will involve temporaries
> (that the compiler may or may not be able to optimize away).
>
> --
> Matthew
>
>
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/1b90d6b2-aa10-4da3-bcf6-2e44c2a38bff%40isocpp.org.
------=_Part_1099_966565300.1476458185875
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Hi Matthew,<div><br></div><div>I do like your suggestion a=
lot. Solves the problem I wanted and with better functionality.</div><div>=
<br></div><div>Cheers,</div><div>Richard<br><br>On Friday, October 14, 2016=
at 4:09:51 PM UTC+1, Matthew Woehlke wrote:<blockquote class=3D"gmail_quot=
e" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;paddin=
g-left: 1ex;">On 2016-10-14 10:57, D. B. wrote:
<br>> On Fri, Oct 14, 2016 at 3:52 PM, Matthew Woehlke wrote:
<br>>> First, to the folks pointing at std::apply / std::invoke... th=
ose can't
<br>>> call constructors. They are not sufficient.
<br>>
<br>> That's what std::make_from_tuple is for.
<br>
<br>Please show the library equivalent of this:
<br>
<br>=C2=A0 auto x =3D Foo{[:]t1..., [-1]t2, [0]t2, [2:-1]t2..., v};
<br>
<br>A language feature is easy to use and works in every context without
<br>having to remember several library functions.
<br>
<br>You can *probably* do the above using only only library features (thoug=
h
<br>start throwing in references, and things likely get more interesting),
<br>but it's going to be *hugely* more typing and will involve temporar=
ies
<br>(that the compiler may or may not be able to optimize away).
<br>
<br>--=20
<br>Matthew
<br>
<br></blockquote></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/1b90d6b2-aa10-4da3-bcf6-2e44c2a38bff%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/1b90d6b2-aa10-4da3-bcf6-2e44c2a38bff=
%40isocpp.org</a>.<br />
------=_Part_1099_966565300.1476458185875--
------=_Part_1098_1855575954.1476458185875--
.
Author: Matthew Woehlke <mwoehlke.floss@gmail.com>
Date: Fri, 14 Oct 2016 11:24:43 -0400
Raw View
On 2016-10-14 11:09, Matthew Woehlke wrote:
> On 2016-10-14 10:57, D. B. wrote:
>> On Fri, Oct 14, 2016 at 3:52 PM, Matthew Woehlke wrote:
>>> First, to the folks pointing at std::apply / std::invoke... those can't
>>> call constructors. They are not sufficient.
>>
>> That's what std::make_from_tuple is for.
>=20
> Please show the library equivalent of this:
>=20
> auto x =3D Foo{[:]t1..., [-1]t2, [0]t2, [2:-1]t2..., v};
....not to mention:
// let 'vec' be equivalent to an array of T
auto dot =3D T{1} * [:]vec...;
auto manhattan_distance =3D T{0} + std::abs([:]vec)...;
Being able to turn a tuple-like=C2=B9 into a parameter pack is MUCH more
useful than having to keep creating one-off library functions to do the
same thing.
(=C2=B9 ...or product type, or aggregate, or whatever becomes the "blessed"=
term)
--=20
Matthew
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/5800F8BB.9080307%40gmail.com.
.
Author: "Arthur O'Dwyer" <arthur.j.odwyer@gmail.com>
Date: Fri, 14 Oct 2016 11:36:03 -0700
Raw View
--047d7b873a2ca5d436053ed77fdf
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Fri, Oct 14, 2016 at 8:24 AM, Matthew Woehlke <mwoehlke.floss@gmail.com>
wrote:
> On 2016-10-14 11:09, Matthew Woehlke wrote:
> > On 2016-10-14 10:57, D. B. wrote:
> >> On Fri, Oct 14, 2016 at 3:52 PM, Matthew Woehlke wrote:
> >>> First, to the folks pointing at std::apply / std::invoke... those can=
't
> >>> call constructors. They are not sufficient.
> >>
> >> That's what std::make_from_tuple is for.
> >
> > Please show the library equivalent of this:
> >
> > auto x =3D Foo{[:]t1..., [-1]t2, [0]t2, [2:-1]t2..., v};
>
> ...not to mention:
>
> // let 'vec' be equivalent to an array of T
> auto dot =3D T{1} * [:]vec...;
> auto manhattan_distance =3D T{0} + std::abs([:]vec)...;
>
> Being able to turn a tuple-like=C2=B9 into a parameter pack is MUCH more
> useful than having to keep creating one-off library functions to do the
> same thing.
>
Agreed, but there are fundamental semantic problems that you'd need to
overcome before anything like this could get into the language. So while
it looks really nifty, I would strongly discourage anyone from saying "Oh,
we should JUST standardize something like this and then we don't need (some
other achievable library feature) anymore." There's no such thing as JUST
standardizing Matthew's syntax as currently proposed.
See my previous posts in this group
https://groups.google.com/a/isocpp.org/d/msg/std-proposals/ajLcDl8GbpA/TygO=
gRe4AwAJ
(on blowing up packs of packs)
https://groups.google.com/a/isocpp.org/d/msg/std-proposals/ajLcDl8GbpA/d-RE=
DXv2BwAJ
(on blowing up packs of packs)
https://groups.google.com/a/isocpp.org/d/msg/std-proposals/KW2FcaRAasc/Go39=
E_4bGAAJ
(on syntactic ambiguity)
and the following example code.
int main() {
std::tuple<int> t1 { 1, 2, 3 };
std::tuple<int,int> t2 { 4, 5, 6 };
std::tuple<int,int,int> t3 { 7, 8, 9 };
auto tt =3D std::make_tuple(t1, t2, t3); // a tuple of tuples
f([:]tt ...); // f(t1, t2, t3);
f(g([:]tt) ...); // f(g(t1), g(t2), g(t3));
f(g([:]tt ...)); // f(g(t1, t2, t3));
f(g([:][:]tt ...) ...); // f(g(1,2,3), g(4,5,6), g(7,8,9)); ???
f(g([:][:]tt ... ...)); // f(g(1, 2, 3, 4, 5, 6, 7, 8, 9)); ???
???; // f(g(1,4,7), g(2,5,8), g(3,6,9)); ???
???; // f(g(1, 4, 7, 2, 5, 8, 3, 6, 9)); ???
}
=E2=80=93Arthur
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/CADvuK0LfTY4GkSpD8%2Bhyb8G7k_yhB3qtX1ENYm%2BVYGV=
fNThcrw%40mail.gmail.com.
--047d7b873a2ca5d436053ed77fdf
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Fri, Oct 14, 2016 at 8:24 AM, Matthew Woehlke <span dir=
=3D"ltr"><<a href=3D"mailto:mwoehlke.floss@gmail.com" target=3D"_blank">=
mwoehlke.floss@gmail.com</a>></span> wrote:<br><div class=3D"gmail_extra=
"><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"mar=
gin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,2=
04);border-left-style:solid;padding-left:1ex"><span class=3D"gmail-">On 201=
6-10-14 11:09, Matthew Woehlke wrote:<br>
> On 2016-10-14 10:57, D. B. wrote:<br>
>> On Fri, Oct 14, 2016 at 3:52 PM, Matthew Woehlke wrote:<br>
>>> First, to the folks pointing at std::apply / std::invoke... th=
ose can't<br>
>>> call constructors. They are not sufficient.<br>
>><br>
>> That's what std::make_from_tuple is for.<br>
><br>
> Please show the library equivalent of this:<br>
><br>
>=C2=A0 =C2=A0auto x =3D Foo{[:]t1..., [-1]t2, [0]t2, [2:-1]t2..., v};<b=
r>
<br>
</span>...not to mention:<br>
<br>
=C2=A0 // let 'vec' be equivalent to an array of T<br>
=C2=A0 auto dot =3D T{1} * [:]vec...;<br>
=C2=A0 auto manhattan_distance =3D T{0} + std::abs([:]vec)...;<br>
<br>
Being able to turn a tuple-like=C2=B9 into a parameter pack is MUCH more<br=
>
useful than having to keep creating one-off library functions to do the<br>
same thing.<br></blockquote><div><br></div><div>Agreed, but there are funda=
mental semantic problems that you'd need to overcome before anything li=
ke this could get into the language.=C2=A0 So while it looks really nifty, =
I would strongly discourage anyone from saying "Oh, we should JUST sta=
ndardize something like this and then we don't need (some other achieva=
ble library feature) anymore." =C2=A0There's no such thing as JUST=
standardizing Matthew's syntax as currently proposed.</div><div><br></=
div><div>See my previous posts in this group</div><div><a href=3D"https://g=
roups.google.com/a/isocpp.org/d/msg/std-proposals/ajLcDl8GbpA/TygOgRe4AwAJ"=
>https://groups.google.com/a/isocpp.org/d/msg/std-proposals/ajLcDl8GbpA/Tyg=
OgRe4AwAJ</a> (on blowing up packs of packs)<br></div><div><a href=3D"https=
://groups.google.com/a/isocpp.org/d/msg/std-proposals/ajLcDl8GbpA/d-REDXv2B=
wAJ">https://groups.google.com/a/isocpp.org/d/msg/std-proposals/ajLcDl8GbpA=
/d-REDXv2BwAJ</a> (on blowing up packs of packs)<br></div><div><div><a href=
=3D"https://groups.google.com/a/isocpp.org/d/msg/std-proposals/KW2FcaRAasc/=
Go39E_4bGAAJ">https://groups.google.com/a/isocpp.org/d/msg/std-proposals/KW=
2FcaRAasc/Go39E_4bGAAJ</a> (on syntactic ambiguity)<br></div></div><div>and=
the following example code.</div><div><br></div><div style=3D"margin:0px;p=
adding:0px;border:0px;font-family:arial,helvetica,sans-serif;font-size:13px=
">int main() {</div><div style=3D"font-size:13px;margin:0px;padding:0px;bor=
der:0px;font-family:arial,helvetica,sans-serif">=C2=A0 =C2=A0 std::tuple<=
;int> t1 { 1, 2, 3 };</div><div style=3D"font-size:13px;margin:0px;paddi=
ng:0px;border:0px;font-family:arial,helvetica,sans-serif">=C2=A0 =C2=A0 std=
::tuple<int,int> t2 { 4, 5, 6 };</div><div style=3D"font-size:13px;ma=
rgin:0px;padding:0px;border:0px;font-family:arial,helvetica,sans-serif">=C2=
=A0 =C2=A0 std::tuple<int,int,int> t3 { 7, 8, 9 };</div><div style=3D=
"font-size:13px;margin:0px;padding:0px;border:0px;font-family:arial,helveti=
ca,sans-serif">=C2=A0 =C2=A0 auto tt =3D std::make_tuple(t1, t2, t3); =C2=
=A0// a tuple of tuples</div><div style=3D"font-size:13px;margin:0px;paddin=
g:0px;border:0px;font-family:arial,helvetica,sans-serif"><br></div><div sty=
le=3D"font-size:13px;margin:0px;padding:0px;border:0px;font-family:arial,he=
lvetica,sans-serif">=C2=A0 =C2=A0 f([:]tt ...); =C2=A0 // f(t1, t2, t3);</d=
iv><div style=3D"font-size:13px;margin:0px;padding:0px;border:0px;font-fami=
ly:arial,helvetica,sans-serif">=C2=A0 =C2=A0 f(g([:]tt) ...); =C2=A0// f(g(=
t1), g(t2), g(t3));</div><div style=3D"font-size:13px;margin:0px;padding:0p=
x;border:0px;font-family:arial,helvetica,sans-serif">=C2=A0 =C2=A0 f(g([:]t=
t ...)); =C2=A0// f(g(t1, t2, t3));</div><div style=3D"font-size:13px;margi=
n:0px;padding:0px;border:0px;font-family:arial,helvetica,sans-serif">=C2=A0=
=C2=A0 f(g([:][:]tt ...) ...); =C2=A0// f(g(1,2,3), g(4,5,6), g(7,8,9)); =
=C2=A0???</div><div style=3D"font-size:13px;margin:0px;padding:0px;border:0=
px;font-family:arial,helvetica,sans-serif">=C2=A0 =C2=A0 f(g([:][:]tt ... .=
...)); =C2=A0// f(g(1, 2, 3, 4, 5, 6, 7, 8, 9)); =C2=A0???</div><div style=
=3D"font-size:13px;margin:0px;padding:0px;border:0px;font-family:arial,helv=
etica,sans-serif">=C2=A0 =C2=A0 ???; =C2=A0// f(g(1,4,7), g(2,5,8), g(3,6,9=
)); ???</div><div style=3D"font-size:13px;margin:0px;padding:0px;border:0px=
;font-family:arial,helvetica,sans-serif">=C2=A0 =C2=A0 ???; =C2=A0// f(g(1,=
4, 7, 2, 5, 8, 3, 6, 9)); =C2=A0???</div><div style=3D"font-size:13px;marg=
in:0px;padding:0px;border:0px;font-family:arial,helvetica,sans-serif">}<br>=
</div><div><br></div><div>=E2=80=93Arthur</div></div></div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CADvuK0LfTY4GkSpD8%2Bhyb8G7k_yhB3qtX1=
ENYm%2BVYGVfNThcrw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter"=
>https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CADvuK0LfTY4G=
kSpD8%2Bhyb8G7k_yhB3qtX1ENYm%2BVYGVfNThcrw%40mail.gmail.com</a>.<br />
--047d7b873a2ca5d436053ed77fdf--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Fri, 14 Oct 2016 12:48:55 -0700 (PDT)
Raw View
------=_Part_1139_894129589.1476474535309
Content-Type: multipart/alternative;
boundary="----=_Part_1140_1604778734.1476474535310"
------=_Part_1140_1604778734.1476474535310
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Friday, October 14, 2016 at 2:36:06 PM UTC-4, Arthur O'Dwyer wrote:
>
> On Fri, Oct 14, 2016 at 8:24 AM, Matthew Woehlke <mwoehlk...@gmail.com=20
> <javascript:>> wrote:
>
>> On 2016-10-14 11:09, Matthew Woehlke wrote:
>> > On 2016-10-14 10:57, D. B. wrote:
>> >> On Fri, Oct 14, 2016 at 3:52 PM, Matthew Woehlke wrote:
>> >>> First, to the folks pointing at std::apply / std::invoke... those=20
>> can't
>> >>> call constructors. They are not sufficient.
>> >>
>> >> That's what std::make_from_tuple is for.
>> >
>> > Please show the library equivalent of this:
>> >
>> > auto x =3D Foo{[:]t1..., [-1]t2, [0]t2, [2:-1]t2..., v};
>>
>> ...not to mention:
>>
>> // let 'vec' be equivalent to an array of T
>> auto dot =3D T{1} * [:]vec...;
>> auto manhattan_distance =3D T{0} + std::abs([:]vec)...;
>>
>> Being able to turn a tuple-like=C2=B9 into a parameter pack is MUCH more
>> useful than having to keep creating one-off library functions to do the
>> same thing.
>>
>
> Agreed, but there are fundamental semantic problems that you'd need to=20
> overcome before anything like this could get into the language. So while=
=20
> it looks really nifty, I would strongly discourage anyone from saying "Oh=
,=20
> we should JUST standardize something like this and then we don't need (so=
me=20
> other achievable library feature) anymore."
>
The point of the feature is not to say we don't need standard library=20
tools. The point of the feature is that we don't need nearly so many of=20
them, and even then, the implementations of them become a lot more=20
reasonable.
=20
> There's no such thing as JUST standardizing Matthew's syntax as currentl=
y=20
> proposed.
>
> See my previous posts in this group
>
> https://groups.google.com/a/isocpp.org/d/msg/std-proposals/ajLcDl8GbpA/Ty=
gOgRe4AwAJ=20
> (on blowing up packs of packs)
>
> https://groups.google.com/a/isocpp.org/d/msg/std-proposals/ajLcDl8GbpA/d-=
REDXv2BwAJ=20
> (on blowing up packs of packs)
>
> https://groups.google.com/a/isocpp.org/d/msg/std-proposals/KW2FcaRAasc/Go=
39E_4bGAAJ=20
> (on syntactic ambiguity)
> and the following example code.
>
> int main() {
> std::tuple<int> t1 { 1, 2, 3 };
> std::tuple<int,int> t2 { 4, 5, 6 };
> std::tuple<int,int,int> t3 { 7, 8, 9 };
> auto tt =3D std::make_tuple(t1, t2, t3); // a tuple of tuples
>
> f([:]tt ...); // f(t1, t2, t3);
> f(g([:]tt) ...); // f(g(t1), g(t2), g(t3));
> f(g([:]tt ...)); // f(g(t1, t2, t3));
> f(g([:][:]tt ...) ...); // f(g(1,2,3), g(4,5,6), g(7,8,9)); ???
> f(g([:][:]tt ... ...)); // f(g(1, 2, 3, 4, 5, 6, 7, 8, 9)); ???
> ???; // f(g(1,4,7), g(2,5,8), g(3,6,9)); ???
> ???; // f(g(1, 4, 7, 2, 5, 8, 3, 6, 9)); ???
> }
>
I don't think this is too difficult of a problem to work out.
The tuple-to-pack operator should attach before the ... operator.=20
Therefore, `[:][:]tt...` means "convert tuple to pack, then convert tuple=
=20
to pack, then unpack". However, since a pack is *not a tuple*, the second=
=20
application should be il-formed.
Your issue is essentially, how do I get the system to produce the given=20
effects? Well, the answer is this: `[:]` can't do everything for you. What=
=20
it does do is make the resulting code decidedly less verbose than it could=
=20
have been:
*f(g(1,2,3), g(4,5,6), g(7,8,9));*
You have to use helper function:
f(std::apply(g, [:]tt)...);
Not as neat as being pure. But try to image doing it without the `[:]`, and=
=20
you'll see why it is so much better.
It also allows things like `std::apply(g, [:]tt) + ... + 0` and similar=20
trickery.
*f(g(1, 2, 3, 4, 5, 6, 7, 8, 9));*
You're talking about flattening a tuple of tuples. Obviously, parameter=20
pack syntax doesn't provide for such a thing.
Like this above, this requires a utility function that can concatenate=20
tuple-like types into a tuple. With that, it's pretty easy:
f(g([:]std::flatten_tuples([:]tt...)...));
A little verbose, but flattening tuples-of-tuples isn't something you need=
=20
to do every day.
*f(g(1,4,7), g(2,5,8), g(3,6,9));*
This is doable with a utility function that acts on tuples, much like a zip=
=20
iterator/range. It turns a sequence of tuple-like types of the same size=20
into an array of tuples of the corresponding elements:
f(std::apply(g, [:]std::zip_tuples([:]tt...))...);
Nobody ever said that `[:]` syntax was the beginning and the end of tuple=
=20
handling and unpacking. We will certainly need utility functions to cover=
=20
specialized cases. And the above code can be quite complex to read. But=20
this is mainly due to the complexity of the cases themselves.
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/9eb999a1-2cd7-439d-b812-6e0f3e6ed131%40isocpp.or=
g.
------=_Part_1140_1604778734.1476474535310
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Friday, October 14, 2016 at 2:36:06 PM UTC-4, Arthur O&=
#39;Dwyer wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin=
-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"lt=
r">On Fri, Oct 14, 2016 at 8:24 AM, Matthew Woehlke <span dir=3D"ltr"><<=
a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"9V_n3gwOA=
gAJ" rel=3D"nofollow" onmousedown=3D"this.href=3D'javascript:';retu=
rn true;" onclick=3D"this.href=3D'javascript:';return true;">mwoehl=
k...@gmail.com</a>></span> wrote:<br><div><div class=3D"gmail_quote"><bl=
ockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-lef=
t-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padd=
ing-left:1ex"><span>On 2016-10-14 11:09, Matthew Woehlke wrote:<br>
> On 2016-10-14 10:57, D. B. wrote:<br>
>> On Fri, Oct 14, 2016 at 3:52 PM, Matthew Woehlke wrote:<br>
>>> First, to the folks pointing at std::apply / std::invoke... th=
ose can't<br>
>>> call constructors. They are not sufficient.<br>
>><br>
>> That's what std::make_from_tuple is for.<br>
><br>
> Please show the library equivalent of this:<br>
><br>
>=C2=A0 =C2=A0auto x =3D Foo{[:]t1..., [-1]t2, [0]t2, [2:-1]t2..., v};<b=
r>
<br>
</span>...not to mention:<br>
<br>
=C2=A0 // let 'vec' be equivalent to an array of T<br>
=C2=A0 auto dot =3D T{1} * [:]vec...;<br>
=C2=A0 auto manhattan_distance =3D T{0} + std::abs([:]vec)...;<br>
<br>
Being able to turn a tuple-like=C2=B9 into a parameter pack is MUCH more<br=
>
useful than having to keep creating one-off library functions to do the<br>
same thing.<br></blockquote><div><br></div><div>Agreed, but there are funda=
mental semantic problems that you'd need to overcome before anything li=
ke this could get into the language.=C2=A0 So while it looks really nifty, =
I would strongly discourage anyone from saying "Oh, we should JUST sta=
ndardize something like this and then we don't need (some other achieva=
ble library feature) anymore."</div></div></div></div></blockquote><di=
v><br>The point of the feature is not to say we don't need standard lib=
rary tools. The point of the feature is that we don't need nearly so ma=
ny of them, and even then, the implementations of them become a lot more re=
asonable.<br>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:=
0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div =
dir=3D"ltr"><div><div class=3D"gmail_quote"><div> =C2=A0There's no such=
thing as JUST standardizing Matthew's syntax as currently proposed.</d=
iv><div><br></div><div>See my previous posts in this group</div><div><a hre=
f=3D"https://groups.google.com/a/isocpp.org/d/msg/std-proposals/ajLcDl8GbpA=
/TygOgRe4AwAJ" target=3D"_blank" rel=3D"nofollow" onmousedown=3D"this.href=
=3D'https://groups.google.com/a/isocpp.org/d/msg/std-proposals/ajLcDl8G=
bpA/TygOgRe4AwAJ';return true;" onclick=3D"this.href=3D'https://gro=
ups.google.com/a/isocpp.org/d/msg/std-proposals/ajLcDl8GbpA/TygOgRe4AwAJ=
9;;return true;">https://groups.google.com/a/<wbr>isocpp.org/d/msg/std-<wbr=
>proposals/ajLcDl8GbpA/<wbr>TygOgRe4AwAJ</a> (on blowing up packs of packs)=
<br></div><div><a href=3D"https://groups.google.com/a/isocpp.org/d/msg/std-=
proposals/ajLcDl8GbpA/d-REDXv2BwAJ" target=3D"_blank" rel=3D"nofollow" onmo=
usedown=3D"this.href=3D'https://groups.google.com/a/isocpp.org/d/msg/st=
d-proposals/ajLcDl8GbpA/d-REDXv2BwAJ';return true;" onclick=3D"this.hre=
f=3D'https://groups.google.com/a/isocpp.org/d/msg/std-proposals/ajLcDl8=
GbpA/d-REDXv2BwAJ';return true;">https://groups.google.com/a/<wbr>isocp=
p.org/d/msg/std-<wbr>proposals/ajLcDl8GbpA/d-<wbr>REDXv2BwAJ</a> (on blowin=
g up packs of packs)<br></div><div><div><a href=3D"https://groups.google.co=
m/a/isocpp.org/d/msg/std-proposals/KW2FcaRAasc/Go39E_4bGAAJ" target=3D"_bla=
nk" rel=3D"nofollow" onmousedown=3D"this.href=3D'https://groups.google.=
com/a/isocpp.org/d/msg/std-proposals/KW2FcaRAasc/Go39E_4bGAAJ';return t=
rue;" onclick=3D"this.href=3D'https://groups.google.com/a/isocpp.org/d/=
msg/std-proposals/KW2FcaRAasc/Go39E_4bGAAJ';return true;">https://group=
s.google.com/a/<wbr>isocpp.org/d/msg/std-<wbr>proposals/KW2FcaRAasc/Go39E_<=
wbr>4bGAAJ</a> (on syntactic ambiguity)<br></div></div><div>and the followi=
ng example code.</div><div><br></div><div style=3D"margin:0px;padding:0px;b=
order:0px;font-family:arial,helvetica,sans-serif;font-size:13px">int main()=
{</div><div style=3D"font-size:13px;margin:0px;padding:0px;border:0px;font=
-family:arial,helvetica,sans-serif">=C2=A0 =C2=A0 std::tuple<int> t1 =
{ 1, 2, 3 };</div><div style=3D"font-size:13px;margin:0px;padding:0px;borde=
r:0px;font-family:arial,helvetica,sans-serif">=C2=A0 =C2=A0 std::tuple<i=
nt,int> t2 { 4, 5, 6 };</div><div style=3D"font-size:13px;margin:0px;pad=
ding:0px;border:0px;font-family:arial,helvetica,sans-serif">=C2=A0 =C2=A0 s=
td::tuple<int,int,int> t3 { 7, 8, 9 };</div><div style=3D"font-size:1=
3px;margin:0px;padding:0px;border:0px;font-family:arial,helvetica,sans-seri=
f">=C2=A0 =C2=A0 auto tt =3D std::make_tuple(t1, t2, t3); =C2=A0// a tuple =
of tuples</div><div style=3D"font-size:13px;margin:0px;padding:0px;border:0=
px;font-family:arial,helvetica,sans-serif"><br></div><div style=3D"font-siz=
e:13px;margin:0px;padding:0px;border:0px;font-family:arial,helvetica,sans-s=
erif">=C2=A0 =C2=A0 f([:]tt ...); =C2=A0 // f(t1, t2, t3);</div><div style=
=3D"font-size:13px;margin:0px;padding:0px;border:0px;font-family:arial,helv=
etica,sans-serif">=C2=A0 =C2=A0 f(g([:]tt) ...); =C2=A0// f(g(t1), g(t2), g=
(t3));</div><div style=3D"font-size:13px;margin:0px;padding:0px;border:0px;=
font-family:arial,helvetica,sans-serif">=C2=A0 =C2=A0 f(g([:]tt ...)); =C2=
=A0// f(g(t1, t2, t3));</div><div style=3D"font-size:13px;margin:0px;paddin=
g:0px;border:0px;font-family:arial,helvetica,sans-serif">=C2=A0 =C2=A0 f(g(=
[:][:]tt ...) ...); =C2=A0// f(g(1,2,3), g(4,5,6), g(7,8,9)); =C2=A0???</di=
v><div style=3D"font-size:13px;margin:0px;padding:0px;border:0px;font-famil=
y:arial,helvetica,sans-serif">=C2=A0 =C2=A0 f(g([:][:]tt ... ...)); =C2=A0/=
/ f(g(1, 2, 3, 4, 5, 6, 7, 8, 9)); =C2=A0???</div><div style=3D"font-size:1=
3px;margin:0px;padding:0px;border:0px;font-family:arial,helvetica,sans-seri=
f">=C2=A0 =C2=A0 ???; =C2=A0// f(g(1,4,7), g(2,5,8), g(3,6,9)); ???</div><d=
iv style=3D"font-size:13px;margin:0px;padding:0px;border:0px;font-family:ar=
ial,helvetica,sans-serif">=C2=A0 =C2=A0 ???; =C2=A0// f(g(1, 4, 7, 2, 5, 8,=
3, 6, 9)); =C2=A0???</div><div style=3D"font-size:13px;margin:0px;padding:=
0px;border:0px;font-family:arial,helvetica,sans-serif">}<br></div></div></d=
iv></div></blockquote><div><br>I don't think this is too difficult of a=
problem to work out.<br><br>The tuple-to-pack operator should attach befor=
e the ... operator. Therefore, `[:][:]tt...` means "convert tuple to p=
ack, then convert tuple to pack, then unpack". However, since a pack i=
s <i>not a tuple</i>, the second application should be il-formed.<br><br>Yo=
ur issue is essentially, how do I get the system to produce the given effec=
ts? Well, the answer is this: `[:]` can't do everything for you. What i=
t does do is make the resulting code decidedly less verbose than it could h=
ave been:<br><br><div style=3D"background-color: rgb(250, 250, 250); border=
-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; overflo=
w-wrap: break-word;" class=3D"prettyprint"><b><code class=3D"prettyprint"><=
div class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-b=
y-prettify">f</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">g</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span s=
tyle=3D"color: #066;" class=3D"styled-by-prettify">1</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #06=
6;" class=3D"styled-by-prettify">2</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">,</span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">3</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">),</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> g=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><s=
pan style=3D"color: #066;" class=3D"styled-by-prettify">4</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color=
: #066;" class=3D"styled-by-prettify">5</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">,</span><span style=3D"color: #066;" class=3D"=
styled-by-prettify">6</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">),</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> g</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</sp=
an><span style=3D"color: #066;" class=3D"styled-by-prettify">7</span><span =
style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"=
color: #066;" class=3D"styled-by-prettify">8</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">,</span><span style=3D"color: #066;" clas=
s=3D"styled-by-prettify">9</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">));</span></div></code></b></div><br>You have to use helper=
function:<br><br><div style=3D"background-color: rgb(250, 250, 250); borde=
r-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; overfl=
ow-wrap: break-word;" class=3D"prettyprint"><code class=3D"prettyprint"><di=
v class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-=
prettify">f</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">std</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">apply</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">g</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">[:]</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy">tt</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)...=
);</span></div></code></div><br>Not as neat as being pure. But try to image=
doing it without the `[:]`, and you'll see why it is so much better.<b=
r><br>It also allows things like `std::apply(g, [:]tt) + ... + 0` and simil=
ar trickery.<br><br><div style=3D"background-color: rgb(250, 250, 250); bor=
der-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; over=
flow-wrap: break-word;" class=3D"prettyprint"><b><code class=3D"prettyprint=
"><div class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"style=
d-by-prettify">f</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">g</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><spa=
n style=3D"color: #066;" class=3D"styled-by-prettify">1</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" =
class=3D"styled-by-prettify">2</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify=
">3</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #066;" class=3D"styled-by-prettify">4</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=
=3D"styled-by-prettify">5</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">6</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">7</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"=
styled-by-prettify">8</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> </span><span style=3D"color: #066;" class=3D"styled-by-prettify">9</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">));</span></div>=
</code></b></div><br>You're talking about flattening a tuple of tuples.=
Obviously, parameter pack syntax doesn't provide for such a thing.<br>=
<br>Like this above, this requires a utility function that can concatenate =
tuple-like types into a tuple. With that, it's pretty easy:<br><br><div=
style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187,=
187); border-style: solid; border-width: 1px; overflow-wrap: break-word;" =
class=3D"prettyprint"><code class=3D"prettyprint"><div class=3D"subprettypr=
int"><span style=3D"color: #000;" class=3D"styled-by-prettify">f</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">g</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">([:]</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">std</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">::</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">flatten_tuples</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">([:]</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">tt</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">...)...));</span></div></code></div><br>A little verbose, but flatte=
ning tuples-of-tuples isn't something you need to do every day.<br><br>=
<div style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, =
187, 187); border-style: solid; border-width: 1px; overflow-wrap: break-wor=
d;" class=3D"prettyprint"><b><code class=3D"prettyprint"><div class=3D"subp=
rettyprint"><span style=3D"color: #000;" class=3D"styled-by-prettify">f</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">g</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #0=
66;" class=3D"styled-by-prettify">1</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #066;" class=3D"styl=
ed-by-prettify">4</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">,</span><span style=3D"color: #066;" class=3D"styled-by-prettify">7<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">),</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> g</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #066;" class=3D"styled-by-prettify">2</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">,</span><span style=3D"color: #066;" class=3D=
"styled-by-prettify">5</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">,</span><span style=3D"color: #066;" class=3D"styled-by-prettif=
y">8</span><span style=3D"color: #660;" class=3D"styled-by-prettify">),</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> g</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D=
"color: #066;" class=3D"styled-by-prettify">3</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #066;" cla=
ss=3D"styled-by-prettify">6</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">,</span><span style=3D"color: #066;" class=3D"styled-by-pr=
ettify">9</span><span style=3D"color: #660;" class=3D"styled-by-prettify">)=
);</span></div></code></b></div><br>This is doable with a utility function =
that acts on tuples, much like a zip iterator/range. It turns a sequence of=
tuple-like types of the same size into an array of tuples of the correspon=
ding elements:<br><br><div style=3D"background-color: rgb(250, 250, 250); b=
order-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; ov=
erflow-wrap: break-word;" class=3D"prettyprint"><code class=3D"prettyprint"=
><div class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled=
-by-prettify">f</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">std<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">::</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify">apply</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">g</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">[:]</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">std</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>::</span><span style=3D"color: #000;" class=3D"styled-by-prettify">zip_tup=
les</span><span style=3D"color: #660;" class=3D"styled-by-prettify">([:]</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify">tt</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">...))...);</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></co=
de></div><br>Nobody ever said that `[:]` syntax was the beginning and the e=
nd of tuple handling and unpacking. We will certainly need utility function=
s to cover specialized cases. And the above code can be quite complex to re=
ad. But this is mainly due to the complexity of the cases themselves.<br></=
div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/9eb999a1-2cd7-439d-b812-6e0f3e6ed131%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/9eb999a1-2cd7-439d-b812-6e0f3e6ed131=
%40isocpp.org</a>.<br />
------=_Part_1140_1604778734.1476474535310--
------=_Part_1139_894129589.1476474535309--
.
Author: Matthew Woehlke <mwoehlke.floss@gmail.com>
Date: Fri, 14 Oct 2016 17:26:46 -0400
Raw View
On 2016-10-14 15:48, Nicol Bolas wrote:
> On Friday, October 14, 2016 at 2:36:06 PM UTC-4, Arthur O'Dwyer wrote:
>> On Fri, Oct 14, 2016 at 8:24 AM, Matthew Woehlke wrote:
>>> Being able to turn a tuple-like=C2=B9 into a parameter pack is MUCH mor=
e
>>> useful than having to keep creating one-off library functions to do the
>>> same thing.
>>
>> Agreed, but there are fundamental semantic problems that you'd need to=
=20
>> overcome before anything like this could get into the language. So whil=
e=20
>> it looks really nifty, I would strongly discourage anyone from saying "O=
h,=20
>> we should JUST standardize something like this and then we don't need (s=
ome=20
>> other achievable library feature) anymore."
>=20
> The point of the feature is not to say we don't need standard library=20
> tools. The point of the feature is that we don't need nearly so many of=
=20
> them, and even then, the implementations of them become a lot more=20
> reasonable.
Right.
>> There's no such thing as JUST standardizing Matthew's syntax as currentl=
y=20
>> proposed. [Consider] the following example code.
>>
>> std::tuple<int> t1 { 1, 2, 3 };
>> std::tuple<int,int> t2 { 4, 5, 6 };
>> std::tuple<int,int,int> t3 { 7, 8, 9 };
>> auto tt =3D std::make_tuple(t1, t2, t3); // a tuple of tuples
>>
>> f([:]tt ...); // f(t1, t2, t3);
>> f(g([:]tt) ...); // f(g(t1), g(t2), g(t3));
>> f(g([:]tt ...)); // f(g(t1, t2, t3));
>> f(g([:][:]tt ...) ...); // f(g(1,2,3), g(4,5,6), g(7,8,9)); ???
>> f(g([:][:]tt ... ...)); // f(g(1, 2, 3, 4, 5, 6, 7, 8, 9)); ???
>> ???; // f(g(1,4,7), g(2,5,8), g(3,6,9)); ???
>> ???; // f(g(1, 4, 7, 2, 5, 8, 3, 6, 9)); ???
>=20
> I don't think this is too difficult of a problem to work out.
>=20
> The tuple-to-pack operator should attach before the ... operator.=20
> Therefore, `[:][:]tt...` means "convert tuple to pack, then convert tuple=
=20
> to pack, then unpack".
Exactly. In the paper I am working on, I explicitly give prefix `[]`
higher precedence than postfix `...`, so both the 'what do these mean'
examples above are ill-formed. However...
> However, since a pack is *not a tuple*, the second application
> should be ill-formed.
I *also* specify slicing as working on *either* parameter packs or
product types. So the first application converts the tuple to a pack,
the second does nothing, and then you have `pack......`, which is
ill-formed because the second `...` is no longer being applied to a pack.
> *f(g(1,2,3), g(4,5,6), g(7,8,9));*
>=20
> You have to use helper function:
>=20
> f(std::apply(g, [:]tt)...);
>=20
> Not as neat as being pure. But try to image doing it without the `[:]`, a=
nd=20
> you'll see why it is so much better.
Yup, that's about what I came up with.
> *f(g(1, 2, 3, 4, 5, 6, 7, 8, 9));*
>=20
> You're talking about flattening a tuple of tuples. Obviously, parameter=
=20
> pack syntax doesn't provide for such a thing.
Agreed again. In order to make this work with *just* the language
feature, it would be necessary to apply a fold expression on prefix
`[]`. I don't see an obvious and sensible way to specify that.
> Like this above, this requires a utility function that can concatenate=20
> tuple-like types into a tuple. With that, it's pretty easy:
>=20
> f(g([:]std::flatten_tuples([:]tt...)...));
That requires a temporary. It can also be done (without the temporary)
by modifying std::apply to accept a list of tuples rather than just one:
std::apply_helper<int n>(auto func, auto... args)
{
// n is number of already-unpacked arguments
constexpr auto r =3D sizeof...(args) - n; // remaining tuples
if constexpr (r =3D=3D 0)
return func(args...);
auto&& t =3D [n]args;
auto k =3D sizeof...(t);
return apply_helper<n + k>(func, [:n]args, [:]t..., [n+1:]args);
}
std::apply(auto func, auto... tuples)
{
return apply_helper<0>(func, tuples);
}
(I'd be interested to see that implemented *without* my feature... *and*
without creating any temporary tuples.)
> Nobody ever said that `[:]` syntax was the beginning and the end of tuple=
=20
> handling and unpacking. We will certainly need utility functions to cover=
=20
> specialized cases. And the above code can be quite complex to read. But=
=20
> this is mainly due to the complexity of the cases themselves.
Right. I'm not attempting to solve interleaving or reversing; I'd like
to see pack generators for those tasks (but they possibly require pack
indexing, so...).
These don't strike me as problems that need to be solved before the
feature can move forward.
--=20
Matthew
--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/58014D96.5070402%40gmail.com.
.