2 //===--------------------------- stdexcept --------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_STDEXCEPT
12 #define _LIBCPP_STDEXCEPT
22 class invalid_argument;
28 class underflow_error;
30 for each class xxx_error:
32 class xxx_error : public exception // at least indirectly
35 explicit xxx_error(const string& what_arg);
36 explicit xxx_error(const char* what_arg);
38 virtual const char* what() const noexcept // returns what_arg
47 #include <iosfwd> // for string forward decl
49 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
50 #pragma GCC system_header
53 #ifndef _LIBCPP___REFSTRING
54 _LIBCPP_BEGIN_NAMESPACE_STD
55 class _LIBCPP_HIDDEN __libcpp_refstring {
57 const char *__imp_ __attribute__((__unused__)); // only clang emits a warning
62 _LIBCPP_END_NAMESPACE_STD
65 namespace std // purposefully not using versioning namespace
68 class _LIBCPP_EXCEPTION_ABI logic_error
72 _VSTD::__libcpp_refstring __imp_;
74 explicit logic_error(const string&);
75 explicit logic_error(const char*);
77 logic_error(const logic_error&) _NOEXCEPT;
78 logic_error& operator=(const logic_error&) _NOEXCEPT;
80 virtual ~logic_error() _NOEXCEPT;
82 virtual const char* what() const _NOEXCEPT;
85 class _LIBCPP_EXCEPTION_ABI runtime_error
89 _VSTD::__libcpp_refstring __imp_;
91 explicit runtime_error(const string&);
92 explicit runtime_error(const char*);
94 runtime_error(const runtime_error&) _NOEXCEPT;
95 runtime_error& operator=(const runtime_error&) _NOEXCEPT;
97 virtual ~runtime_error() _NOEXCEPT;
99 virtual const char* what() const _NOEXCEPT;
102 class _LIBCPP_EXCEPTION_ABI domain_error
106 _LIBCPP_INLINE_VISIBILITY explicit domain_error(const string& __s) : logic_error(__s) {}
107 _LIBCPP_INLINE_VISIBILITY explicit domain_error(const char* __s) : logic_error(__s) {}
109 virtual ~domain_error() _NOEXCEPT;
112 class _LIBCPP_EXCEPTION_ABI invalid_argument
116 _LIBCPP_INLINE_VISIBILITY explicit invalid_argument(const string& __s) : logic_error(__s) {}
117 _LIBCPP_INLINE_VISIBILITY explicit invalid_argument(const char* __s) : logic_error(__s) {}
119 virtual ~invalid_argument() _NOEXCEPT;
122 class _LIBCPP_EXCEPTION_ABI length_error
126 _LIBCPP_INLINE_VISIBILITY explicit length_error(const string& __s) : logic_error(__s) {}
127 _LIBCPP_INLINE_VISIBILITY explicit length_error(const char* __s) : logic_error(__s) {}
129 virtual ~length_error() _NOEXCEPT;
132 class _LIBCPP_EXCEPTION_ABI out_of_range
136 _LIBCPP_INLINE_VISIBILITY explicit out_of_range(const string& __s) : logic_error(__s) {}
137 _LIBCPP_INLINE_VISIBILITY explicit out_of_range(const char* __s) : logic_error(__s) {}
139 virtual ~out_of_range() _NOEXCEPT;
142 class _LIBCPP_EXCEPTION_ABI range_error
143 : public runtime_error
146 _LIBCPP_INLINE_VISIBILITY explicit range_error(const string& __s) : runtime_error(__s) {}
147 _LIBCPP_INLINE_VISIBILITY explicit range_error(const char* __s) : runtime_error(__s) {}
149 virtual ~range_error() _NOEXCEPT;
152 class _LIBCPP_EXCEPTION_ABI overflow_error
153 : public runtime_error
156 _LIBCPP_INLINE_VISIBILITY explicit overflow_error(const string& __s) : runtime_error(__s) {}
157 _LIBCPP_INLINE_VISIBILITY explicit overflow_error(const char* __s) : runtime_error(__s) {}
159 virtual ~overflow_error() _NOEXCEPT;
162 class _LIBCPP_EXCEPTION_ABI underflow_error
163 : public runtime_error
166 _LIBCPP_INLINE_VISIBILITY explicit underflow_error(const string& __s) : runtime_error(__s) {}
167 _LIBCPP_INLINE_VISIBILITY explicit underflow_error(const char* __s) : runtime_error(__s) {}
169 virtual ~underflow_error() _NOEXCEPT;
174 #endif // _LIBCPP_STDEXCEPT