Topic: Small change to a function declaration: allow to drop


Author: Mikhail Semenov <mikhailsemenov1957@gmail.com>
Date: Thu, 30 May 2013 01:26:13 -0700 (PDT)
Raw View
------=_Part_4077_22266246.1369902373547
Content-Type: text/plain; charset=ISO-8859-1

Now-a-days we often write
auto f(...)->decltype(expression) { ... return expression; }

I propose to drop the result type:

auto f(...) {... return expression; }

but on two conditions:
(1) only if there is only one return in the function body (a bit similar to
a newly proposed lambda);
(2) you are not allowed to refer to this function using a header (forward
declaration, etc).

The second option will guard against the abuse of the usage.

I find it looks ugly, when a long expression is written in the decltype
construct.

I think this feature may be particularly useful when writing templates.


--

---
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/?hl=en.



------=_Part_4077_22266246.1369902373547
Content-Type: text/html; charset=ISO-8859-1

<DIV>Now-a-days we often write </DIV>
<DIV>auto f(...)-&gt;decltype(expression) { ... return expression; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>I propose to drop the result type:</DIV>
<DIV>
<DIV>&nbsp;</DIV>
<DIV>auto f(...) {... return expression; }</DIV>
<DIV>&nbsp;</DIV>
<DIV>but on two conditions:</DIV>
<DIV>(1) only if there is only one return in&nbsp;the function body (a bit similar to a newly proposed lambda);</DIV>
<DIV>(2) you are not allowed to refer to this function using a header (forward declaration, etc).</DIV>
<DIV>&nbsp;</DIV>
<DIV>The second option will guard against the abuse of the usage.</DIV>
<DIV>&nbsp;</DIV>
<DIV>I find it looks ugly, when a long expression is written in the decltype construct.</DIV>
<DIV>&nbsp;</DIV>
<DIV>I think this feature&nbsp;may be particularly useful when writing templates.</DIV>
<DIV>&nbsp;</DIV></DIV>

<p></p>

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

------=_Part_4077_22266246.1369902373547--

.