xref: /freebsd/contrib/libcxxrt/stdexcept.h (revision 726f4cd5)
194e3ee44SDavid Chisnall /*
294e3ee44SDavid Chisnall  * Copyright 2010-2011 PathScale, Inc. All rights reserved.
394e3ee44SDavid Chisnall  *
494e3ee44SDavid Chisnall  * Redistribution and use in source and binary forms, with or without
594e3ee44SDavid Chisnall  * modification, are permitted provided that the following conditions are met:
694e3ee44SDavid Chisnall  *
794e3ee44SDavid Chisnall  * 1. Redistributions of source code must retain the above copyright notice,
894e3ee44SDavid Chisnall  *    this list of conditions and the following disclaimer.
994e3ee44SDavid Chisnall  *
1094e3ee44SDavid Chisnall  * 2. Redistributions in binary form must reproduce the above copyright notice,
1194e3ee44SDavid Chisnall  *    this list of conditions and the following disclaimer in the documentation
1294e3ee44SDavid Chisnall  *    and/or other materials provided with the distribution.
1394e3ee44SDavid Chisnall  *
1494e3ee44SDavid Chisnall  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
1594e3ee44SDavid Chisnall  * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
1694e3ee44SDavid Chisnall  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
1794e3ee44SDavid Chisnall  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
1894e3ee44SDavid Chisnall  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
1994e3ee44SDavid Chisnall  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
2094e3ee44SDavid Chisnall  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
2194e3ee44SDavid Chisnall  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
2294e3ee44SDavid Chisnall  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
2394e3ee44SDavid Chisnall  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
2494e3ee44SDavid Chisnall  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2594e3ee44SDavid Chisnall  */
2694e3ee44SDavid Chisnall 
277a984708SDavid Chisnall /**
287a984708SDavid Chisnall  * stdexcept.h - provides a stub version of <stdexcept>, which defines enough
297a984708SDavid Chisnall  * of the exceptions for the runtime to use.
307a984708SDavid Chisnall  */
317a984708SDavid Chisnall 
327a984708SDavid Chisnall namespace std
337a984708SDavid Chisnall {
347a984708SDavid Chisnall 
357a984708SDavid Chisnall 	class exception
367a984708SDavid Chisnall 	{
377a984708SDavid Chisnall 	public:
387a984708SDavid Chisnall 		exception() throw();
397a984708SDavid Chisnall 		exception(const exception&) throw();
407a984708SDavid Chisnall 		exception& operator=(const exception&) throw();
417a984708SDavid Chisnall 		virtual ~exception();
427a984708SDavid Chisnall 		virtual const char* what() const throw();
437a984708SDavid Chisnall 	};
447a984708SDavid Chisnall 
457a984708SDavid Chisnall 
467a984708SDavid Chisnall 	/**
477a984708SDavid Chisnall 	 * Bad allocation exception.  Thrown by ::operator new() if it fails.
487a984708SDavid Chisnall 	 */
497a984708SDavid Chisnall 	class bad_alloc: public exception
507a984708SDavid Chisnall 	{
517a984708SDavid Chisnall 	public:
527a984708SDavid Chisnall 		bad_alloc() throw();
537a984708SDavid Chisnall 		bad_alloc(const bad_alloc&) throw();
547a984708SDavid Chisnall 		bad_alloc& operator=(const bad_alloc&) throw();
557a984708SDavid Chisnall 		~bad_alloc();
567a984708SDavid Chisnall 		virtual const char* what() const throw();
577a984708SDavid Chisnall 	};
587a984708SDavid Chisnall 
597a984708SDavid Chisnall 	/**
607a984708SDavid Chisnall 	 * Bad cast exception.  Thrown by the __cxa_bad_cast() helper function.
617a984708SDavid Chisnall 	 */
627a984708SDavid Chisnall 	class bad_cast: public exception {
637a984708SDavid Chisnall 	public:
647a984708SDavid Chisnall 		bad_cast() throw();
657a984708SDavid Chisnall 		bad_cast(const bad_cast&) throw();
667a984708SDavid Chisnall 		bad_cast& operator=(const bad_cast&) throw();
677a984708SDavid Chisnall 		virtual ~bad_cast();
687a984708SDavid Chisnall 		virtual const char* what() const throw();
697a984708SDavid Chisnall 	};
707a984708SDavid Chisnall 
717a984708SDavid Chisnall 	/**
727a984708SDavid Chisnall 	 * Bad typeidexception.  Thrown by the __cxa_bad_typeid() helper function.
737a984708SDavid Chisnall 	 */
747a984708SDavid Chisnall 	class bad_typeid: public exception
757a984708SDavid Chisnall 	{
767a984708SDavid Chisnall 	public:
777a984708SDavid Chisnall 		bad_typeid() throw();
787a984708SDavid Chisnall 		bad_typeid(const bad_typeid &__rhs) throw();
797a984708SDavid Chisnall 		virtual ~bad_typeid();
807a984708SDavid Chisnall 		bad_typeid& operator=(const bad_typeid &__rhs) throw();
817a984708SDavid Chisnall 		virtual const char* what() const throw();
827a984708SDavid Chisnall 	};
837a984708SDavid Chisnall 
84726f4cd5SBaptiste Daroussin 	class bad_array_new_length: public bad_alloc
85726f4cd5SBaptiste Daroussin 	{
86726f4cd5SBaptiste Daroussin 	public:
87726f4cd5SBaptiste Daroussin 		bad_array_new_length() throw();
88726f4cd5SBaptiste Daroussin 		bad_array_new_length(const bad_array_new_length&) throw();
89726f4cd5SBaptiste Daroussin 		bad_array_new_length& operator=(const bad_array_new_length&) throw();
90726f4cd5SBaptiste Daroussin 		virtual ~bad_array_new_length();
91726f4cd5SBaptiste Daroussin 		virtual const char *what() const throw();
92726f4cd5SBaptiste Daroussin 	};
937a984708SDavid Chisnall 
947a984708SDavid Chisnall 
957a984708SDavid Chisnall } // namespace std
967a984708SDavid Chisnall 
97