Topic: R-value references Status & Syntax
Author: "royalstream" <royalstream@gmail.com>
Date: Tue, 2 Jan 2007 16:26:00 CST Raw View
Thanks for the info.
I agree the keyword may be confused with a cv-qualifier, but I also
think most C++ programmers would have gotten the point. Besides you end
up with hard-to-explain combinations like (const T&&) plus the tempting
reference-to-reference interpretation.
But if they already settled on it, there's no point complaining I
guess. People with several years of C++ experience will not get
confused regardless of the syntax chosen. It's the new adopters I was
worried about.
Steven
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: royalstream@gmail.com
Date: Mon, 1 Jan 2007 13:24:55 CST Raw View
I have a few basic questions (perhaps too basic) regarding the r-value
reference proposal.
1. What is the current status of this proposal regarding the C++09
standard? Is it going to make it into the language?
2. On the articles and whitepapers I've read so far, I have not
encountered any single code snippet with a const r-value reference
(const T&&) and I was wondering if there are scenarios where you could
want that and how often.
3. The reason for the previous question is that maybe there could be a
better syntax for the r-value reference than (T&&), in particular for
new adopters who may interpret this to be a reference to a reference,
just like (T**) is a pointer to a pointer. Something along the lines of
(keyword T&) might do it, where "keyword" is a keyword yet to be
decided:
struct Wee
{
Wee(const Wee&); // copy semantics
Wee(keyword Wee&); // move semantics
};
The rationale behind it is that r-value references behave differently
but they are still references. However, if they could be const then
(const keyword T&) is not that good looking.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: Howard Hinnant <howard.hinnant@gmail.com>
Date: Tue, 2 Jan 2007 08:59:43 CST Raw View
In article <1167665390.245010.115710@48g2000cwx.googlegroups.com>,
royalstream@gmail.com wrote:
> I have a few basic questions (perhaps too basic) regarding the r-value
> reference proposal.
>
> 1. What is the current status of this proposal regarding the C++09
> standard? Is it going to make it into the language?
The language part (N2118) has been voted into the working draft for
C++0X (N2135). The library part is on the LWG's agenda.
> 2. On the articles and whitepapers I've read so far, I have not
> encountered any single code snippet with a const r-value reference
> (const T&&) and I was wondering if there are scenarios where you could
> want that and how often.
>
> 3. The reason for the previous question is that maybe there could be a
> better syntax for the r-value reference than (T&&), in particular for
> new adopters who may interpret this to be a reference to a reference,
> just like (T**) is a pointer to a pointer. Something along the lines of
> (keyword T&) might do it, where "keyword" is a keyword yet to be
> decided:
>
> struct Wee
> {
> Wee(const Wee&); // copy semantics
> Wee(keyword Wee&); // move semantics
> };
>
> The rationale behind it is that r-value references behave differently
> but they are still references. However, if they could be const then
> (const keyword T&) is not that good looking.
One can have a rvalue reference to a const-qualified type, although I
currently do not have a good use case for that construct. A keyword was
considered (years ago) but has the downside of being confused with a
cv-qualifier. The lvalue reference and rvalue reference are distinct
types in the type system, both are reference types, and they both can be
references to cv-qualified types.
-Howard
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]