xref: /netbsd-src/external/gpl3/gcc/dist/libstdc++-v3/libsupc++/exception.h (revision b1e838363e3c6fc78a55519254d99869742dd33c)
1b17d1066Smrg // Exception Handling support header for -*- C++ -*-
2b17d1066Smrg 
3*b1e83836Smrg // Copyright (C) 2016-2022 Free Software Foundation, Inc.
4b17d1066Smrg //
5b17d1066Smrg // This file is part of GCC.
6b17d1066Smrg //
7b17d1066Smrg // GCC is free software; you can redistribute it and/or modify
8b17d1066Smrg // it under the terms of the GNU General Public License as published by
9b17d1066Smrg // the Free Software Foundation; either version 3, or (at your option)
10b17d1066Smrg // any later version.
11b17d1066Smrg //
12b17d1066Smrg // GCC is distributed in the hope that it will be useful,
13b17d1066Smrg // but WITHOUT ANY WARRANTY; without even the implied warranty of
14b17d1066Smrg // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15b17d1066Smrg // GNU General Public License for more details.
16b17d1066Smrg //
17b17d1066Smrg // Under Section 7 of GPL version 3, you are granted additional
18b17d1066Smrg // permissions described in the GCC Runtime Library Exception, version
19b17d1066Smrg // 3.1, as published by the Free Software Foundation.
20b17d1066Smrg 
21b17d1066Smrg // You should have received a copy of the GNU General Public License and
22b17d1066Smrg // a copy of the GCC Runtime Library Exception along with this program;
23b17d1066Smrg // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
24b17d1066Smrg // <http://www.gnu.org/licenses/>.
25b17d1066Smrg 
26b17d1066Smrg /** @file bits/exception.h
27b17d1066Smrg  *  This is an internal header file, included by other library headers.
28b17d1066Smrg  *  Do not attempt to use it directly.
29b17d1066Smrg  */
30b17d1066Smrg 
31b17d1066Smrg #ifndef __EXCEPTION_H
32b17d1066Smrg #define __EXCEPTION_H 1
33b17d1066Smrg 
34b17d1066Smrg #pragma GCC system_header
35b17d1066Smrg 
36b17d1066Smrg #pragma GCC visibility push(default)
37b17d1066Smrg 
38b17d1066Smrg #include <bits/c++config.h>
39b17d1066Smrg 
40b17d1066Smrg extern "C++" {
41b17d1066Smrg 
42b17d1066Smrg namespace std
43b17d1066Smrg {
44b17d1066Smrg   /**
45b17d1066Smrg    * @defgroup exceptions Exceptions
46b17d1066Smrg    * @ingroup diagnostics
47*b1e83836Smrg    * @since C++98
48b17d1066Smrg    *
49a448f87cSmrg    * Classes and functions for reporting errors via exceptions.
50b17d1066Smrg    * @{
51b17d1066Smrg    */
52b17d1066Smrg 
53b17d1066Smrg   /**
54b17d1066Smrg    *  @brief Base class for all library exceptions.
55b17d1066Smrg    *
56b17d1066Smrg    *  This is the base class for all exceptions thrown by the standard
57b17d1066Smrg    *  library, and by certain language expressions.  You are free to derive
58b17d1066Smrg    *  your own %exception classes, or use a different hierarchy, or to
59b17d1066Smrg    *  throw non-class data (e.g., fundamental types).
60b17d1066Smrg    */
61b17d1066Smrg   class exception
62b17d1066Smrg   {
63b17d1066Smrg   public:
exception()64181254a7Smrg     exception() _GLIBCXX_NOTHROW { }
65181254a7Smrg     virtual ~exception() _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_NOTHROW;
66181254a7Smrg #if __cplusplus >= 201103L
67181254a7Smrg     exception(const exception&) = default;
68181254a7Smrg     exception& operator=(const exception&) = default;
69181254a7Smrg     exception(exception&&) = default;
70181254a7Smrg     exception& operator=(exception&&) = default;
71181254a7Smrg #endif
72b17d1066Smrg 
73b17d1066Smrg     /** Returns a C-style character string describing the general cause
74b17d1066Smrg      *  of the current error.  */
75b17d1066Smrg     virtual const char*
76181254a7Smrg     what() const _GLIBCXX_TXN_SAFE_DYN _GLIBCXX_NOTHROW;
77b17d1066Smrg   };
78b17d1066Smrg 
79a448f87cSmrg   /// @}
80a448f87cSmrg 
81b17d1066Smrg } // namespace std
82b17d1066Smrg 
83b17d1066Smrg }
84b17d1066Smrg 
85b17d1066Smrg #pragma GCC visibility pop
86b17d1066Smrg 
87b17d1066Smrg #endif
88