Topic: An implementation of enhanced auto deduction
Author: =?UTF-8?Q?Klaim_=2D_Jo=C3=ABl_Lamotte?= <mjklaim@gmail.com>
Date: Wed, 4 Mar 2015 13:50:29 +0100
Raw View
--001a11c3fd946a6081051075e5ad
Content-Type: text/plain; charset=UTF-8
On Wed, Mar 4, 2015 at 1:45 PM, Faisal Vali <faisalv@gmail.com> wrote:
> > I don't see the use-case for this feature. Why would I write
> >
> > vector<auto> v = vector<int>();
> >
> > when it's less typing and less noise to just write
> >
> > auto v = vector<int>();
> >
>
> I generally agree with the above statement - but there are some who
> have argued that it can improve readability - and I see their point
> too.
Another argument would be that if you have
auto v = generateData();
It is less constrained than
vector<auto> v = generateData();
which add an interesting constraint that generateData() must return a
vector, not just something that
have the same interface.
It looks like improved granularity on constraints specifications.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+unsubscribe@isocpp.org.
To post to this group, send email to std-discussion@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-discussion/.
--001a11c3fd946a6081051075e5ad
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">=
On Wed, Mar 4, 2015 at 1:45 PM, Faisal Vali <span dir=3D"ltr"><<a href=
=3D"mailto:faisalv@gmail.com" target=3D"_blank">faisalv@gmail.com</a>></=
span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8e=
x;border-left:1px #ccc solid;padding-left:1ex"><div class=3D"HOEnZb adM"><d=
iv class=3D"">> I don't see the use-case for this feature. Why would=
I write<br>
><br>
>=C2=A0 =C2=A0 =C2=A0vector<auto> v =3D vector<int>();<br>
><br>
> when it's less typing and less noise to just write<br>
><br>
>=C2=A0 =C2=A0 =C2=A0auto v =3D vector<int>();<br>
><br>
<br>
</div></div>I generally agree with the above statement - but there are some=
who<br>
have argued that it can improve readability - and I see their point<br>
too.</blockquote></div><br>Another argument would be that if you have</div>=
<div class=3D"gmail_extra"><br></div><div class=3D"gmail_extra">=C2=A0 =C2=
=A0 auto v =3D generateData();</div><div class=3D"gmail_extra"><br></div><d=
iv class=3D"gmail_extra">It is less constrained than</div><div class=3D"gma=
il_extra"><br></div><div class=3D"gmail_extra">=C2=A0 =C2=A0 vector<auto=
> v =3D generateData();</div><div class=3D"gmail_extra"><br></div><div c=
lass=3D"gmail_extra">which add an interesting constraint that generateData(=
) must return a vector, not just something that</div><div class=3D"gmail_ex=
tra">have the same interface.</div><div class=3D"gmail_extra">It looks like=
improved granularity on constraints specifications.</div><div class=3D"gma=
il_extra"><br></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Discussion" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-discussion+unsubscribe@isocpp.org">std-discus=
sion+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-discussion@isocp=
p.org">std-discussion@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-discussion/">http://groups.google.com/a/isocpp.org/group/std-discussion=
/</a>.<br />
--001a11c3fd946a6081051075e5ad--
.
Author: "Arthur O'Dwyer" <arthur.j.odwyer@gmail.com>
Date: Wed, 4 Mar 2015 12:24:19 -0800
Raw View
--14dae9cc988e6e8d9405107c3c67
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Wed, Mar 4, 2015 at 9:14 AM, Matthew Fioravante <fmatthew5876@gmail.com>
wrote:
> On Wednesday, March 4, 2015 at 12:36:02 AM UTC-5, Arthur O'Dwyer wrote:
>>
>>
>> I don't see the use-case for this feature. Why would I write
>>
>> vector<auto> v =3D vector<int>();
>>
>> when it's less typing and less noise to just write
>>
>> auto v =3D vector<int>();
>>
>
> The use case for this:
>
> vector<int> v;
>
> array_view<auto> av =3D v; //deduces to array_view<int>
>
>
Does that work with Faisal's patch? I don't see how it could, since the
right-hand side is vector<int> and the left-hand side is
array_view<UNKNOWN>. What if array_view has a specialization for <long
double (*)()> that has a constructor taking vector<int>? Then it would be
ambiguous whether <UNKNOWN> should be equal to <int> or to <long double
(*)()>.
On that topic, what about this multiple-inheritance test case?
template<class T> struct Base { T t };
struct D1 : Base<int> {};
struct D2 : Base<int>, Base<double> {};
Base<auto> *p1 =3D new D1; // well-formed?
Base<auto> *p2 =3D new D2; // must be ill-formed, surely?
However, Scott Prager writes:
*> Great stuff! No more writing is_tuple and is_pair functions to
get SFINAE overloading.*
I hadn't thought of that! That is a killer app IMHO, but only if it works
right. *Does* it work right? Do we even know what "right" is, yet?
auto doPairSpecificThing(const pair<auto,auto>& arg) { return true; }
auto doPairSpecificThing(auto&& arg) { return false; }
int a, b;
doPairSpecificThing(std::pair<int,int>(a,b));
doPairSpecificThing(std::pair<int&&,int&>(std::move(a),b));
=E2=80=93Arthur
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
--14dae9cc988e6e8d9405107c3c67
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Wed, Mar 4, 2015 at 9:14 AM, Matthew Fioravante <span d=
ir=3D"ltr"><<a href=3D"mailto:fmatthew5876@gmail.com" target=3D"_blank">=
fmatthew5876@gmail.com</a>></span> wrote:<div class=3D"gmail_extra"><div=
class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0p=
x 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);bo=
rder-left-style:solid;padding-left:1ex"><div dir=3D"ltr"><span class=3D"">O=
n Wednesday, March 4, 2015 at 12:36:02 AM UTC-5, Arthur O'Dwyer wrote:<=
/span><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;b=
order-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:s=
olid;padding-left:1ex"><div dir=3D"ltr"><span class=3D""><br><div>I don'=
;t see the use-case for this feature. Why would I write</div><div><br></div=
></span><span class=3D""><div><div style=3D"background-color:rgb(250,250,25=
0);border:1px solid rgb(187,187,187);word-wrap:break-word"><code><div><span=
style=3D"color:rgb(0,0,0)">=C2=A0 =C2=A0 vector</span><span style=3D"color=
:rgb(0,136,0)"><auto></span><span style=3D"color:rgb(0,0,0)"> v </spa=
n><span style=3D"color:rgb(102,102,0)">=3D</span><span style=3D"color:rgb(0=
,0,0)"> vector</span><span style=3D"color:rgb(0,136,0)"><int></span><=
span style=3D"color:rgb(102,102,0)">();</span></div></code></div></div><div=
><br></div></span><span class=3D""><div>when it's less typing and less =
noise to just write</div><div><br></div></span><span class=3D""><div><div s=
tyle=3D"background-color:rgb(250,250,250);border:1px solid rgb(187,187,187)=
;word-wrap:break-word"><code><div><span style=3D"color:rgb(0,0,0)">=C2=A0 =
=C2=A0 </span><span style=3D"color:rgb(0,0,136)">auto</span><span style=3D"=
color:rgb(0,0,0)"> v </span><span style=3D"color:rgb(102,102,0)">=3D</span>=
<span style=3D"color:rgb(0,0,0)"> vector</span><span style=3D"color:rgb(0,1=
36,0)"><int></span><span style=3D"color:rgb(102,102,0)">();</span></d=
iv></code></div></div></span></div></blockquote><div><br>The use case for t=
his:<br><br><div style=3D"background-color:rgb(250,250,250);border:1px soli=
d rgb(187,187,187);word-wrap:break-word"><code><div><div style=3D"backgroun=
d-color:rgb(250,250,250);border:1px solid rgb(187,187,187);word-wrap:break-=
word"><code><div><span style=3D"color:rgb(102,0,102)">vector<int> v;<=
br><br>array_view<auto> av =3D v; //deduces to array_view<int><=
br></span><span style=3D"color:rgb(0,0,0)"></span><span style=3D"color:rgb(=
102,102,0)"></span></div></code></div></div></code></div><br></div></div></=
blockquote><div><span style=3D"font-size:13px"><br></span></div><div>Does t=
hat work with Faisal's patch? I don't see how it could, since the r=
ight-hand side is vector<int> and the left-hand side is array_view<=
;UNKNOWN>. What if array_view has a specialization for <long double (=
*)()> that has a constructor taking vector<int>? Then it would be =
ambiguous whether <UNKNOWN> should be equal to <int> or to <=
long double (*)()>.</div><div><br></div><div>On that topic, what about t=
his multiple-inheritance test case?</div><div><br></div><div><font face=3D"=
monospace, monospace">=C2=A0 =C2=A0 template<class T> struct Base { T=
t };</font></div><div><font face=3D"monospace, monospace">=C2=A0 =C2=A0 st=
ruct D1 : Base<int> {};</font></div><div><font face=3D"monospace, mon=
ospace">=C2=A0 =C2=A0 struct D2 : Base<int>, Base<double> {};</=
font></div><div><font face=3D"monospace, monospace"><br></font></div><div><=
font face=3D"monospace, monospace">=C2=A0 =C2=A0 Base<auto> *p1 =3D n=
ew D1; =C2=A0// well-formed?</font></div><div><font face=3D"monospace, mono=
space">=C2=A0 =C2=A0 Base<auto> *p2 =3D new D2; =C2=A0// must be ill-=
formed, surely?</font></div><div><br></div><div><br></div><div>However, Sco=
tt Prager writes:</div><div><i><span style=3D"font-size:13px">> Great st=
uff! No more writing=C2=A0</span><span style=3D"font-size:13px">is_tuple</s=
pan><span style=3D"font-size:13px">=C2=A0and=C2=A0</span><span style=3D"fon=
t-size:13px">is_pair</span><span style=3D"font-size:13px">=C2=A0functions t=
o get=C2=A0</span><span style=3D"font-size:13px">SFINAE overloading.</span>=
</i></div><div><br></div><div>I hadn't thought of that! That is a kille=
r app IMHO, but only if it works right. <i>Does</i> it work right? Do we ev=
en know what "right" is, yet?</div><div><br></div><div><font face=
=3D"monospace, monospace">auto doPairSpecificThing(const pair<auto,auto&=
gt;& arg) { return true; }</font></div><div><font face=3D"monospace, mo=
nospace">auto doPairSpecificThing(auto&& arg) { return false; }</fo=
nt></div><div><font face=3D"monospace, monospace"><br></font></div><div><fo=
nt face=3D"monospace, monospace">int a, b;</font></div><div><font face=3D"m=
onospace, monospace">doPairSpecificThing(std::pair<int,int>(a,b));</f=
ont></div><div><font face=3D"monospace, monospace">doPairSpecificThing(std:=
:pair<int&&,int&>(std::move(a),b));</font></div><div><div=
><br></div></div><div>=E2=80=93Arthur</div></div></div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
--14dae9cc988e6e8d9405107c3c67--
.
Author: Scott Prager <splinterofchaos@gmail.com>
Date: Wed, 4 Mar 2015 13:18:16 -0800 (PST)
Raw View
------=_Part_6909_1735137163.1425503896949
Content-Type: multipart/alternative;
boundary="----=_Part_6910_1769855928.1425503896949"
------=_Part_6910_1769855928.1425503896949
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Wednesday, March 4, 2015 at 3:24:21 PM UTC-5, Arthur O'Dwyer wrote:
=20
>
> However, Scott Prager writes:
> *> Great stuff! No more writing is_tuple and is_pair functions to=20
> get SFINAE overloading.*
>
> I hadn't thought of that! That is a killer app IMHO, but only if it works=
=20
> right. *Does* it work right? Do we even know what "right" is, yet?
>
> auto doPairSpecificThing(const pair<auto,auto>& arg) { return true; }
> auto doPairSpecificThing(auto&& arg) { return false; }
>
> int a, b;
> doPairSpecificThing(std::pair<int,int>(a,b));
> doPairSpecificThing(std::pair<int&&,int&>(std::move(a),b));
>
> =E2=80=93Arthur
>
I forgot I wrote that... brain fart. Obviously, this can be achieved using
normal templates and also this still doesn't provide a way to perfect=20
forward
and pattern match at the same time.
But, yes, the example you wrote does work, but you have to change the
first overload to this:
bool doPairSpecificThing(std::pair<auto,auto>&& arg) { return true; }
Since *auto&&* precedes *const pair&* in partial function overloading.
--=20
---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.
------=_Part_6910_1769855928.1425503896949
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Wednesday, March 4, 2015 at 3:24:21 PM UTC-5, A=
rthur O'Dwyer wrote:<div> </div><blockquote class=3D"gmail_quote" styl=
e=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></div><div><br=
></div><div>However, Scott Prager writes:</div><div><i><span style=3D"font-=
size:13px">> Great stuff! No more writing </span><span style=3D"fon=
t-size:13px">is_tuple</span><span style=3D"font-size:13px"> and <=
/span><span style=3D"font-size:13px">is_pair</span><span style=3D"font-size=
:13px"> <wbr>functions to get </span><span style=3D"font-size:13p=
x">SFINAE overloading.</span></i></div><div><br></div><div>I hadn't thought=
of that! That is a killer app IMHO, but only if it works right. <i>Does</i=
> it work right? Do we even know what "right" is, yet?</div><div><br></div>=
<div><font face=3D"monospace, monospace">auto doPairSpecificThing(const pai=
r<auto,auto>& arg) { return true; }</font></div><div><font face=
=3D"monospace, monospace">auto doPairSpecificThing(auto&& arg) { re=
turn false; }</font></div><div><font face=3D"monospace, monospace"><br></fo=
nt></div><div><font face=3D"monospace, monospace">int a, b;</font></div><di=
v><font face=3D"monospace, monospace">doPairSpecificThing(std::pair<<wbr=
>int,int>(a,b));</font></div><div><font face=3D"monospace, monospace">do=
PairSpecificThing(std::pair<<wbr>int&&,int&>(std::move(a)=
,b));</font></div><div><div><br></div></div><div>=E2=80=93Arthur</div></div=
></div></div></blockquote><div><br></div><div><div>I forgot I wrote that...=
brain fart. Obviously, this can be achieved using</div><div>normal templat=
es and also this still doesn't provide a way to perfect forward</div><div>a=
nd pattern match at the same time.</div></div><div><br></div><div>But, yes,=
the example you wrote does work, but you have to change the</div><div>firs=
t overload to this:</div><div><br></div><div><div>bool doPairSpecificThing(=
std::pair<auto,auto>&& arg) { return true; }</div></div><div>=
<br></div><div>Since <i>auto&&</i> precedes <i>const pair&=
</i> in partial function overloading.</div></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />
------=_Part_6910_1769855928.1425503896949--
------=_Part_6909_1735137163.1425503896949--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Fri, 6 Mar 2015 01:36:19 +0200
Raw View
On 6 March 2015 at 01:19, Nicol Bolas <jmckesson@gmail.com> wrote:
> My issue is with, well, any syntax that declares a template without having
> to type either the word "template" or the use of "<>" brackets. Templates
> are a fundamentally different kind of construct, and we have specific syntax
> for doing so. By removing that syntax, it becomes way too easy to not notice
> that you've declared a template.
Why is that a problem?
> The last thing we should want is for people to accidentally make something a
> template.
Same question.
> I accept this with lambdas, because the main point of lambdas is that
> they're a short-cut. Furthermore, they have a syntax that's fundamentally
> different from regular functions. But for a regular function? No.
Ditto.
>
> Basically, if I see this:
>
> X func_name(...);
>
> I expect that &func_name ought to return a pointer. For it to do something
> else, like being a compiler error, would be surprising.
That already happens if func_name is overloaded, so the terse template
declaration
syntax doesn't introduce that particular problem.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.
.