xref: /netbsd-src/external/bsd/libc++/dist/libcxxrt/src/stdexcept.h (revision fec583f48bb2b0329630246c25e9635fec7c3f97)
1ccec91a1Sjoerg /*
2ccec91a1Sjoerg  * Copyright 2010-2011 PathScale, Inc. All rights reserved.
3ccec91a1Sjoerg  *
4ccec91a1Sjoerg  * Redistribution and use in source and binary forms, with or without
5ccec91a1Sjoerg  * modification, are permitted provided that the following conditions are met:
6ccec91a1Sjoerg  *
7ccec91a1Sjoerg  * 1. Redistributions of source code must retain the above copyright notice,
8ccec91a1Sjoerg  *    this list of conditions and the following disclaimer.
9ccec91a1Sjoerg  *
10ccec91a1Sjoerg  * 2. Redistributions in binary form must reproduce the above copyright notice,
11ccec91a1Sjoerg  *    this list of conditions and the following disclaimer in the documentation
12ccec91a1Sjoerg  *    and/or other materials provided with the distribution.
13ccec91a1Sjoerg  *
14ccec91a1Sjoerg  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
15ccec91a1Sjoerg  * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
16ccec91a1Sjoerg  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17ccec91a1Sjoerg  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
18ccec91a1Sjoerg  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19ccec91a1Sjoerg  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20ccec91a1Sjoerg  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
21ccec91a1Sjoerg  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
22ccec91a1Sjoerg  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23ccec91a1Sjoerg  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
24ccec91a1Sjoerg  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25ccec91a1Sjoerg  */
26ccec91a1Sjoerg 
27ccec91a1Sjoerg /**
28ccec91a1Sjoerg  * stdexcept.h - provides a stub version of <stdexcept>, which defines enough
29ccec91a1Sjoerg  * of the exceptions for the runtime to use.
30ccec91a1Sjoerg  */
31ccec91a1Sjoerg 
32ccec91a1Sjoerg namespace std
33ccec91a1Sjoerg {
34ccec91a1Sjoerg 
35ccec91a1Sjoerg 	class exception
36ccec91a1Sjoerg 	{
37ccec91a1Sjoerg 	public:
38ccec91a1Sjoerg 		exception() throw();
39ccec91a1Sjoerg 		exception(const exception&) throw();
40ccec91a1Sjoerg 		exception& operator=(const exception&) throw();
41ccec91a1Sjoerg 		virtual ~exception();
42ccec91a1Sjoerg 		virtual const char* what() const throw();
43ccec91a1Sjoerg 	};
44ccec91a1Sjoerg 
45ccec91a1Sjoerg 
46ccec91a1Sjoerg 	/**
47ccec91a1Sjoerg 	 * Bad allocation exception.  Thrown by ::operator new() if it fails.
48ccec91a1Sjoerg 	 */
49ccec91a1Sjoerg 	class bad_alloc: public exception
50ccec91a1Sjoerg 	{
51ccec91a1Sjoerg 	public:
52ccec91a1Sjoerg 		bad_alloc() throw();
53ccec91a1Sjoerg 		bad_alloc(const bad_alloc&) throw();
54ccec91a1Sjoerg 		bad_alloc& operator=(const bad_alloc&) throw();
55ccec91a1Sjoerg 		~bad_alloc();
56ccec91a1Sjoerg 		virtual const char* what() const throw();
57ccec91a1Sjoerg 	};
58ccec91a1Sjoerg 
59ccec91a1Sjoerg 	/**
60ccec91a1Sjoerg 	 * Bad cast exception.  Thrown by the __cxa_bad_cast() helper function.
61ccec91a1Sjoerg 	 */
62ccec91a1Sjoerg 	class bad_cast: public exception {
63ccec91a1Sjoerg 	public:
64ccec91a1Sjoerg 		bad_cast() throw();
65ccec91a1Sjoerg 		bad_cast(const bad_cast&) throw();
66ccec91a1Sjoerg 		bad_cast& operator=(const bad_cast&) throw();
67ccec91a1Sjoerg 		virtual ~bad_cast();
68ccec91a1Sjoerg 		virtual const char* what() const throw();
69ccec91a1Sjoerg 	};
70ccec91a1Sjoerg 
71ccec91a1Sjoerg 	/**
72ccec91a1Sjoerg 	 * Bad typeidexception.  Thrown by the __cxa_bad_typeid() helper function.
73ccec91a1Sjoerg 	 */
74ccec91a1Sjoerg 	class bad_typeid: public exception
75ccec91a1Sjoerg 	{
76ccec91a1Sjoerg 	public:
77ccec91a1Sjoerg 		bad_typeid() throw();
78ccec91a1Sjoerg 		bad_typeid(const bad_typeid &__rhs) throw();
79ccec91a1Sjoerg 		virtual ~bad_typeid();
80ccec91a1Sjoerg 		bad_typeid& operator=(const bad_typeid &__rhs) throw();
81ccec91a1Sjoerg 		virtual const char* what() const throw();
82ccec91a1Sjoerg 	};
83ccec91a1Sjoerg 
84*fec583f4Spooka 	class bad_array_new_length: public bad_alloc
85*fec583f4Spooka 	{
86*fec583f4Spooka 	public:
87*fec583f4Spooka 		bad_array_new_length() throw();
88*fec583f4Spooka 		bad_array_new_length(const bad_array_new_length&) throw();
89*fec583f4Spooka 		bad_array_new_length& operator=(const bad_array_new_length&) throw();
90*fec583f4Spooka 		virtual ~bad_array_new_length();
91*fec583f4Spooka 		virtual const char *what() const throw();
92*fec583f4Spooka 	};
93ccec91a1Sjoerg 
94ccec91a1Sjoerg 
95ccec91a1Sjoerg } // namespace std
96ccec91a1Sjoerg 
97