1370. throw_with_nested should not use perfect forwarding

Section: 17.9.8 [except.nested] Status: C++11 Submitter: INCITS Opened: 2010-08-25 Last modified: 2016-01-28 10:19:27 UTC

Priority: Not Prioritized

View all other issues in [except.nested].

View all issues with C++11 status.


Addresses US-84

The throw_with_nested specification passes in its argument as T&& (perfect forwarding pattern), but then discusses requirements on T without taking into account that T may be an lvalue-reference type. It is also not clear in the spec that t is intended to be perfectly forwarded.

[ Resolution proposed by ballot comment ]

Patch [except.nested] p6-7 to match the intent with regards to requirements on T and the use of std::forward<T>(t).

[ 2010-10-24 Daniel adds: ]

Accepting n3144 would solve this issue.

[2010-11-10 Batavia: LWG accepts Howard's updated wording with corrected boo boos reported by Sebastian Gesemann and Pete Becker, which is approved for Immediate adoption this meeting.]

[ Adopted at 2010-11 Batavia ]

Proposed resolution:

Change 18.8.7 nested_exception [except.nested] as indicated:

[[noreturn]] template <class T> void throw_with_nested(T&& t);

Let U be remove_reference<T>::type

6 Requires: T U shall be CopyConstructible.

7 Throws: If T U is a non-union class type not derived from nested_exception, an exception of unspecified type that is publicly derived from both T U and nested_exception and constructed from std::forward<T>(t), otherwise throws std::forward<T>(t).