Difference between revisions of "cpp/error/exception/exception"
From cppreference.com
m (Text replace - "{{noexcept" to "{{unreviewed noexcept") |
(The standard says std::exception's default constructor returns an implementation-defined string, not an empty string. Indeed, gcc's std::exception{}.what() returns "std::exception") |
||
Line 12: | Line 12: | ||
Constructs new exception object. | Constructs new exception object. | ||
− | @1@ Default constructor. {{ltf|cpp/error/exception/what}} returns | + | @1@ Default constructor. {{ltf|cpp/error/exception/what}} returns an implementation-defined string. |
@2@ Copy constructor. Initializes the contents with those of {{tt|other}} | @2@ Copy constructor. Initializes the contents with those of {{tt|other}} |
Revision as of 12:11, 19 November 2018
exception(); |
(1) | |
exception( const exception& other ); |
(2) | |
Constructs new exception object.
1) Default constructor. what() returns an implementation-defined string.
2) Copy constructor. Initializes the contents with those of
other
Parameters
other | - | another exception to assign the contents of |
Exceptions
(none) | (until C++11) |
noexcept specification: noexcept |
(since C++11) |
Notes
Because copying std::exception
is not permitted to throw exceptions, when derived classes (such as std::runtime_error) have to manage a user-defined diagnostic message, it is typically implemented as a copy-on-write string.