Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- stdexcept --------------------------------===// |
| 3 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 4 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 5 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 6 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 7 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | |
| 11 | #ifndef _LIBCPP_STDEXCEPT |
| 12 | #define _LIBCPP_STDEXCEPT |
| 13 | |
| 14 | /* |
| 15 | stdexcept synopsis |
| 16 | |
| 17 | namespace std |
| 18 | { |
| 19 | |
| 20 | class logic_error; |
| 21 | class domain_error; |
| 22 | class invalid_argument; |
| 23 | class length_error; |
| 24 | class out_of_range; |
| 25 | class runtime_error; |
| 26 | class range_error; |
| 27 | class overflow_error; |
| 28 | class underflow_error; |
| 29 | |
| 30 | for each class xxx_error: |
| 31 | |
| 32 | class xxx_error : public exception // at least indirectly |
| 33 | { |
| 34 | public: |
| 35 | explicit xxx_error(const string& what_arg); |
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 36 | explicit xxx_error(const char* what_arg); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 37 | |
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 38 | virtual const char* what() const noexcept // returns what_arg |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 39 | }; |
| 40 | |
| 41 | } // std |
| 42 | |
| 43 | */ |
| 44 | |
| 45 | #include <__config> |
| 46 | #include <exception> |
| 47 | #include <iosfwd> // for string forward decl |
| 48 | |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 49 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 50 | #pragma GCC system_header |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 51 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 52 | |
| 53 | namespace std // purposefully not using versioning namespace |
| 54 | { |
| 55 | |
| 56 | class _LIBCPP_EXCEPTION_ABI logic_error |
| 57 | : public exception |
| 58 | { |
| 59 | private: |
| 60 | void* __imp_; |
| 61 | public: |
| 62 | explicit logic_error(const string&); |
| 63 | explicit logic_error(const char*); |
| 64 | |
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 65 | logic_error(const logic_error&) _NOEXCEPT; |
| 66 | logic_error& operator=(const logic_error&) _NOEXCEPT; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 67 | |
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 68 | virtual ~logic_error() _NOEXCEPT; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 69 | |
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 70 | virtual const char* what() const _NOEXCEPT; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 71 | }; |
| 72 | |
| 73 | class _LIBCPP_EXCEPTION_ABI runtime_error |
| 74 | : public exception |
| 75 | { |
| 76 | private: |
| 77 | void* __imp_; |
| 78 | public: |
| 79 | explicit runtime_error(const string&); |
| 80 | explicit runtime_error(const char*); |
| 81 | |
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 82 | runtime_error(const runtime_error&) _NOEXCEPT; |
| 83 | runtime_error& operator=(const runtime_error&) _NOEXCEPT; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 84 | |
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 85 | virtual ~runtime_error() _NOEXCEPT; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 86 | |
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 87 | virtual const char* what() const _NOEXCEPT; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 88 | }; |
| 89 | |
| 90 | class _LIBCPP_EXCEPTION_ABI domain_error |
| 91 | : public logic_error |
| 92 | { |
| 93 | public: |
| 94 | _LIBCPP_INLINE_VISIBILITY explicit domain_error(const string& __s) : logic_error(__s) {} |
| 95 | _LIBCPP_INLINE_VISIBILITY explicit domain_error(const char* __s) : logic_error(__s) {} |
| 96 | |
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 97 | virtual ~domain_error() _NOEXCEPT; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 98 | }; |
| 99 | |
| 100 | class _LIBCPP_EXCEPTION_ABI invalid_argument |
| 101 | : public logic_error |
| 102 | { |
| 103 | public: |
| 104 | _LIBCPP_INLINE_VISIBILITY explicit invalid_argument(const string& __s) : logic_error(__s) {} |
| 105 | _LIBCPP_INLINE_VISIBILITY explicit invalid_argument(const char* __s) : logic_error(__s) {} |
| 106 | |
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 107 | virtual ~invalid_argument() _NOEXCEPT; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | class _LIBCPP_EXCEPTION_ABI length_error |
| 111 | : public logic_error |
| 112 | { |
| 113 | public: |
| 114 | _LIBCPP_INLINE_VISIBILITY explicit length_error(const string& __s) : logic_error(__s) {} |
| 115 | _LIBCPP_INLINE_VISIBILITY explicit length_error(const char* __s) : logic_error(__s) {} |
| 116 | |
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 117 | virtual ~length_error() _NOEXCEPT; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 118 | }; |
| 119 | |
| 120 | class _LIBCPP_EXCEPTION_ABI out_of_range |
| 121 | : public logic_error |
| 122 | { |
| 123 | public: |
| 124 | _LIBCPP_INLINE_VISIBILITY explicit out_of_range(const string& __s) : logic_error(__s) {} |
| 125 | _LIBCPP_INLINE_VISIBILITY explicit out_of_range(const char* __s) : logic_error(__s) {} |
| 126 | |
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 127 | virtual ~out_of_range() _NOEXCEPT; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 128 | }; |
| 129 | |
| 130 | class _LIBCPP_EXCEPTION_ABI range_error |
| 131 | : public runtime_error |
| 132 | { |
| 133 | public: |
| 134 | _LIBCPP_INLINE_VISIBILITY explicit range_error(const string& __s) : runtime_error(__s) {} |
| 135 | _LIBCPP_INLINE_VISIBILITY explicit range_error(const char* __s) : runtime_error(__s) {} |
| 136 | |
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 137 | virtual ~range_error() _NOEXCEPT; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 138 | }; |
| 139 | |
| 140 | class _LIBCPP_EXCEPTION_ABI overflow_error |
| 141 | : public runtime_error |
| 142 | { |
| 143 | public: |
| 144 | _LIBCPP_INLINE_VISIBILITY explicit overflow_error(const string& __s) : runtime_error(__s) {} |
| 145 | _LIBCPP_INLINE_VISIBILITY explicit overflow_error(const char* __s) : runtime_error(__s) {} |
| 146 | |
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 147 | virtual ~overflow_error() _NOEXCEPT; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 148 | }; |
| 149 | |
| 150 | class _LIBCPP_EXCEPTION_ABI underflow_error |
| 151 | : public runtime_error |
| 152 | { |
| 153 | public: |
| 154 | _LIBCPP_INLINE_VISIBILITY explicit underflow_error(const string& __s) : runtime_error(__s) {} |
| 155 | _LIBCPP_INLINE_VISIBILITY explicit underflow_error(const char* __s) : runtime_error(__s) {} |
| 156 | |
Howard Hinnant | 1e15fd1 | 2011-05-26 19:48:01 +0000 | [diff] [blame] | 157 | virtual ~underflow_error() _NOEXCEPT; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 158 | }; |
| 159 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 160 | } // std |
| 161 | |
| 162 | #endif // _LIBCPP_STDEXCEPT |