// exception standard header
#ifndef _EXCEPTION_
#define _EXCEPTION_
#include <xstddef>

 #if __GNUC__ < 3 && !defined(__APPLE__) && !defined(__MINGW32__)
_X_STD_BEGIN

 #else /* __GNUC__ < 3 && !defined(__APPLE__) && !defined(__MINGW32__) */
namespace std {
 #endif /* __GNUC__ < 3 && !defined(__APPLE__) && !defined(__MINGW32__) */

		// FORWARD REFERENCES
class exception;
typedef void (*_Prhand)(const exception&);
extern _Prhand _Raise_handler;
void _Throw(const exception&);

 #if __EDG__ || defined(__SUNPRO_CC)
		// CLASS exception
class exception
	{	// base of all library exceptions, EDG version
public:
	static _Prhand _Set_raise_handler(_Prhand _Pnew)
		{	// register a handler for _Raise calls
		const _Prhand _Pold = _Raise_handler;
		_Raise_handler = _Pnew;
		return (_Pold);
		}

	explicit exception(const char *_Message = _MESG("unknown")) _THROW0()
		: _Ptr(_Message)
		{	// construct from message string
		}

	exception(const exception& _Right) _THROW0()
		: _Ptr(_Right._Ptr)
		{	// construct by copying _Right
		}

	exception& operator=(const exception& _Right) _THROW0()
		{	// assign _Right
		_Ptr = _Right._Ptr;
		return (*this);
		}

	virtual ~exception()
		{	// destroy the object
		}

 #if _HAS_TRADITIONAL_STL
	virtual const char *what() const

 #else /* _HAS_TRADITIONAL_STL */
	virtual const char *what() const _THROW0()
 #endif /* _HAS_TRADITIONAL_STL */

		{	// return pointer to message string
		return (_Ptr);
		}

 #if _HAS_EXCEPTIONS
protected:

 #else /* _HAS_EXCEPTIONS */
	void _Raise() const
		{	// raise the exception
		if (_Raise_handler != 0)
			(*_Raise_handler)(*this);	// call raise handler if present

		_Doraise();	// call the protected virtual
		_RAISE(*this);	// raise this exception
		}

protected:
	virtual void _Doraise() const
		{	// perform class-specific exception handling
		}
 #endif /* _HAS_EXCEPTIONS */

	const char *_Ptr;	// the message pointer
	};

		// CLASS bad_exception
class bad_exception
	: public exception
	{	// base of all bad exceptions, EDG version
public:
	bad_exception(const char *_Message = "bad exception")
		_THROW0()
		: exception(_Message)
		{	// construct from message string
		}

	virtual ~bad_exception() _THROW0()
		{	// destroy the object
		}

 #if _HAS_EXCEPTIONS

 #else /* _HAS_EXCEPTIONS */

protected:
	virtual void _Doraise() const
		{	// raise this exception
		_RAISE(*this);
		}
 #endif /* _HAS_EXCEPTIONS */

	};

 #else /* __EDG__ etc. */
		// CLASS exception
class exception
	{	// base of all library exceptions, gcc version
public:
	static _Prhand _Set_raise_handler(_Prhand _Pnew);

	exception()  _THROW0()
		{
		}

	virtual ~exception();

 #if _HAS_TRADITIONAL_STL
	virtual const char *what() const;

 #else /* _HAS_TRADITIONAL_STL */
	virtual const char *what() const _THROW0();
 #endif /* _HAS_TRADITIONAL_STL */

 #if _HAS_EXCEPTIONS

 #else /* _HAS_EXCEPTIONS */

	void _Raise() const;

protected:
	virtual void _Doraise() const;
 #endif /* _HAS_EXCEPTIONS */

	};

		// CLASS bad_exception
class bad_exception
	: public exception
	{	// base of all bad exceptions, gcc version
public:
	bad_exception() _THROW0()
		{	// construct with no message string
		}

	virtual ~bad_exception() _THROW0()
		{	// destroy the object
		}

 #if _HAS_EXCEPTIONS

 #else /* _HAS_EXCEPTIONS */

protected:
	virtual void _Doraise() const
		{	// raise this exception
		_RAISE(*this);
		}
 #endif /* _HAS_EXCEPTIONS */

	};
 #endif /* __EDG__ etc. */

		// TYPES
typedef void (*terminate_handler)();
typedef void (*unexpected_handler)();

		// FUNCTION DECLARATIONS
terminate_handler set_terminate(terminate_handler) _THROW0();
unexpected_handler set_unexpected(unexpected_handler) _THROW0();
bool uncaught_exception();
_NO_RETURN(terminate());
_NO_RETURN(unexpected());

 #if __GNUC__ < 3 && !defined(__APPLE__) && !defined(__MINGW32__)
_X_STD_END

 #else /* __GNUC__ < 3 && !defined(__APPLE__) && !defined(__MINGW32__) */
} /* namespace std */

 #if _HAS_NAMESPACE

 #else /* _HAS_NAMESPACE */
using std::_Prhand; using std::_Raise_handler;
using std::_Throw;

using std::exception; using std::bad_exception;
using std::terminate_handler; using std::unexpected_handler;
using std::set_terminate; using std::set_unexpected;
using std::terminate; using std::unexpected;
using std::uncaught_exception;
 #endif /* _HAS_NAMESPACE */

 #endif /* __GNUC__ < 3 && !defined(__APPLE__) && !defined(__MINGW32__) */
#endif /* _EXCEPTION_ */

/*
 * Copyright (c) 1992-2003 by P.J. Plauger.  ALL RIGHTS RESERVED.
 * Consult your license regarding permissions and restrictions.
V4.02:0216 */
