1// -*- C++ -*- 2//===--------------------------- stdexcept --------------------------------===// 3// 4// The LLVM Compiler Infrastructure 5// 6// This file is dual licensed under the MIT and the University of Illinois Open 7// Source Licenses. See LICENSE.TXT for details. 8// 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); 36 explicit xxx_error(const char* what_arg); 37 38 virtual const char* what() const noexcept // returns what_arg 39}; 40 41} // std 42 43*/ 44 45#include <__config> 46#include <exception> 47#include <iosfwd> // for string forward decl 48 49#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 50#pragma GCC system_header 51#endif 52 53#ifndef _LIBCPP___REFSTRING 54_LIBCPP_BEGIN_NAMESPACE_STD 55class _LIBCPP_HIDDEN __libcpp_refstring { 56#ifdef __clang__ 57 const char *__imp_ __attribute__((__unused__)); // only clang emits a warning 58#else 59 const char *__imp_; 60#endif 61}; 62_LIBCPP_END_NAMESPACE_STD 63#endif 64 65namespace std // purposefully not using versioning namespace 66{ 67 68class _LIBCPP_EXCEPTION_ABI logic_error 69 : public exception 70{ 71private: 72 _VSTD::__libcpp_refstring __imp_; 73public: 74 explicit logic_error(const string&); 75 explicit logic_error(const char*); 76 77 logic_error(const logic_error&) _NOEXCEPT; 78 logic_error& operator=(const logic_error&) _NOEXCEPT; 79 80 virtual ~logic_error() _NOEXCEPT; 81 82 virtual const char* what() const _NOEXCEPT; 83}; 84 85class _LIBCPP_EXCEPTION_ABI runtime_error 86 : public exception 87{ 88private: 89 _VSTD::__libcpp_refstring __imp_; 90public: 91 explicit runtime_error(const string&); 92 explicit runtime_error(const char*); 93 94 runtime_error(const runtime_error&) _NOEXCEPT; 95 runtime_error& operator=(const runtime_error&) _NOEXCEPT; 96 97 virtual ~runtime_error() _NOEXCEPT; 98 99 virtual const char* what() const _NOEXCEPT; 100}; 101 102class _LIBCPP_EXCEPTION_ABI domain_error 103 : public logic_error 104{ 105public: 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) {} 108 109 virtual ~domain_error() _NOEXCEPT; 110}; 111 112class _LIBCPP_EXCEPTION_ABI invalid_argument 113 : public logic_error 114{ 115public: 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) {} 118 119 virtual ~invalid_argument() _NOEXCEPT; 120}; 121 122class _LIBCPP_EXCEPTION_ABI length_error 123 : public logic_error 124{ 125public: 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) {} 128 129 virtual ~length_error() _NOEXCEPT; 130}; 131 132class _LIBCPP_EXCEPTION_ABI out_of_range 133 : public logic_error 134{ 135public: 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) {} 138 139 virtual ~out_of_range() _NOEXCEPT; 140}; 141 142class _LIBCPP_EXCEPTION_ABI range_error 143 : public runtime_error 144{ 145public: 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) {} 148 149 virtual ~range_error() _NOEXCEPT; 150}; 151 152class _LIBCPP_EXCEPTION_ABI overflow_error 153 : public runtime_error 154{ 155public: 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) {} 158 159 virtual ~overflow_error() _NOEXCEPT; 160}; 161 162class _LIBCPP_EXCEPTION_ABI underflow_error 163 : public runtime_error 164{ 165public: 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) {} 168 169 virtual ~underflow_error() _NOEXCEPT; 170}; 171 172} // std 173 174#endif // _LIBCPP_STDEXCEPT 175