blob: f251806fba62f43c1a27a14f3eac9984e7b29b6d [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001// -*- C++ -*-
2//===--------------------------- stdexcept --------------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00005//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00006// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00008//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_STDEXCEPT
12#define _LIBCPP_STDEXCEPT
13
14/*
15 stdexcept synopsis
16
17namespace std
18{
19
20class logic_error;
21 class domain_error;
22 class invalid_argument;
23 class length_error;
24 class out_of_range;
25class runtime_error;
26 class range_error;
27 class overflow_error;
28 class underflow_error;
29
30for each class xxx_error:
31
32class xxx_error : public exception // at least indirectly
33{
34public:
35 explicit xxx_error(const string& what_arg);
Howard Hinnant1e15fd12011-05-26 19:48:01 +000036 explicit xxx_error(const char* what_arg);
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000037
Howard Hinnant1e15fd12011-05-26 19:48:01 +000038 virtual const char* what() const noexcept // returns what_arg
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000039};
40
41} // std
42
43*/
44
45#include <__config>
46#include <exception>
47#include <iosfwd> // for string forward decl
48
Howard Hinnant08e17472011-10-17 20:05:10 +000049#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000050#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10 +000051#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000052
Joerg Sonnenberger55622072014-04-30 19:54:11 +000053#ifndef _LIBCPP___REFSTRING
54_LIBCPP_BEGIN_NAMESPACE_STD
55class _LIBCPP_HIDDEN __libcpp_refstring {
Dan Albert1d4a1ed2016-05-25 22:36:09 -070056 const char *__imp_ _LIBCPP_UNUSED;
Joerg Sonnenberger55622072014-04-30 19:54:11 +000057};
58_LIBCPP_END_NAMESPACE_STD
59#endif
60
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000061namespace std // purposefully not using versioning namespace
62{
63
64class _LIBCPP_EXCEPTION_ABI logic_error
65 : public exception
66{
67private:
Joerg Sonnenberger55622072014-04-30 19:54:11 +000068 _VSTD::__libcpp_refstring __imp_;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000069public:
70 explicit logic_error(const string&);
71 explicit logic_error(const char*);
72
Howard Hinnant1e15fd12011-05-26 19:48:01 +000073 logic_error(const logic_error&) _NOEXCEPT;
74 logic_error& operator=(const logic_error&) _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000075
Howard Hinnant1e15fd12011-05-26 19:48:01 +000076 virtual ~logic_error() _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000077
Howard Hinnant1e15fd12011-05-26 19:48:01 +000078 virtual const char* what() const _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000079};
80
81class _LIBCPP_EXCEPTION_ABI runtime_error
82 : public exception
83{
84private:
Joerg Sonnenberger55622072014-04-30 19:54:11 +000085 _VSTD::__libcpp_refstring __imp_;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000086public:
87 explicit runtime_error(const string&);
88 explicit runtime_error(const char*);
89
Howard Hinnant1e15fd12011-05-26 19:48:01 +000090 runtime_error(const runtime_error&) _NOEXCEPT;
91 runtime_error& operator=(const runtime_error&) _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000092
Howard Hinnant1e15fd12011-05-26 19:48:01 +000093 virtual ~runtime_error() _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000094
Howard Hinnant1e15fd12011-05-26 19:48:01 +000095 virtual const char* what() const _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000096};
97
98class _LIBCPP_EXCEPTION_ABI domain_error
99 : public logic_error
100{
101public:
102 _LIBCPP_INLINE_VISIBILITY explicit domain_error(const string& __s) : logic_error(__s) {}
103 _LIBCPP_INLINE_VISIBILITY explicit domain_error(const char* __s) : logic_error(__s) {}
104
Howard Hinnant1e15fd12011-05-26 19:48:01 +0000105 virtual ~domain_error() _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000106};
107
108class _LIBCPP_EXCEPTION_ABI invalid_argument
109 : public logic_error
110{
111public:
112 _LIBCPP_INLINE_VISIBILITY explicit invalid_argument(const string& __s) : logic_error(__s) {}
113 _LIBCPP_INLINE_VISIBILITY explicit invalid_argument(const char* __s) : logic_error(__s) {}
114
Howard Hinnant1e15fd12011-05-26 19:48:01 +0000115 virtual ~invalid_argument() _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000116};
117
118class _LIBCPP_EXCEPTION_ABI length_error
119 : public logic_error
120{
121public:
122 _LIBCPP_INLINE_VISIBILITY explicit length_error(const string& __s) : logic_error(__s) {}
123 _LIBCPP_INLINE_VISIBILITY explicit length_error(const char* __s) : logic_error(__s) {}
124
Howard Hinnant1e15fd12011-05-26 19:48:01 +0000125 virtual ~length_error() _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000126};
127
128class _LIBCPP_EXCEPTION_ABI out_of_range
129 : public logic_error
130{
131public:
132 _LIBCPP_INLINE_VISIBILITY explicit out_of_range(const string& __s) : logic_error(__s) {}
133 _LIBCPP_INLINE_VISIBILITY explicit out_of_range(const char* __s) : logic_error(__s) {}
134
Howard Hinnant1e15fd12011-05-26 19:48:01 +0000135 virtual ~out_of_range() _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000136};
137
138class _LIBCPP_EXCEPTION_ABI range_error
139 : public runtime_error
140{
141public:
142 _LIBCPP_INLINE_VISIBILITY explicit range_error(const string& __s) : runtime_error(__s) {}
143 _LIBCPP_INLINE_VISIBILITY explicit range_error(const char* __s) : runtime_error(__s) {}
144
Howard Hinnant1e15fd12011-05-26 19:48:01 +0000145 virtual ~range_error() _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000146};
147
148class _LIBCPP_EXCEPTION_ABI overflow_error
149 : public runtime_error
150{
151public:
152 _LIBCPP_INLINE_VISIBILITY explicit overflow_error(const string& __s) : runtime_error(__s) {}
153 _LIBCPP_INLINE_VISIBILITY explicit overflow_error(const char* __s) : runtime_error(__s) {}
154
Howard Hinnant1e15fd12011-05-26 19:48:01 +0000155 virtual ~overflow_error() _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000156};
157
158class _LIBCPP_EXCEPTION_ABI underflow_error
159 : public runtime_error
160{
161public:
162 _LIBCPP_INLINE_VISIBILITY explicit underflow_error(const string& __s) : runtime_error(__s) {}
163 _LIBCPP_INLINE_VISIBILITY explicit underflow_error(const char* __s) : runtime_error(__s) {}
164
Howard Hinnant1e15fd12011-05-26 19:48:01 +0000165 virtual ~underflow_error() _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000166};
167
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000168} // std
169
170#endif // _LIBCPP_STDEXCEPT