#pragma once
#ifndef _SYSTEM_ERROR_
#define _SYSTEM_ERROR_
#ifndef RC_INVOKED
#include <cerrno>
#include <cstdlib> // for strerror
#include <stdexcept> // for runtime_error
#include <xcall_once.h>
#include <xerrc.h>
#pragma pack(push,_CRT_PACKING)
#pragma warning(push,_STL_WARNING_LEVEL)
#pragma warning(disable: _STL_DISABLED_WARNINGS)
#pragma warning(disable:
4455
4494
4619
4643
4702
4984
4988
)
_STL_DISABLE_CLANG_WARNINGS
#pragma push_macro("new")
#undef new
enum
class
{
=
1
};
template
<
class
>
struct
:
{
};
template
<>
struct
<
>
:
{
};
template
<
class
>
_INLINE_VAR constexpr bool is_error_code_enum_v = is_error_code_enum<_Ty>::value;
template
<
class
>
struct
:
{
};
template
<>
struct
<
>
:
{
};
template
<
class
>
_INLINE_VAR constexpr bool is_error_condition_enum_v = is_error_condition_enum<_Ty>::value;
constexpr
bool
is_error_condition_enum_v
=
<
>::
;
class
;
class
;
_NODISCARD error_code make_error_code(errc) noexcept;
_NODISCARD error_code make_error_code(io_errc) noexcept;
_NODISCARD error_condition make_error_condition(errc) noexcept;
_NODISCARD error_condition make_error_condition(io_errc) noexcept;
class
;
_NODISCARD const error_category& generic_category() noexcept;
_NODISCARD const error_category& iostream_category() noexcept;
_NODISCARD const error_category& system_category() noexcept;
class
__declspec
(novtable)
{
public
:
()
noexcept
{
=
reinterpret_cast
<
>(
this
);
}
virtual
()
noexcept
{
}
_NODISCARD virtual const char *name() const noexcept = 0;
virtual
const
char
*
()
const
noexcept
=
0
;
_NODISCARD virtual string message(int _Errval) const = 0;
virtual
(
int
)
const
=
0
;
_NODISCARD virtual error_condition default_error_condition(int _Errval) const noexcept;
virtual
(
int
)
const
noexcept
;
_NODISCARD virtual bool equivalent(int _Errval, const error_condition& _Cond) const noexcept;
virtual
bool
(
int
,
const
&
)
const
noexcept
;
_NODISCARD virtual bool equivalent(const error_code& _Code, int _Errval) const noexcept;
virtual
bool
(
const
&
,
int
)
const
noexcept
;
_NODISCARD bool operator==(const error_category& _Right) const noexcept
bool
(
const
&
)
const
noexcept
{
return
(
.
);
}
_NODISCARD bool operator!=(const error_category& _Right) const noexcept
bool
(
const
&
)
const
noexcept
{
return
(!(*
this
));
}
_NODISCARD bool operator<(const error_category& _Right) const noexcept
bool
(
const
&
)
const
noexcept
{
return
(
.
);
}
(
const
&) =
delete
;
&
(
const
&) =
delete
;
protected
:
;
enum
:
{
=
1
,
=
3
,
=
5
,
=
7
};
};
class
{
public
:
()
noexcept
: _Myval(
0
),
_Mycat(&
())
{
}
(
int
,
const
&
)
noexcept
: _Myval(
),
_Mycat(&
)
{
}
template
<
class
,
<
<
>,
int
> =
0
>
(
)
noexcept
: _Myval(
0
),
_Mycat(
nullptr
)
{
*
this
=
(
);
}
void
(
int
,
const
&
)
noexcept
{
=
;
= &
;
}
template
<
class
,
<
<
>,
int
> =
0
>
&
(
)
noexcept
{
*
this
=
(
);
return
(*
this
);
}
void
()
noexcept
{
=
0
;
= &
();
}
_NODISCARD int value() const noexcept
{
return
(
);
}
_NODISCARD const error_category& category() const noexcept
const
&
()
const
noexcept
{
return
(*
);
}
_NODISCARD error_condition default_error_condition() const noexcept;
_NODISCARD string message() const
{
return
(
().
(
()));
}
explicit
bool
()
const
noexcept
{
return
(
()
0
);
}
private
:
int
;
const
*
;
};
class
{
public
:
()
noexcept
: _Myval(
0
),
_Mycat(&
())
{
}
(
int
,
const
&
)
noexcept
: _Myval(
),
_Mycat(&
)
{
}
template
<
class
,
<
is_error_condition_enum_v
<
>,
int
> =
0
>
(
)
noexcept
: _Myval(
0
),
_Mycat(
nullptr
)
{
*
this
=
(
);
}
void
(
int
,
const
&
)
noexcept
{
=
;
= &
;
}
template
<
class
,
<
is_error_condition_enum_v
<
>,
int
> =
0
>
&
(
)
noexcept
{
*
this
=
(
);
return
(*
this
);
}
void
()
noexcept
{
=
0
;
= &
();
}
_NODISCARD int value() const noexcept
{
return
(
);
}
_NODISCARD const error_category& category() const noexcept
const
&
()
const
noexcept
{
return
(*
);
}
_NODISCARD string message() const
{
return
(
().
(
()));
}
explicit
bool
()
const
noexcept
{
return
(
()
0
);
}
private
:
int
;
const
*
;
};
_NODISCARD inline bool operator==(const error_code& _Left, const error_code& _Right) noexcept
inline
bool
(
const
&
,
const
&
)
noexcept
{
return
(
.
()
.
()
&&
.
()
.
());
}
_NODISCARD inline bool operator==(const error_code& _Left, const error_condition& _Right) noexcept
inline
bool
(
const
&
,
const
&
)
noexcept
{
return
(
.
().
(
.
(),
)
||
.
().
(
,
.
()));
}
_NODISCARD inline bool operator==(const error_condition& _Left, const error_code& _Right) noexcept
inline
bool
(
const
&
,
const
&
)
noexcept
{
return
(
.
().
(
.
(),
)
||
.
().
(
,
.
()));
}
_NODISCARD inline bool operator==(const error_condition& _Left, const error_condition& _Right) noexcept
inline
bool
(
const
&
,
const
&
)
noexcept
{
return
(
.
()
.
()
&&
.
()
.
());
}
_NODISCARD inline bool operator!=(const error_code& _Left, const error_code& _Right) noexcept
inline
bool
(
const
&
,
const
&
)
noexcept
{
return
(!(
));
}
_NODISCARD inline bool operator!=(const error_code& _Left, const error_condition& _Right) noexcept
inline
bool
(
const
&
,
const
&
)
noexcept
{
return
(!(
));
}
_NODISCARD inline bool operator!=(const error_condition& _Left, const error_code& _Right) noexcept
inline
bool
(
const
&
,
const
&
)
noexcept
{
return
(!(
));
}
_NODISCARD inline bool operator!=(const error_condition& _Left, const error_condition& _Right) noexcept
inline
bool
(
const
&
,
const
&
)
noexcept
{
return
(!(
));
}
_NODISCARD inline bool operator<(const error_code& _Left, const error_code& _Right) noexcept
inline
bool
(
const
&
,
const
&
)
noexcept
{
return
(
.
()
.
()
|| (
.
()
.
()
&&
.
()
.
()));
}
_NODISCARD inline bool operator<(const error_condition& _Left, const error_condition& _Right) noexcept
inline
bool
(
const
&
,
const
&
)
noexcept
{
return
(
.
()
.
()
|| (
.
()
.
()
&&
.
()
.
()));
}
_NODISCARD inline error_condition error_category::default_error_condition(int _Errval) const noexcept
inline
::
(
int
)
const
noexcept
{
return
(
(
, *
this
));
}
_NODISCARD inline bool error_category::equivalent(int _Errval, const error_condition& _Cond) const noexcept
inline
bool
::
(
int
,
const
&
)
const
noexcept
{
return
(
(
)
);
}
_NODISCARD inline bool error_category::equivalent(const error_code& _Code, int _Errval) const noexcept
inline
bool
::
(
const
&
,
int
)
const
noexcept
{
return
(*
this
.
() &&
.
()
);
}
_NODISCARD inline error_condition error_code::default_error_condition() const noexcept
inline
::
()
const
noexcept
{
return
(
().
(
()));
}
_NODISCARD inline error_code make_error_code(errc _Errno) noexcept
{
return
(
((
int
)
,
()));
}
_NODISCARD inline error_code make_error_code(io_errc _Errno) noexcept
{
return
(
((
int
)
,
()));
}
_NODISCARD inline error_condition make_error_condition(errc _Errno) noexcept
{
return
(
((
int
)
,
()));
}
_NODISCARD inline error_condition make_error_condition(io_errc _Errno) noexcept
{
return
(
((
int
)
,
()));
}
template
<>
struct
<
>
{
_CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef error_code argument_type;
_CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef size_t result_type;
_NODISCARD size_t operator()(const error_code& _Keyval) const noexcept
(
const
&
)
const
noexcept
{
return
(
<
int
>{}(
.
()));
}
};
template
<>
struct
<
>
{
_CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef error_condition argument_type;
_CXX17_DEPRECATE_ADAPTOR_TYPEDEFS typedef size_t result_type;
_NODISCARD size_t operator()(const error_condition& _Keyval) const noexcept
(
const
&
)
const
noexcept
{
return
(
<
int
>{}(
.
()));
}
};
class
:
public
{
private
:
static
(
,
)
{
if
(!
.
())
{
.
(
": "
);
}
.
(
.
());
return
(
);
}
protected
:
(
,
const
&
)
:
(
(
,
)),
_Mycode(
)
{
}
;
};
class
:
public
{
private
:
typedef
;
public
:
(
)
:
(
,
""
)
{
}
(
,
const
&
)
:
(
,
)
{
}
(
,
const
char
*
)
:
(
,
)
{
}
(
int
,
const
&
)
:
(
(
,
),
""
)
{
}
(
int
,
const
&
,
const
&
)
:
(
(
,
),
)
{
}
(
int
,
const
&
,
const
char
*
)
:
(
(
,
),
)
{
}
_NODISCARD const error_code& code() const noexcept
const
&
()
const
noexcept
{
return
(
);
}
#if _HAS_EXCEPTIONS
#else /* _HAS_EXCEPTIONS */
protected:
virtual void _Doraise() const
{ // perform class-specific exception handling
_RAISE(*this);
}
#endif /* _HAS_EXCEPTIONS */
};
_CRTIMP2_PURE const char *__CLRCALL_PURE_OR_CDECL _Syserror_map(int);
const
char
*
__cdecl
(
int
);
_CRTIMP2_PURE int __CLRCALL_PURE_OR_CDECL _Winerror_map(int);
_CRTIMP2_PURE unsigned long __CLRCALL_PURE_OR_CDECL _Winerror_message(
unsigned
long
,
char
*
,
unsigned
long
);
class
:
public
{
public
:
()
noexcept
{
=
;
}
_NODISCARD virtual const char *name() const noexcept override
virtual
const
char
*
()
const
noexcept
override
{
return
(
"generic"
);
}
_NODISCARD virtual string message(int _Errcode) const override
virtual
(
int
)
const
override
{
return
(
(
));
}
};
class
:
public
{
public
:
()
noexcept
{
=
;
}
_NODISCARD virtual const char *name() const noexcept override
virtual
const
char
*
()
const
noexcept
override
{
return
(
"iostream"
);
}
_NODISCARD virtual string message(int _Errcode) const override
virtual
(
int
)
const
override
{
if
(
(
int
)
::
)
{
return
(
"iostream stream error"
);
}
else
{
return
(
::
(
));
}
}
};
class
:
public
{
public
:
()
noexcept
{
=
;
}
_NODISCARD virtual const char *name() const noexcept override
virtual
const
char
*
()
const
noexcept
override
{
return
(
"system"
);
}
_NODISCARD virtual string message(int _Errcode) const override
virtual
(
int
)
const
override
{
const
unsigned
long
=
32767
;
(
_Size
,
'\0'
);
const
unsigned
long
=
(
static_cast
<
unsigned
long
>(
), &
_Narrow
0
],
_Size
);
if
(
_Val
0
)
{
_Narrow
"unknown error"
;
}
else
{
_Narrow
.
(
_Val
);
}
_Narrow
.
();
return
(
_Narrow
);
}
_NODISCARD virtual error_condition default_error_condition(int _Errval) const noexcept override
virtual
(
int
)
const
noexcept
override
{
const
int
=
(
);
if
(
_Posv
0
)
{
return
(
(
,
()));
}
else
{
return
(
(
_Posv
,
()));
}
}
};
#ifdef _M_CEE_PURE
template<class _Ty>
struct _Immortalizer
{ // constructs _Ty, never destroys
_Immortalizer()
{ // construct _Ty inside _Storage
::new (static_cast<void *>(&_Storage)) _Ty();
}
_Immortalizer(const _Immortalizer&) = delete;
_Immortalizer& operator=(const _Immortalizer&) = delete;
aligned_union_t<1, _Ty> _Storage;
};
template<class _Ty> inline
_Ty& _Immortalize()
{ // return a reference to an object that will live forever
/* MAGIC */ static _Immortalizer<_Ty> _Static;
return (reinterpret_cast<_Ty&>(_Static._Storage));
}
#else /* ^^^ _M_CEE_PURE ^^^ // vvv !_M_CEE_PURE vvv */
template
<
class
>
inline
int
__stdcall
(
void
*,
void
*
,
void
**)
noexcept
{
::
new
(
)
();
return
(
1
);
}
template
<
class
>
inline
&
()
{
static_assert
(
sizeof
(
void
*)
sizeof
(
),
"TRANSITION, VSO#406237"
);
static_assert
(alignof(
void
*)
alignof(
),
"TRANSITION, VSO#406237"
);
static
void
*
=
nullptr
;
static
<
1
,
>
;
if
(
(
reinterpret_cast
<
&>(
_Flag
),
<
>, &
_Storage
)
0
)
{
}
return
(
reinterpret_cast
<
&>(
_Storage
));
}
#endif /* _M_CEE_PURE */
_NODISCARD inline const error_category& generic_category() noexcept
inline
const
&
()
noexcept
{
return
(
<
>());
}
_NODISCARD inline const error_category& iostream_category() noexcept
inline
const
&
()
noexcept
{
return
(
<
>());
}
_NODISCARD inline const error_category& system_category() noexcept
inline
const
&
()
noexcept
{
return
(
<
>());
}
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma warning(pop)
#pragma pack(pop)
#endif /* RC_INVOKED */
#endif /* _SYSTEM_ERROR_ */
#pragma pack(pop)