Topic: Catch by rvalue reference
Author: wasti.redl@gmx.net
Date: Mon, 16 Mar 2009 03:02:43 CST Raw View
Hi,
C++0x (N2800) [except.handle]p3 says:
"A handler is a match for an exception object of type E if
- The handler is of type cv T or cv T& and E and T are the same type
(ignoring the top-level cv-qualifiers), or
..."
Note that this does not allow catch by rvalue reference to succeed,
i.e.
try { ... } catch(T&& t) { /* cannot be used */ }
Intentional or oversight? If intentional, shouldn't it be an ill-
formed program instead?
Sebastian
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: doug.gregor@gmail.com
Date: Tue, 17 Mar 2009 14:47:18 CST Raw View
On Mar 16, 2:02 am, wasti.r...@gmx.net wrote:
> Hi,
>
> C++0x (N2800) [except.handle]p3 says:
>
> "A handler is a match for an exception object of type E if
> - The handler is of type cv T or cv T& and E and T are the same type
> (ignoring the top-level cv-qualifiers), or
> ..."
>
> Note that this does not allow catch by rvalue reference to succeed,
> i.e.
>
> try { ... } catch(T&& t) { /* cannot be used */ }
>
> Intentional or oversight? If intentional, shouldn't it be an ill-
> formed program instead?
I believe it was originally an oversight. However, this issue was
discussed at the most recent C++ committee meeting, as part of the
discussion of N2831, a change that prevents rvalue references from
binding to lvalues. This paper effectively made rvalue-reference
handlers useless, since they would never be able to bind to a thrown
exception (which is an lvalue). Therefore, the core working group
decided to make rvalue-reference handlers ill-formed. The change is
part of N2844 (the successor to N2831), which was voted into the
working paper and will appear in the post-Summit mailing.
- Doug
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]