]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/include/std/stdexcept
*: Use headername alias to associate private includes to public includes.
[thirdparty/gcc.git] / libstdc++-v3 / include / std / stdexcept
CommitLineData
54c1bf78 1// Standard exception classes -*- C++ -*-
de96ac46 2
5b9daa7e 3// Copyright (C) 2001, 2002, 2005, 2007, 2009 Free Software Foundation, Inc.
de96ac46
BK
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
748086b7 8// Free Software Foundation; either version 3, or (at your option)
de96ac46
BK
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
748086b7
JJ
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
de96ac46 19
748086b7
JJ
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
de96ac46 24
f910786b 25/** @file include/stdexcept
0aa06b18 26 * This is a Standard C++ Library header.
2f9d51b8
PE
27 */
28
143c27b0
BK
29//
30// ISO C++ 19.1 Exception classes
31//
32
1143680e
SE
33#ifndef _GLIBCXX_STDEXCEPT
34#define _GLIBCXX_STDEXCEPT 1
54c1bf78
BK
35
36#pragma GCC system_header
37
38#include <exception>
39#include <string>
40
3cbc7af0
BK
41_GLIBCXX_BEGIN_NAMESPACE(std)
42
5b9daa7e
BK
43 /**
44 * @addtogroup exceptions
45 * @{
46 */
47
54c1bf78
BK
48 /** Logic errors represent problems in the internal logic of a program;
49 * in theory, these are preventable, and even detectable before the
50 * program runs (e.g., violations of class invariants).
51 * @brief One of two subclasses of exception.
52 */
53 class logic_error : public exception
54 {
55 string _M_msg;
56
57 public:
58 /** Takes a character string describing the error. */
59 explicit
8339896e 60 logic_error(const string& __arg);
54c1bf78
BK
61
62 virtual
63 ~logic_error() throw();
64
65 /** Returns a C-style character string describing the general cause of
66 * the current error (the same string passed to the ctor). */
67 virtual const char*
68 what() const throw();
69 };
70
71 /** Thrown by the library, or by you, to report domain errors (domain in
28dac70a 72 * the mathematical sense). */
54c1bf78
BK
73 class domain_error : public logic_error
74 {
75 public:
8339896e 76 explicit domain_error(const string& __arg);
54c1bf78
BK
77 };
78
79 /** Thrown to report invalid arguments to functions. */
80 class invalid_argument : public logic_error
81 {
82 public:
8339896e 83 explicit invalid_argument(const string& __arg);
54c1bf78
BK
84 };
85
86 /** Thrown when an object is constructed that would exceed its maximum
87 * permitted size (e.g., a basic_string instance). */
88 class length_error : public logic_error
89 {
90 public:
8339896e 91 explicit length_error(const string& __arg);
54c1bf78
BK
92 };
93
94 /** This represents an argument whose value is not within the expected
95 * range (e.g., boundary checks in basic_string). */
96 class out_of_range : public logic_error
97 {
98 public:
8339896e 99 explicit out_of_range(const string& __arg);
54c1bf78
BK
100 };
101
102 /** Runtime errors represent problems outside the scope of a program;
103 * they cannot be easily predicted and can generally only be caught as
104 * the program executes.
105 * @brief One of two subclasses of exception.
106 */
107 class runtime_error : public exception
108 {
109 string _M_msg;
110
111 public:
112 /** Takes a character string describing the error. */
113 explicit
8339896e 114 runtime_error(const string& __arg);
54c1bf78
BK
115
116 virtual
117 ~runtime_error() throw();
118
119 /** Returns a C-style character string describing the general cause of
120 * the current error (the same string passed to the ctor). */
121 virtual const char*
122 what() const throw();
123 };
124
125 /** Thrown to indicate range errors in internal computations. */
126 class range_error : public runtime_error
127 {
128 public:
8339896e 129 explicit range_error(const string& __arg);
54c1bf78
BK
130 };
131
132 /** Thrown to indicate arithmetic overflow. */
133 class overflow_error : public runtime_error
134 {
135 public:
8339896e 136 explicit overflow_error(const string& __arg);
54c1bf78
BK
137 };
138
139 /** Thrown to indicate arithmetic underflow. */
140 class underflow_error : public runtime_error
141 {
142 public:
8339896e 143 explicit underflow_error(const string& __arg);
54c1bf78 144 };
3cbc7af0 145
5b9daa7e
BK
146 // @} group exceptions
147
3cbc7af0 148_GLIBCXX_END_NAMESPACE
54c1bf78 149
1143680e 150#endif /* _GLIBCXX_STDEXCEPT */