Created on 2017-01-17.00:00:00 last changed 89 months ago
Proposed resolution:
This wording is relative to N4618.
Edit [except.nested] as indicated:
template <class T> [[noreturn]] void throw_with_nested(T&& t);-6- Let U be
-7- Requires: U shall be CopyConstructible.remove_referencedecay_t<T>.
[ 2017-01-27 Telecon ]
Priority 0
[except.nested] says:
template <class T> [[noreturn]] void throw_with_nested(T&& t);Let U be remove_reference_t<T>.
Requires: U shall be CopyConstructible.
This forbids std::throw_with_nested("string literal") because T gets deduced as const char(&)[15] and so U is const char[15] which is not CopyConstructible.
A throw expression decays an array argument to a pointer ([expr.throw] p2) and so works fine with string literals. GCC's throw_with_nested also worked fine until I added a static_assert to enforce the CopyConstructible requirement. The same problem exists when throwing a function type, which should also decay:#include <exception> void f() { } int main() { std::throw_with_nested(f); }
(Note: LWG 1370 added the remove_reference, which was a step in the right direction but not far enough.)
History | |||
---|---|---|---|
Date | User | Action | Args |
2017-07-30 20:15:43 | admin | set | status: wp -> c++17 |
2017-03-05 23:41:16 | admin | set | status: ready -> wp |
2017-01-30 15:36:02 | admin | set | messages: + msg8831 |
2017-01-30 15:36:02 | admin | set | status: new -> ready |
2017-01-25 20:14:53 | admin | set | messages: + msg8789 |
2017-01-17 00:00:00 | admin | create |