Topic: auto in function declarations


Author: walter1234 <walter2bz@gmail.com>
Date: Thu, 12 Jun 2014 01:41:35 -0700 (PDT)
Raw View
------=_Part_3462_6508171.1402562495260
Content-Type: text/plain; charset=UTF-8

Has anyone suggested using 'auto' in function definitions similarly to its
use in lambdas - as sugar for templates

imagine if
    auto  foo(auto x, auto y) {
    }

was sugar for
    template<typename X,typename Y>
    auto foo(X x, Y y) {
       ...
    }

So its just one line - but would streamline writing small helpers.
once you've seen it for lambdas, I think it would be very intuitive.
might seem trivial but it would cut down on some syntactic noise, every
little helps.

of course what would be really nice is if the absence of a type meant
'auto' too, but I'm guessing that would be problematic to retrofit ?

--

---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/.

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

<div dir=3D"ltr">Has anyone suggested using 'auto' in function definitions =
similarly to its use in lambdas - as sugar for templates<div><br></div><div=
>imagine if</div><div>&nbsp; &nbsp; auto &nbsp;foo(auto x, auto y) {</div><=
div>&nbsp; &nbsp; }</div><div><br></div><div>was sugar for</div><div>&nbsp;=
 &nbsp; template&lt;typename X,typename Y&gt;</div><div>&nbsp; &nbsp; auto =
foo(X x, Y y) {</div><div>&nbsp; &nbsp; &nbsp; &nbsp;...</div><div>&nbsp; &=
nbsp; }</div><div><br></div><div>So its just one line - but would streamlin=
e writing small helpers.</div><div>once you've seen it for lambdas, I think=
 it would be very intuitive.</div><div>might seem trivial but it would cut =
down on some syntactic noise, every little helps.</div><div><br></div><div>=
of course what would be really nice is if the absence of a type meant 'auto=
' too, but I'm guessing that would be problematic to retrofit ?</div></div>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_3462_6508171.1402562495260--

.


Author: =?ISO-8859-1?Q?Daniel_Kr=FCgler?= <daniel.kruegler@gmail.com>
Date: Thu, 12 Jun 2014 10:47:57 +0200
Raw View
2014-06-12 10:41 GMT+02:00 walter1234 <walter2bz@gmail.com>:
> Has anyone suggested using 'auto' in function definitions similarly to its
> use in lambdas - as sugar for templates
>
> imagine if
>     auto  foo(auto x, auto y) {
>     }
>
> was sugar for
>     template<typename X,typename Y>
>     auto foo(X x, Y y) {
>        ...
>     }
>
> So its just one line - but would streamline writing small helpers.
> once you've seen it for lambdas, I think it would be very intuitive.
> might seem trivial but it would cut down on some syntactic noise, every
> little helps.
>
> of course what would be really nice is if the absence of a type meant 'auto'
> too, but I'm guessing that would be problematic to retrofit ?

This had been suggested earlier and it is part of the concept proposal
as well, search for "generic function" in

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4040.pdf

- Daniel

--

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

.