Topic: [D0428R0] Familiar template syntax for
Author: Simon Brand <simon@codeplay.com>
Date: Thu, 8 Sep 2016 15:56:02 +0100
Raw View
This is a multi-part message in MIME format.
--------------98DAFFA8382163D446B35B06
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable
Another useful application of this extension is the indices trick (I'm=20
sure you're familiar with this from boost::hana, but thought I'd mention=20
it anyway).
If we want to tag dispatch using an index sequence, this usually=20
requires a separate function template, e.g.:
template <typename Tuple, std::size_t... Idx>
void print_tuple(Tuple&& t, std::index_sequence<Idx...>) {
(..., (std::cout << std::get<Idx>(std::forward<Tuple>(t))));
}
template <typename Tuple>
void print_tuple(Tuple&& t) {
constexpr auto size =3D std::tuple_size<std::decay_t<Tuple>>::value;
print_tuple(std::forward<Tuple>(t), std::make_index_sequence<size>{});
}
But with the usual template syntax we can do it all without a helper:
template <typename Tuple>
void print_tuple(Tuple&& t) {
constexpr auto size =3D std::tuple_size<std::decay_t<Tuple>>::value;
[&]<std::size_t... Idx>(std::index_sequence<Idx...>){
(..., (std::cout << std::get<Idx>(std::forward<Tuple>(t))));
}(std::make_index_sequence<size>{});
}
On 08/09/16 14:39, Nicol Bolas wrote:
> On Wednesday, September 7, 2016 at 9:16:26 PM UTC-4, Louis Dionne wrote:
>
> Hi,
>
> I wrote a paper to allow using the familiar template syntax to
> define generic
> lambdas:
>
> []<typename T>(T const& t) { }
> // equivalent to
> [](auto const& t) { }
>
> One of the motivations behind this is that it's often useful to be
> able to
> name the type of a parameter (or a type derived from it) without
> having to
> use `decltype(param)`. Other motivations are explained in more
> details in
> the paper.
>
> I'd like to gather some feedback, so please provide anything
> you've got.
>
>
> In your motivation section, you say you have to do this:
>
> |
> usingT =3Dstd::remove_cv_t<std::remove_reference_t<decltype(x)>>;
> |
>
> The more general way is with:
>
> |
> usingT =3Dstd::decay_t<decltype(x)>;
> |
>
> While this will also decay arrays and turn functions into function=20
> pointers, that is irrelevant for most such use cases (since you can't=20
> pass an array or a function. Well, not like this at any rate).
>
> Further, I dispute that this:
>
> |
> autof =3D[](auto&&...args){
> returnfoo(std::forward<decltype(args)>(args)...);
> };
> |
>
> Is more verbose than this:
>
> |
> autof =3D[]<typename...T>(T&&...args){
> returnfoo(std::forward<T>(args)...);
> };
> |
>
> From what I can tell, you save... one keystroke. And it's not like you=20
> can forward parameters/twice/.
>
> Overall, I'd say that your best motivation is #3, so you should lead=20
> with that.
> --=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/d09ee300-aef=
0-4f1a-9fb5-12bf5b316322%40isocpp.org=20
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/d09ee300-ae=
f0-4f1a-9fb5-12bf5b316322%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/ced30da9-2941-ea74-913c-d535922092ea%40codeplay.=
com.
--------------98DAFFA8382163D446B35B06
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>Another useful application of this extension is the indices trick
(I'm sure you're familiar with this from boost::hana, but thought
I'd mention it anyway).</p>
If we want to tag dispatch using an index sequence, this usually
requires a separate function template, e.g.:<br>
<tt><br>
</tt><tt>template <typename Tuple, std::size_t... Idx><br>
void print_tuple(Tuple&& t,
std::index_sequence<Idx...>) {<br>
=C2=A0=C2=A0=C2=A0 (..., (std::cout <<
std::get<Idx>(std::forward<Tuple>(t))));<br>
}<br>
<br>
template <typename Tuple><br>
void print_tuple(Tuple&& t) {<br>
=C2=A0=C2=A0=C2=A0 constexpr auto size =3D
std::tuple_size<std::decay_t<Tuple>>::value;<br>
=C2=A0=C2=A0=C2=A0 print_tuple(std::forward<Tuple>(t),
std::make_index_sequence<size>{});<br>
}</tt><tt><br>
<br>
</tt>But with the usual template syntax we can do it all without a
helper:<br>
<br>
<tt>template <typename Tuple><br>
void print_tuple(Tuple&& t) {<br>
=C2=A0=C2=A0=C2=A0 constexpr auto size =3D
std::tuple_size<std::decay_t<Tuple>>::value;<br>
=C2=A0=C2=A0=C2=A0 <br>
=C2=A0=C2=A0=C2=A0 [&]<std::size_t...
Idx>(std::index_sequence<Idx...>){<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (..., (std::cout <<
std::get<Idx>(std::forward<Tuple>(t))));<br>
=C2=A0=C2=A0=C2=A0 }(std::make_index_sequence<size>{});<br>
}</tt><tt></tt><tt></tt><br>
<br>
<br>
<div class=3D"moz-cite-prefix">On 08/09/16 14:39, Nicol Bolas wrote:<br=
>
</div>
<blockquote
cite=3D"mid:d09ee300-aef0-4f1a-9fb5-12bf5b316322@isocpp.org"
type=3D"cite">
<div dir=3D"ltr">On Wednesday, September 7, 2016 at 9:16:26 PM
UTC-4, Louis Dionne wrote:
<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
<div dir=3D"ltr">
<div>Hi,</div>
<div><br>
</div>
<div>I wrote a paper to allow using the familiar template
syntax to define generic</div>
<div>lambdas:</div>
<div><br>
</div>
<div>=C2=A0 []<typename T>(T const& t) { }</div>
<div>=C2=A0 // equivalent to</div>
<div>=C2=A0 [](auto const& t) { }</div>
<div><br>
</div>
<div>One of the motivations behind this is that it's often
useful to be able to</div>
<div>name the type of a parameter (or a type derived from
it) without having to</div>
<div>use `decltype(param)`. Other motivations are explained
in more details in</div>
<div>the paper.</div>
<div><br>
</div>
<div>I'd like to gather some feedback, so please provide
anything you've got.</div>
</div>
</blockquote>
<div><br>
In your motivation section, you say you have to do this:<br>
<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">using</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> T </=
span><span
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</=
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">remov=
e_cv_t</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;" class=3D"styled-by-prettify">::</s=
pan><span
style=3D"color: #000;" class=3D"styled-by-prettify">remov=
e_reference_t</span><span
style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><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: #000;" class=3D"styled-by-prettify">x</sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">)>=
>;</span></div>
</code></div>
<br>
The more general way is with:<br>
<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">using</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> T </=
span><span
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</=
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">decay=
_t</span><span
style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><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: #000;" class=3D"styled-by-prettify">x</sp=
an><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>
While this will also decay arrays and turn functions into
function pointers, that is irrelevant for most such use cases
(since you can't pass an array or a function. Well, not like
this at any rate).<br>
<br>
Further, I dispute that this:<br>
<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">auto</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> f </=
span><span
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</=
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">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">...</=
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"> </sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">{</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
=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"> 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">forwa=
rd</span><span
style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><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: #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">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></div>
</code></div>
<br>
Is more verbose than this:<br>
<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">auto</span><span
style=3D"color: #000;" class=3D"styled-by-prettify"> f </=
span><span
style=3D"color: #660;" class=3D"styled-by-prettify">=3D</=
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">typen=
ame</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: #000;" class=3D"styled-by-prettify">T</sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">>(=
</span><span
style=3D"color: #000;" class=3D"styled-by-prettify">T</sp=
an><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">...</=
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"> </sp=
an><span
style=3D"color: #660;" class=3D"styled-by-prettify">{</sp=
an><span
style=3D"color: #000;" class=3D"styled-by-prettify"><br>
=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"> 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">forwa=
rd</span><span
style=3D"color: #660;" class=3D"styled-by-prettify"><<=
/span><span
style=3D"color: #000;" class=3D"styled-by-prettify">T</sp=
an><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></div>
</code></div>
<br>
From what I can tell, you save... one keystroke. And it's not
like you can forward parameters<i> twice</i>.<br>
<br>
Overall, I'd say that your best motivation is #3, so you
should lead with that.<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/d09ee3=
00-aef0-4f1a-9fb5-12bf5b316322%40isocpp.org?utm_medium=3Demail&utm_sour=
ce=3Dfooter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/d=
09ee300-aef0-4f1a-9fb5-12bf5b316322%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/ced30da9-2941-ea74-913c-d535922092ea%=
40codeplay.com?utm_medium=3Demail&utm_source=3Dfooter">https://groups.googl=
e.com/a/isocpp.org/d/msgid/std-proposals/ced30da9-2941-ea74-913c-d535922092=
ea%40codeplay.com</a>.<br />
--------------98DAFFA8382163D446B35B06--
.
Author: Nicol Bolas <jmckesson@gmail.com>
Date: Thu, 8 Sep 2016 09:56:18 -0700 (PDT)
Raw View
------=_Part_2818_1559475559.1473353778673
Content-Type: multipart/alternative;
boundary="----=_Part_2819_1366436365.1473353778674"
------=_Part_2819_1366436365.1473353778674
Content-Type: text/plain; charset=UTF-8
On Thursday, September 8, 2016 at 10:56:06 AM UTC-4, Simon Brand wrote:
>
> Another useful application of this extension is the indices trick (I'm
> sure you're familiar with this from boost::hana, but thought I'd mention it
> anyway).
> If we want to tag dispatch using an index sequence, this usually requires
> a separate function template, e.g.:
>
> template <typename Tuple, std::size_t... Idx>
> void print_tuple(Tuple&& t, std::index_sequence<Idx...>) {
> (..., (std::cout << std::get<Idx>(std::forward<Tuple>(t))));
> }
>
> template <typename Tuple>
> void print_tuple(Tuple&& t) {
> constexpr auto size = std::tuple_size<std::decay_t<Tuple>>::value;
> print_tuple(std::forward<Tuple>(t), std::make_index_sequence<size>{});
> }
>
> But with the usual template syntax we can do it all without a helper:
>
> template <typename Tuple>
> void print_tuple(Tuple&& t) {
> constexpr auto size = std::tuple_size<std::decay_t<Tuple>>::value;
>
> [&]<std::size_t... Idx>(std::index_sequence<Idx...>){
> (..., (std::cout << std::get<Idx>(std::forward<Tuple>(t))));
> }(std::make_index_sequence<size>{});
> }
>
>
That brings up an interesting point.
If we're going to allow the definition of arbitrary template functions
within a function like this, why do we restrict them to being lambdas? That
is, why do we allow generic lambdas but not local structs with template
functions?
When we added lambdas to C++11, we also changed the wording on local
structs to allow them to escape the functions that declared them
(previously, their types could not even be template argument deduced). If
we're going to bless lambdas with arbitrary template powers, lets give
local structs the same abilities.
--
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/db8850c4-a89a-46ec-8d36-829daa0246fe%40isocpp.org.
------=_Part_2819_1366436365.1473353778674
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Thursday, September 8, 2016 at 10:56:06 AM UTC-4, Simon=
Brand wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
=20
=20
=20
<div bgcolor=3D"#FFFFFF" text=3D"#000000">
<p>Another useful application of this extension is the indices trick
(I'm sure you're familiar with this from boost::hana, but tho=
ught
I'd mention it anyway).</p>
If we want to tag dispatch using an index sequence, this usually
requires a separate function template, e.g.:<br>
<tt><br>
</tt><tt>template <typename Tuple, std::size_t... Idx><br>
void print_tuple(Tuple&& t,
std::index_sequence<Idx...>) {<br>
=C2=A0=C2=A0=C2=A0 (..., (std::cout <<
std::get<Idx>(std::forward<<wbr>Tuple>(t))));<br>
}<br>
<br>
template <typename Tuple><br>
void print_tuple(Tuple&& t) {<br>
=C2=A0=C2=A0=C2=A0 constexpr auto size =3D
std::tuple_size<std::decay_t<<wbr>Tuple>>::value;<br>
=C2=A0=C2=A0=C2=A0 print_tuple(std::forward<<wbr>Tuple>(t),
std::make_index_sequence<size><wbr>{});<br>
}</tt><tt><br>
<br>
</tt>But with the usual template syntax we can do it all without a
helper:<br>
<br>
<tt>template <typename Tuple><br>
void print_tuple(Tuple&& t) {<br>
=C2=A0=C2=A0=C2=A0 constexpr auto size =3D
std::tuple_size<std::decay_t<<wbr>Tuple>>::value;<br>
=C2=A0=C2=A0=C2=A0 <br>
=C2=A0=C2=A0=C2=A0 [&]<std::size_t...
Idx>(std::index_sequence<Idx..<wbr>.>){<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (..., (std::cout <<
std::get<Idx>(std::forward<<wbr>Tuple>(t))));<br>
=C2=A0=C2=A0=C2=A0 }(std::make_index_sequence<<wbr>size>{});<br=
>
}</tt><tt></tt><tt></tt><br>
<br></div></blockquote><div><br>That brings up an interesting point.<br=
><br>If we're going to allow the definition of arbitrary template funct=
ions within a function like this, why do we restrict them to being lambdas?=
That is, why do we allow generic lambdas but not local structs with templa=
te functions?</div><br>When we added lambdas to C++11, we also changed the =
wording on local structs to allow them to escape the functions that declare=
d them (previously, their types could not even be template argument deduced=
). If we're going to bless lambdas with arbitrary template powers, lets=
give local structs the same abilities.<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/db8850c4-a89a-46ec-8d36-829daa0246fe%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/db8850c4-a89a-46ec-8d36-829daa0246fe=
%40isocpp.org</a>.<br />
------=_Part_2819_1366436365.1473353778674--
------=_Part_2818_1559475559.1473353778673--
.
Author: FrankHB1989 <frankhb1989@gmail.com>
Date: Thu, 8 Sep 2016 21:09:35 -0700 (PDT)
Raw View
------=_Part_2846_946788388.1473394175694
Content-Type: multipart/alternative;
boundary="----=_Part_2847_222586310.1473394175695"
------=_Part_2847_222586310.1473394175695
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
=E5=9C=A8 2016=E5=B9=B49=E6=9C=889=E6=97=A5=E6=98=9F=E6=9C=9F=E4=BA=94 UTC+=
8=E4=B8=8A=E5=8D=8812:56:18=EF=BC=8CNicol Bolas=E5=86=99=E9=81=93=EF=BC=9A
>
> On Thursday, September 8, 2016 at 10:56:06 AM UTC-4, Simon Brand wrote:
>>
>> Another useful application of this extension is the indices trick (I'm=
=20
>> sure you're familiar with this from boost::hana, but thought I'd mention=
it=20
>> anyway).
>> If we want to tag dispatch using an index sequence, this usually require=
s=20
>> a separate function template, e.g.:
>>
>> template <typename Tuple, std::size_t... Idx>
>> void print_tuple(Tuple&& t, std::index_sequence<Idx...>) {
>> (..., (std::cout << std::get<Idx>(std::forward<Tuple>(t))));
>> }
>>
>> template <typename Tuple>
>> void print_tuple(Tuple&& t) {
>> constexpr auto size =3D std::tuple_size<std::decay_t<Tuple>>::value;
>> print_tuple(std::forward<Tuple>(t), std::make_index_sequence<size>{}=
);
>> }
>>
>> But with the usual template syntax we can do it all without a helper:
>>
>> template <typename Tuple>
>> void print_tuple(Tuple&& t) {
>> constexpr auto size =3D std::tuple_size<std::decay_t<Tuple>>::value;
>> =20
>> [&]<std::size_t... Idx>(std::index_sequence<Idx...>){
>> (..., (std::cout << std::get<Idx>(std::forward<Tuple>(t))));
>> }(std::make_index_sequence<size>{});
>> }
>>
>>
> That brings up an interesting point.
>
> If we're going to allow the definition of arbitrary template functions=20
> within a function like this, why do we restrict them to being lambdas? Th=
at=20
> is, why do we allow generic lambdas but not local structs with template=
=20
> functions?
>
> When we added lambdas to C++11, we also changed the wording on local=20
> structs to allow them to escape the functions that declared them=20
> (previously, their types could not even be template argument deduced). If=
=20
> we're going to bless lambdas with arbitrary template powers, lets give=20
> local structs the same abilities.
>
It's not that interesting because we are reinventing the wheel of first=20
class functions, though the direction is right since it is not preexisted=
=20
in C++. Then, besides interop capability (as well as object layout issues),=
=20
non-overloaded named functions/function templates seem to be a mostly=20
useless grammar sugar... like builtin pointers.
--=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/768d45ed-e8cc-4fcd-a1a8-88e908377170%40isocpp.or=
g.
------=_Part_2847_222586310.1473394175695
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>=E5=9C=A8 2016=E5=B9=B49=E6=9C=889=E6=97=A5=E6=98=
=9F=E6=9C=9F=E4=BA=94 UTC+8=E4=B8=8A=E5=8D=8812:56:18=EF=BC=8CNicol Bolas=
=E5=86=99=E9=81=93=EF=BC=9A<blockquote class=3D"gmail_quote" style=3D"margi=
n: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><di=
v dir=3D"ltr">On Thursday, September 8, 2016 at 10:56:06 AM UTC-4, Simon Br=
and 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>Another useful application of this extension is the indices trick
(I'm sure you're familiar with this from boost::hana, but tho=
ught
I'd mention it anyway).</p>
If we want to tag dispatch using an index sequence, this usually
requires a separate function template, e.g.:<br>
<tt><br>
</tt><tt>template <typename Tuple, std::size_t... Idx><br>
void print_tuple(Tuple&& t,
std::index_sequence<Idx...>) {<br>
=C2=A0=C2=A0=C2=A0 (..., (std::cout <<
std::get<Idx>(std::forward<<wbr>Tuple>(t))));<br>
}<br>
<br>
template <typename Tuple><br>
void print_tuple(Tuple&& t) {<br>
=C2=A0=C2=A0=C2=A0 constexpr auto size =3D
std::tuple_size<std::decay_t<<wbr>Tuple>>::value;<br>
=C2=A0=C2=A0=C2=A0 print_tuple(std::forward<<wbr>Tuple>(t),
std::make_index_sequence<size><wbr>{});<br>
}</tt><tt><br>
<br>
</tt>But with the usual template syntax we can do it all without a
helper:<br>
<br>
<tt>template <typename Tuple><br>
void print_tuple(Tuple&& t) {<br>
=C2=A0=C2=A0=C2=A0 constexpr auto size =3D
std::tuple_size<std::decay_t<<wbr>Tuple>>::value;<br>
=C2=A0=C2=A0=C2=A0 <br>
=C2=A0=C2=A0=C2=A0 [&]<std::size_t...
Idx>(std::index_sequence<Idx..<wbr>.>){<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (..., (std::cout <<
std::get<Idx>(std::forward<<wbr>Tuple>(t))));<br>
=C2=A0=C2=A0=C2=A0 }(std::make_index_sequence<<wbr>size>{});<br=
>
}</tt><tt></tt><tt></tt><br>
<br></div></blockquote><div><br>That brings up an interesting point.<br=
><br>If we're going to allow the definition of arbitrary template funct=
ions within a function like this, why do we restrict them to being lambdas?=
That is, why do we allow generic lambdas but not local structs with templa=
te functions?</div><br>When we added lambdas to C++11, we also changed the =
wording on local structs to allow them to escape the functions that declare=
d them (previously, their types could not even be template argument deduced=
). If we're going to bless lambdas with arbitrary template powers, lets=
give local structs the same abilities.<br></div></blockquote><div>It's=
not that interesting because we are reinventing the wheel of first class f=
unctions, though the direction is right since it is not preexisted in C++. =
Then, besides interop capability (as well as object layout issues), non-ove=
rloaded named functions/function templates seem to be a mostly useless gram=
mar sugar... like builtin pointers.<br><br><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/768d45ed-e8cc-4fcd-a1a8-88e908377170%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/768d45ed-e8cc-4fcd-a1a8-88e908377170=
%40isocpp.org</a>.<br />
------=_Part_2847_222586310.1473394175695--
------=_Part_2846_946788388.1473394175694--
.
Author: Louis Dionne <ldionne.2@gmail.com>
Date: Thu, 8 Sep 2016 21:34:03 -0700 (PDT)
Raw View
------=_Part_7095_1426841565.1473395643706
Content-Type: multipart/alternative;
boundary="----=_Part_7096_1852307146.1473395643706"
------=_Part_7096_1852307146.1473395643706
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Incidentally, one reason why I'm trying to make this part of the language i=
s
that I want the standard library to provide more utilities for=20
metaprogramming,
and these utilities need this proposal to be maximally useful. One goal of=
=20
these
metaprogramming utilities would be to remove the need for the indices trick=
=20
and
related tricks from user code altogether. Hence, while you are correct that=
=20
this
could be used for the indices trick, I consider this trick as being nothing=
=20
more
than an implementation detail, and as such I don't think I should use it as=
=20
a
motivation. It would conflict with my yet-unstated final goal.
On Thursday, 8 September 2016 07:56:06 UTC-7, Simon Brand wrote:
>
> Another useful application of this extension is the indices trick (I'm=20
> sure you're familiar with this from boost::hana, but thought I'd mention =
it=20
> anyway).
> If we want to tag dispatch using an index sequence, this usually requires=
=20
> a separate function template, e.g.:
>
> template <typename Tuple, std::size_t... Idx>
> void print_tuple(Tuple&& t, std::index_sequence<Idx...>) {
> (..., (std::cout << std::get<Idx>(std::forward<Tuple>(t))));
> }
>
> template <typename Tuple>
> void print_tuple(Tuple&& t) {
> constexpr auto size =3D std::tuple_size<std::decay_t<Tuple>>::value;
> print_tuple(std::forward<Tuple>(t), std::make_index_sequence<size>{})=
;
> }
>
> But with the usual template syntax we can do it all without a helper:
>
> template <typename Tuple>
> void print_tuple(Tuple&& t) {
> constexpr auto size =3D std::tuple_size<std::decay_t<Tuple>>::value;
> =20
> [&]<std::size_t... Idx>(std::index_sequence<Idx...>){
> (..., (std::cout << std::get<Idx>(std::forward<Tuple>(t))));
> }(std::make_index_sequence<size>{});
> }
>
>
> On 08/09/16 14:39, Nicol Bolas wrote:
>
> On Wednesday, September 7, 2016 at 9:16:26 PM UTC-4, Louis Dionne wrote:=
=20
>>
>> Hi,
>>
>> I wrote a paper to allow using the familiar template syntax to define=20
>> generic
>> lambdas:
>>
>> []<typename T>(T const& t) { }
>> // equivalent to
>> [](auto const& t) { }
>>
>> One of the motivations behind this is that it's often useful to be able =
to
>> name the type of a parameter (or a type derived from it) without having =
to
>> use `decltype(param)`. Other motivations are explained in more details i=
n
>> the paper.
>>
>> I'd like to gather some feedback, so please provide anything you've got.
>>
>
> In your motivation section, you say you have to do this:
>
> using T =3D std::remove_cv_t<std::remove_reference_t<decltype(x)>>;
>
> The more general way is with:
>
> using T =3D std::decay_t<decltype(x)>;
>
> While this will also decay arrays and turn functions into function=20
> pointers, that is irrelevant for most such use cases (since you can't pas=
s=20
> an array or a function. Well, not like this at any rate).
>
> Further, I dispute that this:
>
> auto f =3D [](auto&& ...args) {
> return foo(std::forward<decltype(args)>(args)...);
> };
>
> Is more verbose than this:
>
> auto f =3D []<typename ...T>(T&& ...args) {
> return foo(std::forward<T>(args)...);
> };
>
> From what I can tell, you save... one keystroke. And it's not like you ca=
n=20
> forward parameters* twice*.
>
> Overall, I'd say that your best motivation is #3, so you should lead with=
=20
> that.
> --=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/d09ee300-aef=
0-4f1a-9fb5-12bf5b316322%40isocpp.org=20
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/d09ee300-ae=
f0-4f1a-9fb5-12bf5b316322%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/7de66ab3-9a1b-45c8-abad-f5bd5cc56c52%40isocpp.or=
g.
------=_Part_7096_1852307146.1473395643706
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><div>Incidentally, one reason why I'm trying to m=
ake this part of the language is</div><div>that I want the standard library=
to provide more utilities for metaprogramming,</div><div>and these utiliti=
es need this proposal to be maximally useful. One goal of these</div><div>m=
etaprogramming utilities would be to remove the need for the indices trick =
and</div><div>related tricks from user code altogether. Hence, while you ar=
e correct that this</div><div>could be used for the indices trick, I consid=
er this trick as being nothing more</div><div>than an implementation detail=
, and as such I don't think I should use it as a</div><div>motivation. =
It would conflict with my yet-unstated final goal.</div></div><br>On Thursd=
ay, 8 September 2016 07:56:06 UTC-7, Simon Brand wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #cc=
c solid;padding-left: 1ex;">
=20
=20
=20
<div bgcolor=3D"#FFFFFF" text=3D"#000000">
<p>Another useful application of this extension is the indices trick
(I'm sure you're familiar with this from boost::hana, but tho=
ught
I'd mention it anyway).</p>
If we want to tag dispatch using an index sequence, this usually
requires a separate function template, e.g.:<br>
<tt><br>
</tt><tt>template <typename Tuple, std::size_t... Idx><br>
void print_tuple(Tuple&& t,
std::index_sequence<Idx...>) {<br>
=C2=A0=C2=A0=C2=A0 (..., (std::cout <<
std::get<Idx>(std::forward<<wbr>Tuple>(t))));<br>
}<br>
<br>
template <typename Tuple><br>
void print_tuple(Tuple&& t) {<br>
=C2=A0=C2=A0=C2=A0 constexpr auto size =3D
std::tuple_size<std::decay_t<<wbr>Tuple>>::value;<br>
=C2=A0=C2=A0=C2=A0 print_tuple(std::forward<<wbr>Tuple>(t),
std::make_index_sequence<size><wbr>{});<br>
}</tt><tt><br>
<br>
</tt>But with the usual template syntax we can do it all without a
helper:<br>
<br>
<tt>template <typename Tuple><br>
void print_tuple(Tuple&& t) {<br>
=C2=A0=C2=A0=C2=A0 constexpr auto size =3D
std::tuple_size<std::decay_t<<wbr>Tuple>>::value;<br>
=C2=A0=C2=A0=C2=A0 <br>
=C2=A0=C2=A0=C2=A0 [&]<std::size_t...
Idx>(std::index_sequence<Idx..<wbr>.>){<br>
=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 (..., (std::cout <<
std::get<Idx>(std::forward<<wbr>Tuple>(t))));<br>
=C2=A0=C2=A0=C2=A0 }(std::make_index_sequence<<wbr>size>{});<br=
>
}</tt><tt></tt><tt></tt><br>
<br>
<br>
<div>On 08/09/16 14:39, Nicol Bolas wrote:<br>
</div>
<blockquote type=3D"cite">
<div dir=3D"ltr">On Wednesday, September 7, 2016 at 9:16:26 PM
UTC-4, Louis Dionne wrote:
<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8=
ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir=3D"ltr">
<div>Hi,</div>
<div><br>
</div>
<div>I wrote a paper to allow using the familiar template
syntax to define generic</div>
<div>lambdas:</div>
<div><br>
</div>
<div>=C2=A0 []<typename T>(T const& t) { }</div>
<div>=C2=A0 // equivalent to</div>
<div>=C2=A0 [](auto const& t) { }</div>
<div><br>
</div>
<div>One of the motivations behind this is that it's often
useful to be able to</div>
<div>name the type of a parameter (or a type derived from
it) without having to</div>
<div>use `decltype(param)`. Other motivations are explained
in more details in</div>
<div>the paper.</div>
<div><br>
</div>
<div>I'd like to gather some feedback, so please provide
anything you've got.</div>
</div>
</blockquote>
<div><br>
In your motivation section, you say you have to do this:<br>
<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">using</span><span style=3D"co=
lor:#000"> T </span><span style=3D"color:#660">=3D</span><span style=3D"col=
or:#000"> std</span><span style=3D"color:#660">::</span><span style=3D"colo=
r:#000">remove_cv_t</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">remove_<wbr>reference_t</span><span style=3D"color:#660">&l=
t;</span><span style=3D"color:#008">decltype</span><span style=3D"color:#66=
0">(</span><span style=3D"color:#000">x</span><span style=3D"color:#660">)&=
gt;>;</span></div>
</code></div>
<br>
The more general way is with:<br>
<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">using</span><span style=3D"co=
lor:#000"> T </span><span style=3D"color:#660">=3D</span><span style=3D"col=
or:#000"> std</span><span style=3D"color:#660">::</span><span style=3D"colo=
r:#000">decay_t</span><span style=3D"color:#660"><</span><span style=3D"=
color:#008">decltype</span><span style=3D"color:#660">(</span><span style=
=3D"color:#000">x</span><span style=3D"color:#660">)>;</span><span style=
=3D"color:#000"><br>
</span></div>
</code></div>
<br>
While this will also decay arrays and turn functions into
function pointers, that is irrelevant for most such use cases
(since you can't pass an array or a function. Well, not like
this at any rate).<br>
<br>
Further, I dispute that this:<br>
<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">auto</span><span style=3D"col=
or:#000"> f </span><span style=3D"color:#660">=3D</span><span style=3D"colo=
r:#000"> </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"col=
or:#000">args</span><span style=3D"color:#660">)</span><span style=3D"color=
:#000"> </span><span style=3D"color:#660">{</span><span style=3D"color:#000=
"><br>
=C2=A0 </span><span style=3D"color:#008">return</span><sp=
an style=3D"color:#000"> foo</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">forward</span><span style=3D"color:#660"><</span><sp=
an style=3D"color:#008">decltype</span><span style=3D"color:#660">(</span><=
span style=3D"color:#000">args</span><span style=3D"color:#660"><wbr>)>(=
</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>
<br>
Is more verbose than this:<br>
<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">auto</span><span style=3D"col=
or:#000"> f </span><span style=3D"color:#660">=3D</span><span style=3D"colo=
r:#000"> </span><span style=3D"color:#660">[]<</span><span style=3D"colo=
r:#008">typename</span><span style=3D"color:#000"> </span><span style=3D"co=
lor:#660">...</span><span style=3D"color:#000">T</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"> </span><span style=3D"co=
lor:#660">...</span><span style=3D"color:#000">args</span><span style=3D"co=
lor:#660">)</span><span style=3D"color:#000"> </span><span style=3D"color:#=
660">{</span><span style=3D"color:#000"><br>
=C2=A0 </span><span style=3D"color:#008">return</span><sp=
an style=3D"color:#000"> foo</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">forward</span><span style=3D"color:#660"><</span><sp=
an style=3D"color:#000">T</span><span style=3D"color:#660">>(</span><spa=
n 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>
<br>
From what I can tell, you save... one keystroke. And it's not
like you can forward parameters<i> twice</i>.<br>
<br>
Overall, I'd say that your best motivation is #3, so you
should lead with that.<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"bsCVXq7cFAAJ" 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"bsCVXq7cFAAJ" 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/d09ee300-aef0-4f1a-9fb5-12bf5b3=
16322%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/d09ee300-aef0-4f1a-9fb5-12bf5b3163=
22%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/d09ee300-aef0-4f1a-9fb5-12bf5b316322%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/d09ee300-aef0-4f1a-<wbr=
>9fb5-12bf5b316322%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>
<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/7de66ab3-9a1b-45c8-abad-f5bd5cc56c52%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/7de66ab3-9a1b-45c8-abad-f5bd5cc56c52=
%40isocpp.org</a>.<br />
------=_Part_7096_1852307146.1473395643706--
------=_Part_7095_1426841565.1473395643706--
.
Author: Louis Dionne <ldionne.2@gmail.com>
Date: Thu, 8 Sep 2016 21:35:18 -0700 (PDT)
Raw View
------=_Part_416_90771920.1473395718532
Content-Type: multipart/alternative;
boundary="----=_Part_417_1352658639.1473395718533"
------=_Part_417_1352658639.1473395718533
Content-Type: text/plain; charset=UTF-8
On Thursday, 8 September 2016 09:56:18 UTC-7, Nicol Bolas wrote:
>
> On Thursday, September 8, 2016 at 10:56:06 AM UTC-4, Simon Brand wrote:
>>
>> [...]
>>
>
> That brings up an interesting point.
>
> If we're going to allow the definition of arbitrary template functions
> within a function like this, why do we restrict them to being lambdas? That
> is, why do we allow generic lambdas but not local structs with template
> functions?
>
> When we added lambdas to C++11, we also changed the wording on local
> structs to allow them to escape the functions that declared them
> (previously, their types could not even be template argument deduced). If
> we're going to bless lambdas with arbitrary template powers, lets give
> local structs the same abilities.
>
I think this is a very good idea, and I have run into this frustrating
limitation before. However, I think this belongs to a separate proposal
since the two features are vastly orthogonal.
--
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/116ea8c3-402c-4c3b-9e71-8c1949e5cc0b%40isocpp.org.
------=_Part_417_1352658639.1473395718533
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Thursday, 8 September 2016 09:56:18 UTC-7, Nico=
l Bolas 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=
">On Thursday, September 8, 2016 at 10:56:06 AM UTC-4, Simon Brand wrote:<b=
lockquote 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>[...]</p></div></blockquote><div><br>That brings up an interesting p=
oint.<br><br>If we're going to allow the definition of arbitrary templa=
te functions within a function like this, why do we restrict them to being =
lambdas? That is, why do we allow generic lambdas but not local structs wit=
h template functions?</div><br>When we added lambdas to C++11, we also chan=
ged the wording on local structs to allow them to escape the functions that=
declared them (previously, their types could not even be template argument=
deduced). If we're going to bless lambdas with arbitrary template powe=
rs, lets give local structs the same abilities.<br></div></blockquote><div>=
<br></div><div><div>I think this is a very good idea, and I have run into t=
his frustrating</div><div>limitation before. However, I think this belongs =
to a separate proposal</div><div>since the two features are vastly orthogon=
al.</div></div><div>=C2=A0</div></div>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" 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/116ea8c3-402c-4c3b-9e71-8c1949e5cc0b%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/116ea8c3-402c-4c3b-9e71-8c1949e5cc0b=
%40isocpp.org</a>.<br />
------=_Part_417_1352658639.1473395718533--
------=_Part_416_90771920.1473395718532--
.
Author: Chris DeVisser <chris.n.devisser@gmail.com>
Date: Fri, 9 Sep 2016 00:36:41 -0400
Raw View
--001a113d2a0290fb6a053c0bb289
Content-Type: text/plain; charset=UTF-8
>
> All in all, I do like the syntax that you propose and I suspect there might
> be something good there. However, I think it is a separate proposal from
> what's being proposed here.
You bring up some good points. I had not thought about non-deduced lambda
template parameters, nor about non-type template parameters and
deconstruction. Those are interesting to consider, particularly if your
proposal is accepted.
On Fri, Sep 9, 2016 at 12:31 AM, Louis Dionne <ldionne.2@gmail.com> wrote:
>
>
> On Wednesday, 7 September 2016 21:48:57 UTC-7, Chris DeVisser wrote:
>>
>> This has been looked at in a broader context than just lambdas. I queried
>> Reddit
>> <https://www.reddit.com/r/cpp/comments/3vden2/naming_deduced_types_proposal_idea_discussion/>
>> about this a while ago (and admittedly haven't had the time to get back to
>> it). The basic idea was that auto{T} t would introduce T as the
>> equivalent type had there been a template (i.e., template<typename T>
>> void foo(T const& t); and void foo(auto{T} const& t); would be
>> equivalent). This could be extended to lambdas very easily, as well as to
>> Concepts and other uses of auto.
>>
>> After that, I found out that there was already a Concepts-related
>> proposal
>> <http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3878.pdf> on
>> the matter with a very similar idea. Of course given the Concepts changes
>> since then, this would presumably use auto[T] t now. Structured bindings
>> would also need to be taken into account.
>>
>> This train hasn't moved in a while, but feel free to use my part of this
>> for inspiration. I must admit I do quite like the terseness and consistency
>> with Concepts, which already use this syntax to introduce a type.
>> Regardless, if adding an explicit type in deduced contexts is adopted, I
>> would like to see it cover cases such as declaring a local variable, and I
>> would like to make sure that Concepts can be used with consistent syntax,
>> when that time comes.
>>
>
> That's an interesting idea, however I think it does not allow for lambdas
> that do not deduce their template parameter, such as
>
> auto f = []<typename T>() { };
> f.operator()<int>();
>
> I also do not see a straightforward way of doing stuff like this:
>
> []<typename T, typename = std::enable_if_t<some_trait<T>>>() { };
>
> For this and other nifty tricks, you really need full control on how the
> template parameter list is created. Sure, Concepts will remove many use
> cases for this, but not all of them. Finally, I do not see an easy way of
> deducing non-type template parameters from your proposal, nor to
> "deconstruct"
> template arguments of other templates:
>
> auto f = []<typename T, std::size_t N>(std::array<T, N> const& a) { };
>
> All in all, I do like the syntax that you propose and I suspect there might
> be something good there. However, I think it is a separate proposal from
> what's
> being proposed 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/b5d17724-717d-4131-
> 82c0-8b6312171e17%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b5d17724-717d-4131-82c0-8b6312171e17%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/CAM6NJy6gefvG0MBAiq3-08kGcsUVsjYzyJnf7bPp0602PPH-1Q%40mail.gmail.com.
--001a113d2a0290fb6a053c0bb289
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><blockquote style=3D"margin:0px 0px 0px 0.8ex;border-left:=
1px solid rgb(204,204,204);padding-left:1ex" class=3D"gmail_quote">All in a=
ll, I do like the syntax that you propose and I suspect there might<br>be s=
omething good there. However, I think it is a separate proposal from what&#=
39;s=C2=A0<span style=3D"font-size:12.8px">being proposed here.</span></blo=
ckquote><div><br></div><div>You bring up some good points. I had not though=
t about non-deduced lambda template parameters, nor about non-type template=
parameters and deconstruction. Those are interesting to consider, particul=
arly if your proposal is accepted.</div></div><div class=3D"gmail_extra"><b=
r><div class=3D"gmail_quote">On Fri, Sep 9, 2016 at 12:31 AM, Louis Dionne =
<span dir=3D"ltr"><<a href=3D"mailto:ldionne.2@gmail.com" target=3D"_bla=
nk">ldionne.2@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 dir=3D"ltr"><span class=3D""><br><br>On Wednesday, 7 September 20=
16 21:48:57 UTC-7, Chris DeVisser 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">This has been looked at in a broader context than ju=
st lambdas. I <a href=3D"https://www.reddit.com/r/cpp/comments/3vden2/namin=
g_deduced_types_proposal_idea_discussion/" rel=3D"nofollow" target=3D"_blan=
k">queried Reddit</a> about this a while ago (and admittedly haven't ha=
d the time to get back to it). The basic idea was that <font face=3D"courie=
r new, monospace">auto{T} t</font>=C2=A0would introduce T as the equivalent=
type had there been a template (i.e., <font face=3D"courier new, monospace=
">template<typename T> void foo(T const& t);</font> and <font fac=
e=3D"courier new, monospace">void foo(auto{T} const& t);</font> would b=
e equivalent). This could be extended to lambdas very easily, as well as to=
Concepts and other uses of auto.<div><br></div><div>After that, I found ou=
t that there was already a <a href=3D"http://www.open-std.org/jtc1/sc22/wg2=
1/docs/papers/2014/n3878.pdf" rel=3D"nofollow" target=3D"_blank">Concepts-r=
elated proposal</a> on the matter with a very similar idea. Of course given=
the Concepts changes since then, this would presumably use <font face=3D"c=
ourier new, monospace">auto[T] t</font> now. Structured bindings would also=
need to be taken into account.=C2=A0</div><div><br></div><div>This train h=
asn't moved in a while, but feel free to use my part of this for inspir=
ation. I must admit I do quite like the terseness and consistency with Conc=
epts, which already use this syntax to introduce a type. Regardless, if add=
ing an explicit type in deduced contexts is adopted, I would like to see it=
cover cases such as declaring a local variable, and I would like to make s=
ure that Concepts can be used with consistent syntax, when that time comes.=
</div></div></blockquote><div><br></div></span><div><div>That's an inte=
resting idea, however I think it does not allow for lambdas</div><div>that =
do not deduce their template parameter, such as</div><div><br></div><div>=
=C2=A0 =C2=A0 auto f =3D []<typename T>() { };</div><div>=C2=A0 =C2=
=A0 f.operator()<int>();</div><div><br></div><div>I also do not see a=
straightforward way of doing stuff like this:</div><div><br></div><div>=C2=
=A0 =C2=A0 []<typename T, typename =3D std::enable_if_t<some_trait<=
;T><wbr>>>() { };</div><div><br></div><div>For this and other nift=
y tricks, you really need full control on how the</div><div>template parame=
ter list is created. Sure, Concepts will remove many use</div><div>cases fo=
r this, but not all of them. Finally, I do not see an easy way of</div><div=
>deducing non-type template parameters from your proposal, nor to "dec=
onstruct"</div><div>template arguments of other templates:</div><div><=
br></div><div>=C2=A0 =C2=A0 auto f =3D []<typename T, std::size_t N>(=
std::array<T, N> const& a) { };</div><div><br></div><div>All in a=
ll, I do like the syntax that you propose and I suspect there might</div><d=
iv>be something good there. However, I think it is a separate proposal from=
what's</div><div>being proposed here.</div></div><div><br></div></div>
<p></p>
-- <br><span class=3D"">
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br></span>
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>.<span class=3D""><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></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/b5d17724-717d-4131-82c0-8b6312171e17%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/<wbr>isocpp.org/d/msgid/std-<wbr>proposals/b5d1=
7724-717d-4131-<wbr>82c0-8b6312171e17%40isocpp.org</a><wbr>.<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/CAM6NJy6gefvG0MBAiq3-08kGcsUVsjYzyJnf=
7bPp0602PPH-1Q%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfooter">htt=
ps://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAM6NJy6gefvG0MBA=
iq3-08kGcsUVsjYzyJnf7bPp0602PPH-1Q%40mail.gmail.com</a>.<br />
--001a113d2a0290fb6a053c0bb289--
.