#ifndef _LIBCPP___EXCEPTION_EXCEPTION_H
#define _LIBCPP___EXCEPTION_EXCEPTION_H
#include <__config>
#if defined(_LIBCPP_ABI_VCRUNTIME)
# include <vcruntime_exception.h>
#endif
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
_LIBCPP_BEGIN_UNVERSIONED_NAMESPACE_STD
#if defined(_LIBCPP_ABI_VCRUNTIME) && (!defined(_HAS_EXCEPTIONS) || _HAS_EXCEPTIONS != 0)
#elif defined(_LIBCPP_ABI_VCRUNTIME) && _HAS_EXCEPTIONS == 0
struct __std_exception_data {
char const* _What;
bool _DoFree;
};
class exception { public:
exception() _NOEXCEPT : __data_() {}
explicit exception(char const* __message) _NOEXCEPT : __data_() {
__data_._What = __message;
__data_._DoFree = true;
}
exception(exception const&) _NOEXCEPT : __data_() {}
exception& operator=(exception const&) _NOEXCEPT { return *this; }
virtual ~exception() _NOEXCEPT {}
[[__nodiscard__]] virtual char const* what() const _NOEXCEPT {
return __data_._What ? __data_._What : "Unknown exception";
}
private:
__std_exception_data __data_;
};
class bad_exception : public exception {
public:
bad_exception() _NOEXCEPT : exception("bad exception") {}
};
#else
class _LIBCPP_EXPORTED_FROM_ABI exception {
public:
_LIBCPP_HIDE_FROM_ABI exception() _NOEXCEPT {}
_LIBCPP_HIDE_FROM_ABI exception(const exception&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI exception& operator=(const exception&) _NOEXCEPT = default;
virtual ~exception() _NOEXCEPT;
[[__nodiscard__]] virtual const char* what() const _NOEXCEPT;
};
class _LIBCPP_EXPORTED_FROM_ABI bad_exception : public exception {
public:
_LIBCPP_HIDE_FROM_ABI bad_exception() _NOEXCEPT {}
_LIBCPP_HIDE_FROM_ABI bad_exception(const bad_exception&) _NOEXCEPT = default;
_LIBCPP_HIDE_FROM_ABI bad_exception& operator=(const bad_exception&) _NOEXCEPT = default;
~bad_exception() _NOEXCEPT override;
[[__nodiscard__]] const char* what() const _NOEXCEPT override;
};
#endif
_LIBCPP_END_UNVERSIONED_NAMESPACE_STD
#endif