// exception standard header -*-c++-*-
// Copyright 2009-2017 IAR Systems AB.
#ifndef _EXCEPTION_
#define _EXCEPTION_

#ifndef _SYSTEM_BUILD
#pragma system_include
#endif

#include <xstddef>

namespace std {

// CLASS exception
class exception
{
public:
  exception() _THROW0() {}
  exception(const exception&) _THROW0() {}

  virtual ~exception() _NOEXCEPT;
  virtual const char *what() const _THROW0();
};

class bad_exception : public exception
{
public:
  bad_exception() _THROW0();
  bad_exception(const bad_exception&) _THROW0();
  bad_exception& operator=(const bad_exception&) _THROW0();
  virtual ~bad_exception() _NOEXCEPT;
  virtual const char* what() const _THROW0();
};

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

// FUNCTION DECLARATIONS
__ATTRIBUTES terminate_handler get_terminate() _NOEXCEPT;
__ATTRIBUTES terminate_handler set_terminate(terminate_handler) _THROW0();
__ATTRIBUTES unexpected_handler get_unexpected() _NOEXCEPT;
__ATTRIBUTES unexpected_handler set_unexpected(unexpected_handler) _THROW0();
__ATTRIBUTES bool uncaught_exception() _THROW0();
__ATTRIBUTES int uncaught_exceptions() _THROW0(); // C++17
__ATTRIBUTES_NORETURN void terminate();
__ATTRIBUTES_NORETURN_CAN_THROW void unexpected();

inline unexpected_handler get_unexpected() _NOEXCEPT
{       // get unexpected handler -- UNSAFE
  unexpected_handler _Hand = set_unexpected(0);
  set_unexpected(_Hand);
  return (_Hand);
}

inline terminate_handler get_terminate() _NOEXCEPT
{       // get terminate handler -- UNSAFE
  terminate_handler _Hand = set_terminate(0);
  set_terminate(_Hand);
  return (_Hand);
}

} /* namespace std */

#include <xxexception>

#endif /* _EXCEPTION_ */

/*
 * Copyright (c) by P.J. Plauger. All rights reserved.
 * Consult your license regarding permissions and restrictions.
V6.50:0576 */
