CARVIEW |
Select Language
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 21 Jul 2025 09:46:02 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
ETag: W/"83d6-J+rsl0y0dqRdfgLwZB1Lt0OBIOQ"
Content-Encoding: gzip
Base class for standard exceptions.
All objects thrown by components of the standard library are derived from this class. Therefore, all standard exceptions can be caught by catching this type by reference.
It is declared as:
Indirectly (through logic_error):
Indirectly (through runtime_error):
Indirectly (through bad_alloc):
Indirectly (through system_error, since C++11):
Possible output:
Reference
C library:
- <cassert> (assert.h)
- <cctype> (ctype.h)
- <cerrno> (errno.h)
-
<cfenv> (fenv.h)C++11
- <cfloat> (float.h)
-
<cinttypes> (inttypes.h)C++11
- <ciso646> (iso646.h)
- <climits> (limits.h)
- <clocale> (locale.h)
- <cmath> (math.h)
- <csetjmp> (setjmp.h)
- <csignal> (signal.h)
- <cstdarg> (stdarg.h)
-
<cstdbool> (stdbool.h)C++11
- <cstddef> (stddef.h)
-
<cstdint> (stdint.h)C++11
- <cstdio> (stdio.h)
- <cstdlib> (stdlib.h)
- <cstring> (string.h)
-
<ctgmath> (tgmath.h)C++11
- <ctime> (time.h)
-
<cuchar> (uchar.h)C++11
- <cwchar> (wchar.h)
- <cwctype> (wctype.h)
Containers:
-
<array>C++11
- <deque>
-
<forward_list>C++11
- <list>
- <map>
- <queue>
- <set>
- <stack>
-
<unordered_map>C++11
-
<unordered_set>C++11
- <vector>
-
Input/Output:
Multi-threading:
-
<atomic>C++11
-
<condition_variable>C++11
-
<future>C++11
-
<mutex>C++11
-
<thread>C++11
-
Other:
- <algorithm>
- <bitset>
-
<chrono>C++11
-
<codecvt>C++11
- <complex>
- <exception>
- <functional>
-
<initializer_list>C++11
- <iterator>
- <limits>
- <locale>
- <memory>
- <new>
- <numeric>
-
<random>C++11
-
<ratio>C++11
-
<regex>C++11
- <stdexcept>
- <string>
-
<system_error>C++11
-
<tuple>C++11
-
<type_traits>C++11
-
<typeindex>C++11
- <typeinfo>
- <utility>
- <valarray>
<exception>
functions
-
current_exceptionC++11
-
get_terminateC++11
-
get_unexpectedC++11
-
make_exception_ptrC++11
-
rethrow_exceptionC++11
-
rethrow_if_nestedC++11
- set_terminate
- set_unexpected
- terminate
-
throw_with_nestedC++11
- uncaught_exception
- unexpected
-
types
exception
member functions
virtual member functions
- Reference
- <exception>
- exception
class
<exception>
std::exception
class exception;
Standard exception class
All objects thrown by components of the standard library are derived from this class. Therefore, all standard exceptions can be caught by catching this type by reference.
It is declared as:
|
|
|
|
Member functions
- (constructor)
- Construct exception (public member function)
- operator=
- Copy exception (public member function)
- what (virtual)
- Get string identifying exception (public member function)
- (destructor) (virtual)
- Destroy exception (public virtual member function)
Derived types (scattered throughout different library headers)
- bad_alloc
- Exception thrown on failure allocating memory (class)
- bad_cast
- Exception thrown on failure to dynamic cast (class)
- bad_exception
- Exception thrown by unexpected handler (class)
- bad_function_call
- Exception thrown on bad call (class)
- bad_typeid
- Exception thrown on typeid of null pointer (class)
- bad_weak_ptr
- Bad weak pointer (class)
- ios_base::failure
- Base class for stream exceptions (public member class)
- logic_error
- Logic error exception (class)
- runtime_error
- Runtime error exception (class)
Indirectly (through logic_error):
- domain_error
- Domain error exception (class)
- future_error
- Future error exception (class)
- invalid_argument
- Invalid argument exception (class)
- length_error
- Length error exception (class)
- out_of_range
- Out-of-range exception (class)
Indirectly (through runtime_error):
- overflow_error
- Overflow error exception (class)
- range_error
- Range error exception (class)
- system_error
- System error exception (class)
- underflow_error
- Underflow error exception (class)
Indirectly (through bad_alloc):
- bad_array_new_length
- Exception on bad array length (class)
Indirectly (through system_error, since C++11):
- ios_base::failure
- Base class for stream exceptions (public member class)
Example
|
|
Possible output:
exception caught: St10bad_typeid |
Home page | Privacy policy
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us
© cplusplus.com, 2000-2025 - All rights reserved - v3.3.4s
Spotted an error? contact us