Topic: Get a copy of an object as rvalue


Author: "Diego R." <dieram3@gmail.com>
Date: Sat, 4 Apr 2015 21:42:51 -0700 (PDT)
Raw View
------=_Part_753_623065317.1428208971717
Content-Type: multipart/alternative;
 boundary="----=_Part_754_728520047.1428208971717"

------=_Part_754_728520047.1428208971717
Content-Type: text/plain; charset=UTF-8

Sometimes we want manipulate an object with certain properties changed, but
preserving the original.

For example:
std::string parent = ...;
....
auto child = parent;
child.to_upper();
// or auto child = std::string(parent).to_upper();


std::bitset<16> state = ...;
....
for(size_t i = 0; i != 16; ++i) {
  if(state.test(i)) continue;
  auto child_state = state;
  child_state.set(i);
  // or auto child_state = std::bitset<16>(state).set(i);
}




This can be some cumbersome. I was thinking that the following function put
in <utility> could solve this issue.

template <class T>
T copy(const T& obj) { return obj; }


So we could write nicer code like that:
const auto child_state = copy(state).set(i).set(j);
....
const auto lower_str = copy(str).to_lower();

What do you think about it?

Regards

--

---
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_754_728520047.1428208971717
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Sometimes we want manipulate an object with certain proper=
ties changed, but preserving the original.<div><br></div><div>For example:<=
/div><div><div class=3D"prettyprint" style=3D"background-color: rgb(250, 25=
0, 250); border: 1px solid rgb(187, 187, 187); word-wrap: break-word;"><cod=
e class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color:=
 #000;" class=3D"styled-by-prettify">std</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">::</span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">string</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> parent </span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">=3D</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"><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><span =
style=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> child </span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> parent</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br>child</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">.</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">to_upper</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">();</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br></span><span style=3D"color: #800;" class=3D"styled-by-prettify">=
// or auto child =3D std::string(parent).to_upper();</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br><br><br>std</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">::</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">bitset</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">&lt;</span><span style=3D"color: #066;" =
class=3D"styled-by-prettify">16</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">&gt;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> state </span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> </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><span style=
=3D"color: #008;" class=3D"styled-by-prettify">for</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">size_t i </span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #066;" class=3D"style=
d-by-prettify">0</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> i =
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">!=3D</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #066;" class=3D"styled-by-prettify">16</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">++</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">i</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">)</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> <=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; </span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">if</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">state</span><font color=3D"#666600">=
<span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify">test</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">i</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">))</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">continue</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
></span></font><span style=3D"color: #000;" class=3D"styled-by-prettify">&n=
bsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">auto<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> child_stat=
e </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> state</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbsp; child_state</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">set</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">i</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br>&nbsp; </span><span style=3D"color: #800;" class=3D"st=
yled-by-prettify">// or auto child_state =3D std::bitset&lt;16&gt;(state).s=
et(i);</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br><br><br></span>=
</div></code></div><br>&nbsp;</div><div>This can be some cumbersome. I was =
thinking that the following function put in &lt;utility&gt; could solve thi=
s issue.</div><div><br></div><div><div class=3D"prettyprint" style=3D"backg=
round-color: rgb(250, 250, 250); border: 1px solid rgb(187, 187, 187); word=
-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprin=
t"><span style=3D"color: #008;" class=3D"styled-by-prettify">template</span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">&lt;</span><span style=3D=
"color: #008;" class=3D"styled-by-prettify">class</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify"> T</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">&gt;</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br>T copy</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styl=
ed-by-prettify">const</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"> T</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">&amp;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> o=
bj</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">{</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;=
" class=3D"styled-by-prettify">return</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> obj</span><span style=3D"color: #660;" class=3D=
"styled-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">}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><b=
r></span></div></code></div><br>So we could write nicer code like that:</di=
v><div><div class=3D"prettyprint" style=3D"background-color: rgb(250, 250, =
250); border: 1px solid rgb(187, 187, 187); word-wrap: break-word;"><code c=
lass=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">const</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"> child_state </span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">=3D</span><font color=3D"#000000"><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> copy</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">state</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">).</span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">set</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">i</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">).</span><span sty=
le=3D"color: #008;" class=3D"styled-by-prettify">set</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">j</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">...</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br></span><span style=3D"color: #008;" class=3D"styled-by-prettify">con=
st</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"> lower_str </span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> copy</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">str</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">).</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify">to_lower</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">();</span></font></div></code></div><br>What do you think a=
bout it?</div><div><br></div><div>Regards</div><div><br></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_754_728520047.1428208971717--
------=_Part_753_623065317.1428208971717--

.


Author: Zhihao Yuan <zy@miator.net>
Date: Sun, 5 Apr 2015 05:54:51 -0400
Raw View
On Sun, Apr 5, 2015 at 12:42 AM, Diego R. <dieram3@gmail.com> wrote:
>
> So we could write nicer code like that:
> const auto child_state = copy(state).set(i).set(j);
> ...
> const auto lower_str = copy(str).to_lower();
>
> What do you think about it?
>

  auto x(y);  // or auto x{y} in C++14

creates a copy of y as x, so I assume that `auto(y)`
create a prvalue of y... Well, it doesn't.  But why not?

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://bit.ly/blog4bsd

--

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

.


Author: David Krauss <potswa@gmail.com>
Date: Sun, 5 Apr 2015 21:22:29 +0800
Raw View
--Apple-Mail=_14E57F14-4CFF-4C49-B965-D8C77F28C078
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2015=E2=80=9304=E2=80=9305, at 12:42 PM, Diego R. <dieram3@gmail.com> =
wrote:
>=20
> template <class T>
> T copy(const T& obj) { return obj; }
>=20

There=E2=80=99s no need to make a copy if the argument is already an rvalue=
..

template< typename t >
t std::value( t v ) { return std::move( v ); }

or more efficiently:

template< typename t >
t std::value( t const & v ) { return v; }
template< typename t >
t && std::value( t && v ) { return std::move( v ); }

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

--Apple-Mail=_14E57F14-4CFF-4C49-B965-D8C77F28C078
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9304=
=E2=80=9305, at 12:42 PM, Diego R. &lt;<a href=3D"mailto:dieram3@gmail.com"=
 class=3D"">dieram3@gmail.com</a>&gt; wrote:</div><div class=3D""><div dir=
=3D"ltr" class=3D""><div class=3D""><br class=3D""></div><div class=3D""><d=
iv class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); bor=
der: 1px solid rgb(187, 187, 187); word-wrap: break-word;"><code class=3D"p=
rettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">templ=
ate</span> <span style=3D"color: #660;" class=3D"styled-by-prettify">&lt;</=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">class</span>=
 T<span style=3D"color: #660;" class=3D"styled-by-prettify">&gt;</span><br =
class=3D"">T copy<span style=3D"color: #660;" class=3D"styled-by-prettify">=
(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">const</sp=
an> T<span style=3D"color: #660;" class=3D"styled-by-prettify">&amp;</span>=
 obj<span style=3D"color: #660;" class=3D"styled-by-prettify">)</span> <spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">{</span> <span style=
=3D"color: #008;" class=3D"styled-by-prettify">return</span> obj<span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span> <span style=3D"colo=
r: #660;" class=3D"styled-by-prettify">}</span><br class=3D""><br class=3D"=
"></code></div></div></div></div></blockquote><div><br class=3D""></div><di=
v>There=E2=80=99s no need to make a copy if the argument is already an rval=
ue.</div><div><br class=3D""></div><div><font face=3D"Courier" class=3D"">t=
emplate&lt; typename t &gt;</font></div><div><font face=3D"Courier" class=
=3D"">t std::value( t v ) { return std::move( v ); }</font></div><div><br c=
lass=3D""></div><div>or more efficiently:</div><div><br class=3D""></div><d=
iv><div><font face=3D"Courier" class=3D"">template&lt; typename t &gt;</fon=
t></div><div><font face=3D"Courier" class=3D"">t std::value( t const &amp; =
v ) { return v; }</font></div><div><span style=3D"font-family: Courier;" cl=
ass=3D"">template&lt; typename t &gt;</span></div><div><div><font face=3D"C=
ourier" class=3D"">t &amp;&amp; std::value( t &amp;&amp; v ) { return std::=
move( v ); }</font></div></div></div></div></body></html>

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

--Apple-Mail=_14E57F14-4CFF-4C49-B965-D8C77F28C078--

.


Author: "'Matt Calabrese' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Sun, 5 Apr 2015 20:49:09 -0700
Raw View
--047d7b41ce5a35fc810513062ec0
Content-Type: text/plain; charset=UTF-8

On Sun, Apr 5, 2015 at 6:22 AM, David Krauss <potswa@gmail.com> wrote:

> or more efficiently:
>
> template< typename t >
> t std::value( t const & v ) { return v; }
> template< typename t >
> t && std::value( t && v ) { return std::move( v ); }
>

If it were a library function, my vote would be to just have a single
overload
for t&& and perfect forward to the constructor of std::decay_t<t>. I really
like
the "auto" suggestion that Zhihao Yuan presented best, though, assuming
there aren't any ambiguities if it were to be adopted. The operation would
probably be equivalent to that of the suggested std::value implementation.

--

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

--047d7b41ce5a35fc810513062ec0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On S=
un, Apr 5, 2015 at 6:22 AM, David Krauss <span dir=3D"ltr">&lt;<a href=3D"m=
ailto:potswa@gmail.com" target=3D"_blank">potswa@gmail.com</a>&gt;</span> w=
rote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8e=
x;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-styl=
e:solid;padding-left:1ex"><div style=3D"word-wrap:break-word"><div>or more =
efficiently:<br></div><div><br></div><div><div><font face=3D"Courier">templ=
ate&lt; typename t &gt;</font></div><div><font face=3D"Courier">t std::valu=
e( t const &amp; v ) { return v; }</font></div><div><span style=3D"font-fam=
ily:Courier">template&lt; typename t &gt;</span></div><div><div><font face=
=3D"Courier">t &amp;&amp; std::value( t &amp;&amp; v ) { return std::move( =
v ); }</font></div></div></div></div></blockquote></div><br></div><div clas=
s=3D"gmail_extra">If it were a library function, my vote would be to just h=
ave a single overload</div><div class=3D"gmail_extra">for t&amp;&amp; and p=
erfect forward to the constructor of std::decay_t&lt;t&gt;. I really like</=
div><div class=3D"gmail_extra">the &quot;auto&quot; suggestion that=C2=A0<s=
pan name=3D"Zhihao Yuan" class=3D"" style=3D"font-size:12.8000001907349px">=
Zhihao Yuan<span style=3D"white-space:nowrap">=C2=A0presented best,=C2=A0</=
span></span><span style=3D"white-space:nowrap;font-size:12.8000001907349px"=
>though,=C2=A0</span><span style=3D"font-size:12.8000001907349px;white-spac=
e:nowrap">assuming</span></div><div class=3D"gmail_extra"><span style=3D"fo=
nt-size:12.8000001907349px;white-space:nowrap">there aren&#39;t any ambigui=
ties if it were to be adopted. The operation would</span></div><div class=
=3D"gmail_extra"><span style=3D"font-size:12.8000001907349px;white-space:no=
wrap">probably be equivalent to that of the suggested std::value implementa=
tion.</span></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 />

--047d7b41ce5a35fc810513062ec0--

.


Author: David Krauss <potswa@gmail.com>
Date: Mon, 6 Apr 2015 11:59:49 +0800
Raw View
--Apple-Mail=_3D488A44-A4CB-4697-A5FF-456FEF47E81C
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2015=E2=80=9304=E2=80=9306, at 11:49 AM, 'Matt Calabrese' via ISO C++ =
Standard - Future Proposals <std-proposals@isocpp.org> wrote:
>=20
> On Sun, Apr 5, 2015 at 6:22 AM, David Krauss <potswa@gmail.com <mailto:po=
tswa@gmail.com>> wrote:
> or more efficiently:
>=20
> template< typename t >
> t std::value( t const & v ) { return v; }
> template< typename t >
> t && std::value( t && v ) { return std::move( v ); }
>=20
> If it were a library function, my vote would be to just have a single ove=
rload
> for t&& and perfect forward to the constructor of std::decay_t<t>.

I didn=E2=80=99t test that code, don=E2=80=99t know if it even works. Imple=
mentation details are covered by the as-if rule.

> I really like
> the "auto" suggestion that Zhihao Yuan presented best, though, assuming
> there aren't any ambiguities if it were to be adopted. The operation woul=
d
> probably be equivalent to that of the suggested std::value implementation=
..

Casting a prvalue to its own type produces a copy. Elision usually applies,=
 but movability is still required. Casting an xvalue to its own type produc=
es a move-construction onto the stack, which usually can=E2=80=99t be elide=
d. So, the library solution is more efficient and has fewer constraints.

As for the syntax, auto(foo) will be esoteric to the uninitiated. And being=
 an overload of a core language keyword, it=E2=80=99s harder to look up the=
 =E2=80=9Cdefinition=E2=80=9D than a library function.

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

--Apple-Mail=_3D488A44-A4CB-4697-A5FF-456FEF47E81C
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9304=
=E2=80=9306, at 11:49 AM, 'Matt Calabrese' via ISO C++ Standard - Future Pr=
oposals &lt;<a href=3D"mailto:std-proposals@isocpp.org" class=3D"">std-prop=
osals@isocpp.org</a>&gt; wrote:</div><br class=3D"Apple-interchange-newline=
"><div class=3D""><div dir=3D"ltr" class=3D""><div class=3D"gmail_extra"><d=
iv class=3D"gmail_quote">On Sun, Apr 5, 2015 at 6:22 AM, David Krauss <span=
 dir=3D"ltr" class=3D"">&lt;<a href=3D"mailto:potswa@gmail.com" target=3D"_=
blank" class=3D"">potswa@gmail.com</a>&gt;</span> wrote:<br class=3D""><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left=
-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;paddi=
ng-left:1ex"><div style=3D"word-wrap:break-word" class=3D""><div class=3D""=
>or more efficiently:<br class=3D""></div><div class=3D""><br class=3D""></=
div><div class=3D""><div class=3D""><font face=3D"Courier" class=3D"">templ=
ate&lt; typename t &gt;</font></div><div class=3D""><font face=3D"Courier" =
class=3D"">t std::value( t const &amp; v ) { return v; }</font></div><div c=
lass=3D""><span style=3D"font-family:Courier" class=3D"">template&lt; typen=
ame t &gt;</span></div><div class=3D""><div class=3D""><font face=3D"Courie=
r" class=3D"">t &amp;&amp; std::value( t &amp;&amp; v ) { return std::move(=
 v ); }</font></div></div></div></div></blockquote></div><br class=3D""></d=
iv><div class=3D"gmail_extra">If it were a library function, my vote would =
be to just have a single overload</div><div class=3D"gmail_extra">for t&amp=
;&amp; and perfect forward to the constructor of std::decay_t&lt;t&gt;. </d=
iv></div></div></blockquote><div><br class=3D""></div><div>I didn=E2=80=99t=
 test that code, don=E2=80=99t know if it even works. Implementation detail=
s are covered by the as-if rule.</div><br class=3D""><blockquote type=3D"ci=
te" class=3D""><div class=3D""><div dir=3D"ltr" class=3D""><div class=3D"gm=
ail_extra">I really like</div><div class=3D"gmail_extra">the "auto" suggest=
ion that&nbsp;<span name=3D"Zhihao Yuan" class=3D"" style=3D"font-size:12.8=
000001907349px">Zhihao Yuan<span style=3D"white-space:nowrap" class=3D"">&n=
bsp;presented best,&nbsp;</span></span><span style=3D"white-space:nowrap;fo=
nt-size:12.8000001907349px" class=3D"">though,&nbsp;</span><span style=3D"f=
ont-size:12.8000001907349px;white-space:nowrap" class=3D"">assuming</span><=
/div><div class=3D"gmail_extra"><span style=3D"font-size:12.8000001907349px=
;white-space:nowrap" class=3D"">there aren't any ambiguities if it were to =
be adopted. The operation would</span></div><div class=3D"gmail_extra"><spa=
n style=3D"font-size:12.8000001907349px;white-space:nowrap" class=3D"">prob=
ably be equivalent to that of the suggested std::value implementation.</spa=
n></div></div></div></blockquote><div><br class=3D""></div></div>Casting a =
prvalue to its own type produces a copy. Elision usually applies, but movab=
ility is still required. Casting an xvalue to its own type produces a move-=
construction onto the stack, which usually can=E2=80=99t be elided. So, the=
 library solution is more efficient and has fewer constraints.<div class=3D=
""><br class=3D""></div><div class=3D"">As for the syntax, <font face=3D"Co=
urier" class=3D"">auto(foo)</font> will be esoteric to the uninitiated. And=
 being an overload of a core language keyword, it=E2=80=99s harder to look =
up the =E2=80=9Cdefinition=E2=80=9D than a library function.</div></body></=
html>

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

--Apple-Mail=_3D488A44-A4CB-4697-A5FF-456FEF47E81C--

.


Author: "'Matt Calabrese' via ISO C++ Standard - Future Proposals" <std-proposals@isocpp.org>
Date: Sun, 5 Apr 2015 21:38:07 -0700
Raw View
--047d7b41ce5a544b74051306ddbe
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Sun, Apr 5, 2015 at 8:59 PM, David Krauss <potswa@gmail.com> wrote:

>
> On 2015=E2=80=9304=E2=80=9306, at 11:49 AM, 'Matt Calabrese' via ISO C++ =
Standard - Future
> Proposals <std-proposals@isocpp.org> wrote:
>
> On Sun, Apr 5, 2015 at 6:22 AM, David Krauss <potswa@gmail.com> wrote:
>
>> or more efficiently:
>>
>> template< typename t >
>> t std::value( t const & v ) { return v; }
>> template< typename t >
>> t && std::value( t && v ) { return std::move( v ); }
>>
>
> If it were a library function, my vote would be to just have a single
> overload
> for t&& and perfect forward to the constructor of std::decay_t<t>.
>
>
> I didn=E2=80=99t test that code, don=E2=80=99t know if it even works. Imp=
lementation
> details are covered by the as-if rule.
>

It wouldn't be an implementation detail. The alternate that I suggest would
have different behavior, both because of overload resolution and because of
the differing return type and constraints. IMO the perfect-forwarding
version is more likely to be what the user actually wants since it always
yields an object type and always perfectly forwards construction. It's hard
to really say one way or the other which would be best though, as the
choice could affect the ways in which people use the function in subtle
ways, beyond the function's requirements and elision.

Also, unstated but likely assumed by both of us: this would be constexpr
and have an automatically deduced exception specification.

Casting a prvalue to its own type produces a copy. Elision usually applies,
> but movability is still required. Casting an xvalue to its own type
> produces a move-construction onto the stack, which usually can=E2=80=99t =
be elided.
> So, the library solution is more efficient and has fewer constraints.
>

Without a variety of use-cases, I'd still lean more towards the version
that does not forward the reference. In other words it really should just
be a short-hand for the cast but without having to explicitly state the
type.

As for the syntax, auto(foo) will be esoteric to the uninitiated.
>

Possibly, although I'm not entirely sure it's that odd. I'd never seen the
syntax in that context before it was suggested and I knew what was intended
(you probably did too?). I think it's fairly reasonable and natural. In
retrospect, I still personally might favor the library definition anyway,
simply based on the principle of preferring library solutions over language
solutions when equivalent, so I guess that's moot.

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

--047d7b41ce5a544b74051306ddbe
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On S=
un, Apr 5, 2015 at 8:59 PM, David Krauss <span dir=3D"ltr">&lt;<a href=3D"m=
ailto:potswa@gmail.com" target=3D"_blank">potswa@gmail.com</a>&gt;</span> w=
rote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;borde=
r-left:1px #ccc solid;padding-left:1ex"><div style=3D"word-wrap:break-word"=
><br><div><span class=3D""><blockquote type=3D"cite"><div>On 2015=E2=80=930=
4=E2=80=9306, at 11:49 AM, &#39;Matt Calabrese&#39; via ISO C++ Standard - =
Future Proposals &lt;<a href=3D"mailto:std-proposals@isocpp.org" target=3D"=
_blank">std-proposals@isocpp.org</a>&gt; wrote:</div><br><div><div dir=3D"l=
tr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On Sun, Apr 5, 20=
15 at 6:22 AM, David Krauss <span dir=3D"ltr">&lt;<a href=3D"mailto:potswa@=
gmail.com" target=3D"_blank">potswa@gmail.com</a>&gt;</span> wrote:<br><blo=
ckquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left=
-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;paddi=
ng-left:1ex"><div style=3D"word-wrap:break-word"><div>or more efficiently:<=
br></div><div><br></div><div><div><font face=3D"Courier">template&lt; typen=
ame t &gt;</font></div><div><font face=3D"Courier">t std::value( t const &a=
mp; v ) { return v; }</font></div><div><span style=3D"font-family:Courier">=
template&lt; typename t &gt;</span></div><div><div><font face=3D"Courier">t=
 &amp;&amp; std::value( t &amp;&amp; v ) { return std::move( v ); }</font><=
/div></div></div></div></blockquote></div><br></div><div class=3D"gmail_ext=
ra">If it were a library function, my vote would be to just have a single o=
verload</div><div class=3D"gmail_extra">for t&amp;&amp; and perfect forward=
 to the constructor of std::decay_t&lt;t&gt;. </div></div></div></blockquot=
e><div><br></div></span><div>I didn=E2=80=99t test that code, don=E2=80=99t=
 know if it even works. Implementation details are covered by the as-if rul=
e.</div></div></div></blockquote><div><br></div><div>It wouldn&#39;t be an =
implementation detail. The alternate that I suggest would have different be=
havior, both because of overload resolution and because of the differing re=
turn type and constraints. IMO the perfect-forwarding version is more likel=
y to be what the user actually wants since it always yields an object type =
and always perfectly forwards construction. It&#39;s hard to really say one=
 way or the other which would be best though, as the choice could affect th=
e ways in which people use the function in subtle ways, beyond the function=
&#39;s requirements and elision.</div><div><br></div><div>Also, unstated bu=
t likely assumed by both of us: this would be constexpr and have an automat=
ically deduced exception specification.</div><div><br></div><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pa=
dding-left:1ex"><div style=3D"word-wrap:break-word"><div><span class=3D""><=
div>Casting a prvalue to its own type produces a copy. Elision usually appl=
ies, but movability is still required. Casting an xvalue to its own type pr=
oduces a move-construction onto the stack, which usually can=E2=80=99t be e=
lided. So, the library solution is more efficient and has fewer constraints=
..</div></span></div></div></blockquote><div><br></div><div>Without a variet=
y of use-cases, I&#39;d still lean more towards the version that does not f=
orward the reference. In other words it really should just be a short-hand =
for the cast but without having to explicitly state the type.</div><div><br=
></div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-=
left:1px #ccc solid;padding-left:1ex"><div style=3D"word-wrap:break-word"><=
div></div><div>As for the syntax, <font face=3D"Courier">auto(foo)</font> w=
ill be esoteric to the uninitiated.</div></div></blockquote><div><br></div>=
<div>Possibly, although I&#39;m not entirely sure it&#39;s that odd. I&#39;=
d never seen the syntax in that context before it was suggested and I knew =
what was intended (you probably did too?). I think it&#39;s fairly reasonab=
le and natural. In retrospect, I still personally might favor the library d=
efinition anyway, simply based on the principle of preferring library solut=
ions over language solutions when equivalent, so I guess that&#39;s moot.</=
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&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 />

--047d7b41ce5a544b74051306ddbe--

.


Author: David Krauss <potswa@gmail.com>
Date: Mon, 6 Apr 2015 13:06:16 +0800
Raw View
--Apple-Mail=_F9D14514-55A5-405C-B639-8D5A68BB625A
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8


> On 2015=E2=80=9304=E2=80=9306, at 12:38 PM, 'Matt Calabrese' via ISO C++ =
Standard - Future Proposals <std-proposals@isocpp.org> wrote:
>=20
> It wouldn't be an implementation detail. The alternate that I suggest wou=
ld have different behavior,

Then I misunderstood you. Now it=E2=80=99s clear that your suggestion is:

template< typename t >
std::decay_t< t > value( t && v ) { return std::forward< t >( v ); }

This is a more complicated version of the first alternative I mentioned. It=
 has the same unfortunate constraints, because it always move-constructs th=
e result. Note that copy elision will often apply to the parameter value in=
 the simpler version.

> Without a variety of use-cases, I'd still lean more towards the version t=
hat does not forward the reference. In other words it really should just be=
 a short-hand for the cast but without having to explicitly state the type.

Because producing extraneous objects is good somehow?

> As for the syntax, auto(foo) will be esoteric to the uninitiated.
>=20
> Possibly, although I'm not entirely sure it's that odd. I'd never seen th=
e syntax in that context before it was suggested and I knew what was intend=
ed (you probably did too?). I think it's fairly reasonable and natural.

For someone coming from a C background, perhaps.

By the same token, C-style casts may be considered dangerous and obsolescen=
t. Nobody should be forced to use one.

Oh, the C syntax would actually be (auto) foo. Fun.

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

--Apple-Mail=_F9D14514-55A5-405C-B639-8D5A68BB625A
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html; charset=UTF-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html charset=
=3Dutf-8"></head><body style=3D"word-wrap: break-word; -webkit-nbsp-mode: s=
pace; -webkit-line-break: after-white-space;" class=3D""><br class=3D""><di=
v><blockquote type=3D"cite" class=3D""><div class=3D"">On 2015=E2=80=9304=
=E2=80=9306, at 12:38 PM, 'Matt Calabrese' via ISO C++ Standard - Future Pr=
oposals &lt;<a href=3D"mailto:std-proposals@isocpp.org" class=3D"">std-prop=
osals@isocpp.org</a>&gt; wrote:</div><br class=3D"Apple-interchange-newline=
"><div class=3D""><div dir=3D"ltr" style=3D"font-family: Helvetica; font-si=
ze: 12px; font-style: normal; font-variant: normal; font-weight: normal; le=
tter-spacing: normal; line-height: normal; orphans: auto; text-align: start=
; text-indent: 0px; text-transform: none; white-space: normal; widows: auto=
; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D""><div class=
=3D"gmail_extra"><div class=3D"gmail_quote"><div class=3D"">It wouldn't be =
an implementation detail. The alternate that I suggest would have different=
 behavior, </div></div></div></div></div></blockquote><div><br class=3D""><=
/div><div>Then I misunderstood you. Now it=E2=80=99s clear that your sugges=
tion is:</div><div><br class=3D""></div><div><font face=3D"Courier" class=
=3D"">template&lt; typename t &gt;</font></div><div><font face=3D"Courier" =
class=3D"">std::decay_t&lt; t &gt; value( t &amp;&amp; v ) { return std::fo=
rward&lt; t &gt;( v ); }</font></div><div><br class=3D""></div><div>This is=
 a more complicated version of the first alternative I mentioned. It has th=
e same unfortunate constraints, because it always move-constructs the resul=
t. Note that copy elision will often apply to the parameter value in the si=
mpler version.</div><div><br class=3D""></div></div><div><blockquote type=
=3D"cite" class=3D""><div dir=3D"ltr" style=3D"font-family: Helvetica; font=
-size: 12px; font-style: normal; font-variant: normal; font-weight: normal;=
 letter-spacing: normal; line-height: normal; orphans: auto; text-align: st=
art; text-indent: 0px; text-transform: none; white-space: normal; widows: a=
uto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D""><div cl=
ass=3D"gmail_extra"><div class=3D"gmail_quote"><div class=3D"">Without a va=
riety of use-cases, I'd still lean more towards the version that does not f=
orward the reference. In other words it really should just be a short-hand =
for the cast but without having to explicitly state the type.</div></div></=
div></div></blockquote><div><br class=3D""></div><div>Because producing ext=
raneous objects is good somehow?</div><br class=3D""><blockquote type=3D"ci=
te" class=3D""><div dir=3D"ltr" style=3D"font-family: Helvetica; font-size:=
 12px; font-style: normal; font-variant: normal; font-weight: normal; lette=
r-spacing: normal; line-height: normal; orphans: auto; text-align: start; t=
ext-indent: 0px; text-transform: none; white-space: normal; widows: auto; w=
ord-spacing: 0px; -webkit-text-stroke-width: 0px;" class=3D""><div class=3D=
"gmail_extra"><div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" =
style=3D"margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-col=
or: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div =
style=3D"word-wrap: break-word;" class=3D""><div class=3D""></div><div clas=
s=3D"">As for the syntax,<span class=3D"Apple-converted-space">&nbsp;</span=
><font face=3D"Courier" class=3D"">auto(foo)</font><span class=3D"Apple-con=
verted-space">&nbsp;</span>will be esoteric to the uninitiated.</div></div>=
</blockquote><div class=3D""><br class=3D""></div><div class=3D"">Possibly,=
 although I'm not entirely sure it's that odd. I'd never seen the syntax in=
 that context before it was suggested and I knew what was intended (you pro=
bably did too?). I think it's fairly reasonable and natural.</div></div></d=
iv></div></blockquote><div><br class=3D""></div><div>For someone coming fro=
m a C background, perhaps.</div><div><br class=3D""></div><div>By the same =
token, C-style casts may be considered dangerous and obsolescent. Nobody sh=
ould be forced to use one.</div><div><br class=3D""></div><div>Oh, the C sy=
ntax would actually be <font face=3D"Courier" class=3D"">(auto) foo</font>.=
 Fun.</div></div></body></html>

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

--Apple-Mail=_F9D14514-55A5-405C-B639-8D5A68BB625A--

.


Author: Zhihao Yuan <zy@miator.net>
Date: Mon, 6 Apr 2015 01:46:37 -0400
Raw View
On Mon, Apr 6, 2015 at 1:06 AM, David Krauss <potswa@gmail.com> wrote:
>
> Without a variety of use-cases, I'd still lean more towards the version that
> does not forward the reference. In other words it really should just be a
> short-hand for the cast but without having to explicitly state the type.
>
>
> Because producing extraneous objects is good somehow?
>

If you want to forward reference, how about decltype(auto){x} ?

:)

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://bit.ly/blog4bsd

--

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

.


Author: Zhihao Yuan <zy@miator.net>
Date: Mon, 6 Apr 2015 15:46:56 -0400
Raw View
On Mon, Apr 6, 2015 at 1:46 AM, Zhihao Yuan <zy@miator.net> wrote:
>>
>> Because producing extraneous objects is good somehow?
>>
>
> If you want to forward reference, how about decltype(auto){x} ?
>

Hmm, decltype(auto) seems useless in this context, since you
probably don't want to forward lvalue reference.  However,
considering auto(x)'s usecase is pretty clear (DECAY_COPY
in the standard[1]), it may worth to be standardized.

Compared with a library addition, I see 2 advantages of auto(x):

 1. elision instead of move when the input is prvalue
 2. no more noexcept debate; you get it for free.

The syntax auto{x} might be treated as an benefit, too.

[1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3255.html

--
Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
___________________________________________________
4BSD -- http://bit.ly/blog4bsd

--

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

.