1    	// Standard exception classes  -*- C++ -*-
2    	
3    	// Copyright (C) 2001-2013 Free Software Foundation, Inc.
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
8    	// Free Software Foundation; either version 3, or (at your option)
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   	
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.
19   	
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/>.
24   	
25   	/** @file include/stdexcept
26   	 *  This is a Standard C++ Library header.
27   	 */
28   	
29   	//
30   	// ISO C++ 19.1  Exception classes
31   	//
32   	
33   	#ifndef _GLIBCXX_STDEXCEPT
34   	#define _GLIBCXX_STDEXCEPT 1
35   	
36   	#pragma GCC system_header
37   	
38   	#include <exception>
39   	#include <string>
40   	
41   	namespace std _GLIBCXX_VISIBILITY(default)
42   	{
43   	_GLIBCXX_BEGIN_NAMESPACE_VERSION
44   	
45   	  /**
46   	   * @addtogroup exceptions
47   	   * @{
48   	   */
49   	
50   	  /** Logic errors represent problems in the internal logic of a program;
51   	   *  in theory, these are preventable, and even detectable before the
52   	   *  program runs (e.g., violations of class invariants).
53   	   *  @brief One of two subclasses of exception.
54   	   */
55   	  class logic_error : public exception 
56   	  {
57   	    string _M_msg;
58   	
59   	  public:
60   	    /** Takes a character string describing the error.  */
61   	    explicit 
62   	    logic_error(const string& __arg);
63   	
64   	    virtual ~logic_error() _GLIBCXX_USE_NOEXCEPT;
65   	
66   	    /** Returns a C-style character string describing the general cause of
67   	     *  the current error (the same string passed to the ctor).  */
68   	    virtual const char* 
69   	    what() const _GLIBCXX_USE_NOEXCEPT;
70   	  };
71   	
72   	  /** Thrown by the library, or by you, to report domain errors (domain in
73   	   *  the mathematical sense).  */
74   	  class domain_error : public logic_error 
75   	  {
76   	  public:
77   	    explicit domain_error(const string& __arg);
78   	    virtual ~domain_error() _GLIBCXX_USE_NOEXCEPT;
79   	  };
80   	
81   	  /** Thrown to report invalid arguments to functions.  */
82   	  class invalid_argument : public logic_error 
83   	  {
84   	  public:
85   	    explicit invalid_argument(const string& __arg);
86   	    virtual ~invalid_argument() _GLIBCXX_USE_NOEXCEPT;
87   	  };
88   	
89   	  /** Thrown when an object is constructed that would exceed its maximum
90   	   *  permitted size (e.g., a basic_string instance).  */
91   	  class length_error : public logic_error 
92   	  {
93   	  public:
94   	    explicit length_error(const string& __arg);
95   	    virtual ~length_error() _GLIBCXX_USE_NOEXCEPT;
96   	  };
97   	
98   	  /** This represents an argument whose value is not within the expected
99   	   *  range (e.g., boundary checks in basic_string).  */
100  	  class out_of_range : public logic_error 
101  	  {
102  	  public:
103  	    explicit out_of_range(const string& __arg);
104  	    virtual ~out_of_range() _GLIBCXX_USE_NOEXCEPT;
105  	  };
106  	
107  	  /** Runtime errors represent problems outside the scope of a program;
108  	   *  they cannot be easily predicted and can generally only be caught as
109  	   *  the program executes.
110  	   *  @brief One of two subclasses of exception.
111  	   */
112  	  class runtime_error : public exception 
113  	  {
114  	    string _M_msg;
115  	
116  	  public:
117  	    /** Takes a character string describing the error.  */
118  	    explicit 
119  	    runtime_error(const string& __arg);
120  	
121  	    virtual ~runtime_error() _GLIBCXX_USE_NOEXCEPT;
122  	
123  	    /** Returns a C-style character string describing the general cause of
124  	     *  the current error (the same string passed to the ctor).  */
125  	    virtual const char* 
126  	    what() const _GLIBCXX_USE_NOEXCEPT;
127  	  };
128  	
129  	  /** Thrown to indicate range errors in internal computations.  */
130  	  class range_error : public runtime_error 
131  	  {
132  	  public:
133  	    explicit range_error(const string& __arg);
134  	    virtual ~range_error() _GLIBCXX_USE_NOEXCEPT;
135  	  };
136  	
137  	  /** Thrown to indicate arithmetic overflow.  */
138  	  class overflow_error : public runtime_error 
139  	  {
140  	  public:
141  	    explicit overflow_error(const string& __arg);
142  	    virtual ~overflow_error() _GLIBCXX_USE_NOEXCEPT;
143  	  };
144  	
145  	  /** Thrown to indicate arithmetic underflow.  */
146  	  class underflow_error : public runtime_error 
147  	  {
148  	  public:
149  	    explicit underflow_error(const string& __arg);
150  	    virtual ~underflow_error() _GLIBCXX_USE_NOEXCEPT;
151  	  };
152  	
153  	  // @} group exceptions
154  	
155  	_GLIBCXX_END_NAMESPACE_VERSION
156  	} // namespace
157  	
158  	#endif /* _GLIBCXX_STDEXCEPT */
159