In §[except.throw]
, the standard says that throwing an exception copy-initializes the exception object from the throw expression
Throwing an exception copy-initializes (11.6, 15.8) a temporary object, called the exception object
Why then does the following code compile on C++17?
class Exception {
public:
Exception() = default;
Exception(Exception&&) = delete;
Exception(const Exception&) = delete;
};
int main() {
throw Exception{};
return 0;
}
(https://wandbox.org/permlink/R3WfzfnBAORTLVSy)
Copy initialization does not include any case (from what it seems like to me) that is eligible for prvalue elision. Why then does the above code compile in C++17?