#pragma once
#ifndef _UTILITY_
#define _UTILITY_
#ifndef RC_INVOKED
#include <xstddef>
#include <iosfwd>
#include <type_traits>
#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
template
<
class
>
_Post_equal_to_(_Right < _Left ? _Right : _Left)
constexpr
const
&
(
const
&
,
const
&
)
_NOEXCEPT_COND(_NOEXCEPT_OPER(_Right < _Left))
{
return
(
<
?
:
);
}
template
<
class
>
_Post_equal_to_(_Left < _Right ? _Right : _Left)
constexpr
const
&
(
const
&
,
const
&
)
_NOEXCEPT_COND(_NOEXCEPT_OPER(_Left < _Right))
{
return
(
<
?
:
);
}
template
<
class
,
class
>
inline
void
(
,
)
{
(*
, *
);
}
template
<
class
,
,
class
>
inline
void
(
(&
)[
],
(&
)[
])
_NOEXCEPT_COND(_Is_nothrow_swappable<_Ty>::value)
{
if
(&
&
)
{
*
=
;
*
=
_First1
+
;
*
=
;
for
(;
_First1
_Last1
; ++
_First1
, ++
_First2
)
_STD iter_swap(_First1, _First2);
::
std
::
(
_First1
,
_First2
);
}
}
template
<
class
,
class
>
inline
void
(
&
,
&
)
_NOEXCEPT_COND(is_nothrow_move_constructible_v<_Ty>
&& is_nothrow_move_assignable_v<_Ty>)
noexcept
(
is_nothrow_move_constructible_v
<
> &&
is_nothrow_move_assignable_v
<
>)
{
_Ty _Tmp = _STD move(_Left);
_Left = _STD move(_Right);
_Right = _STD move(_Tmp);
}
template
<
class
>
inline
void
(
&
,
&
)
_NOEXCEPT_COND(_Is_nothrow_swappable<_Ty>::value)
{
(
,
);
}
struct
{
explicit
() =
default
;
};
_INLINE_VAR constexpr piecewise_construct_t piecewise_construct{};
template
<
class
...>
class
;
template
<
class
,
class
>
struct
{
using
=
;
using
=
;
template
<
class
=
,
class
=
,
<
<
<
>,
<
>,
_Is_implicitly_default_constructible
<
>,
_Is_implicitly_default_constructible
<
>
>,
int
> =
0
>
constexpr
()
_NOEXCEPT_COND(is_nothrow_default_constructible_v<_Uty1>
&& is_nothrow_default_constructible_v<_Uty2>) // strengthened
noexcept
(
is_nothrow_default_constructible_v
<
> &&
is_nothrow_default_constructible_v
<
>)
: first(), second()
{
}
template
<
class
=
,
class
=
,
<
<
<
>,
<
>,
<
<
_Is_implicitly_default_constructible
<
>,
_Is_implicitly_default_constructible
<
>>>
>,
int
> =
0
>
constexpr
explicit
()
_NOEXCEPT_COND(is_nothrow_default_constructible_v<_Uty1>
&& is_nothrow_default_constructible_v<_Uty2>) // strengthened
noexcept
(
is_nothrow_default_constructible_v
<
> &&
is_nothrow_default_constructible_v
<
>)
: first(), second()
{
}
template
<
class
=
,
class
=
,
<
<
<
>,
<
>,
<
const
&,
>,
<
const
&,
>
>,
int
> =
0
>
constexpr
(
const
&
,
const
&
)
_NOEXCEPT_COND(is_nothrow_copy_constructible_v<_Uty1>
&& is_nothrow_copy_constructible_v<_Uty2>) // strengthened
noexcept
(
is_nothrow_copy_constructible_v
<
> &&
is_nothrow_copy_constructible_v
<
>)
: first(
), second(
)
{
}
template
<
class
=
,
class
=
,
<
<
<
>,
<
>,
<
<
<
const
&,
>,
<
const
&,
>>>
>,
int
> =
0
>
constexpr
explicit
(
const
&
,
const
&
)
_NOEXCEPT_COND(is_nothrow_copy_constructible_v<_Uty1>
&& is_nothrow_copy_constructible_v<_Uty2>) // strengthened
noexcept
(
is_nothrow_copy_constructible_v
<
> &&
is_nothrow_copy_constructible_v
<
>)
: first(
), second(
)
{
}
template
<
class
,
class
,
<
<
<
,
>,
<
,
>,
<
,
>,
<
,
>
>,
int
> =
0
>
constexpr
(
&&
,
&&
)
_NOEXCEPT_COND(is_nothrow_constructible_v<_Ty1, _Other1>
&& is_nothrow_constructible_v<_Ty2, _Other2>) // strengthened
noexcept
(
is_nothrow_constructible_v
<
,
> &&
is_nothrow_constructible_v
<
,
>)
: first(_STD forward<_Other1>(_Val1)),
second(_STD forward<_Other2>(_Val2))
{
}
template
<
class
,
class
,
<
<
<
,
>,
<
,
>,
<
<
<
,
>,
<
,
>>>
>,
int
> =
0
>
constexpr
explicit
(
&&
,
&&
)
_NOEXCEPT_COND(is_nothrow_constructible_v<_Ty1, _Other1>
&& is_nothrow_constructible_v<_Ty2, _Other2>) // strengthened
noexcept
(
is_nothrow_constructible_v
<
,
> &&
is_nothrow_constructible_v
<
,
>)
: first(_STD forward<_Other1>(_Val1)),
second(_STD forward<_Other2>(_Val2))
{
}
(
const
&) =
default
;
(
&&) =
default
;
template
<
class
,
class
,
<
<
<
,
const
&>,
<
,
const
&>,
<
const
&,
>,
<
const
&,
>
>,
int
> =
0
>
constexpr
(
const
<
,
>&
)
_NOEXCEPT_COND(is_nothrow_constructible_v<_Ty1, const _Other1&>
&& is_nothrow_constructible_v<_Ty2, const _Other2&>) // strengthened
noexcept
(
is_nothrow_constructible_v
<
,
const
&> &&
is_nothrow_constructible_v
<
,
const
&>)
: first(
.
), second(
.
)
{
}
template
<
class
,
class
,
<
<
<
,
const
&>,
<
,
const
&>,
<
<
<
const
&,
>,
<
const
&,
>>>
>,
int
> =
0
>
constexpr
explicit
(
const
<
,
>&
)
_NOEXCEPT_COND(is_nothrow_constructible_v<_Ty1, const _Other1&>
&& is_nothrow_constructible_v<_Ty2, const _Other2&>) // strengthened
noexcept
(
is_nothrow_constructible_v
<
,
const
&> &&
is_nothrow_constructible_v
<
,
const
&>)
: first(
.
), second(
.
)
{
}
template
<
class
,
class
,
<
<
<
,
>,
<
,
>,
<
,
>,
<
,
>
>,
int
> =
0
>
constexpr
(
<
,
>&&
)
_NOEXCEPT_COND(is_nothrow_constructible_v<_Ty1, _Other1>
&& is_nothrow_constructible_v<_Ty2, _Other2>) // strengthened
noexcept
(
is_nothrow_constructible_v
<
,
> &&
is_nothrow_constructible_v
<
,
>)
: first(_STD forward<_Other1>(_Right.first)),
second(_STD forward<_Other2>(_Right.second))
{
}
template
<
class
,
class
,
<
<
<
,
>,
<
,
>,
<
<
<
,
>,
<
,
>>>
>,
int
> =
0
>
constexpr
explicit
(
<
,
>&&
)
_NOEXCEPT_COND(is_nothrow_constructible_v<_Ty1, _Other1>
&& is_nothrow_constructible_v<_Ty2, _Other2>) // strengthened
noexcept
(
is_nothrow_constructible_v
<
,
> &&
is_nothrow_constructible_v
<
,
>)
: first(_STD forward<_Other1>(_Right.first)),
second(_STD forward<_Other2>(_Right.second))
{
}
template
<
class
,
class
,
...
,
...
>
inline
(
&
,
&
,
<
...>,
<
...>);
template
<
class
...
,
class
...
>
inline
(
,
<
...>
,
<
...>
);
&
(
const
volatile
&) =
delete
;
template
<
class
=
,
class
=
,
<
<
<
&,
const
&>,
<
&,
const
&>
>,
int
> =
0
>
&
(
const
<
,
>&
)
_NOEXCEPT_COND(is_nothrow_assignable_v<_Ty1&, const _Other1&>
&& is_nothrow_assignable_v<_Ty2&, const _Other2&>) // strengthened
noexcept
(
<
&,
const
&> &&
<
&,
const
&>)
{
=
.
;
=
.
;
return
(*
this
);
}
template
<
class
=
,
class
=
,
<
<
<
&,
>,
<
&,
>
>,
int
> =
0
>
&
(
<
,
>&&
)
_NOEXCEPT_COND(is_nothrow_assignable_v<_Ty1&, _Other1>
&& is_nothrow_assignable_v<_Ty2&, _Other2>) // strengthened
{
first = _STD forward<_Other1>(_Right.first);
second = _STD forward<_Other2>(_Right.second);
return
(*
this
);
}
void
(
&
)
_NOEXCEPT_COND(_Is_nothrow_swappable<_Ty1>::value
&& _Is_nothrow_swappable<_Ty2>::value)
{
if (this != _STD addressof(_Right))
{
(
,
.
);
(
,
.
);
}
}
;
;
};
#if _HAS_CXX17
template<class _Ty1,
class _Ty2>
pair(_Ty1, _Ty2) -> pair<_Ty1, _Ty2>;
#endif /* _HAS_CXX17 */
template
<
class
,
class
,
class
=
<
<
>::
&&
<
>::
>>
inline
void
(
<
,
>&
,
<
,
>&
)
_NOEXCEPT_COND(_NOEXCEPT_OPER(_Left.swap(_Right)))
{
.
(
);
}
template
<
class
,
class
>
_NODISCARD constexpr bool operator==(const pair<_Ty1, _Ty2>& _Left, const pair<_Ty1, _Ty2>& _Right)
constexpr
bool
(
const
<
,
>&
,
const
<
,
>&
)
{
return
(
.
==
.
&&
.
==
.
);
}
template
<
class
,
class
>
_NODISCARD constexpr bool operator!=(const pair<_Ty1, _Ty2>& _Left, const pair<_Ty1, _Ty2>& _Right)
constexpr
bool
(
const
<
,
>&
,
const
<
,
>&
)
{
return
(!(
));
}
template
<
class
,
class
>
_NODISCARD constexpr bool operator<(const pair<_Ty1, _Ty2>& _Left, const pair<_Ty1, _Ty2>& _Right)
constexpr
bool
(
const
<
,
>&
,
const
<
,
>&
)
{
return
(
.
<
.
||
(!(
.
<
.
) &&
.
<
.
));
}
template
<
class
,
class
>
_NODISCARD constexpr bool operator>(const pair<_Ty1, _Ty2>& _Left, const pair<_Ty1, _Ty2>& _Right)
constexpr
bool
(
const
<
,
>&
,
const
<
,
>&
)
{
return
(
);
}
template
<
class
,
class
>
_NODISCARD constexpr bool operator<=(const pair<_Ty1, _Ty2>& _Left, const pair<_Ty1, _Ty2>& _Right)
constexpr
bool
(
const
<
,
>&
,
const
<
,
>&
)
{
return
(!(
));
}
template
<
class
,
class
>
_NODISCARD constexpr bool operator>=(const pair<_Ty1, _Ty2>& _Left, const pair<_Ty1, _Ty2>& _Right)
constexpr
bool
(
const
<
,
>&
,
const
<
,
>&
)
{
return
(!(
));
}
template
<
class
>
struct
{
using
=
;
};
template
<
class
>
struct
<
<
>>
{
using
=
&;
};
template
<
class
>
using
=
typename
<
<
>>::
;
template
<
class
,
class
>
_NODISCARD constexpr pair<_Unrefwrap_t<_Ty1>, _Unrefwrap_t<_Ty2>>
(
&&
,
&&
)
{
using
=
<
<
>,
<
>>;
return (_Mypair(_STD forward<_Ty1>(_Val1), _STD forward<_Ty2>(_Val2)));
return
(
(::
std
::
<
>(
), ::
std
::
<
>(
)));
}
namespace
{
template
<
class
>
_NODISCARD inline bool operator!=(const _Ty& _Left, const _Ty& _Right)
inline
bool
(
const
&
,
const
&
)
{
return
(!(
==
));
}
template
<
class
>
_NODISCARD inline bool operator>(const _Ty& _Left, const _Ty& _Right)
inline
bool
(
const
&
,
const
&
)
{
return
(
<
);
}
template
<
class
>
_NODISCARD inline bool operator<=(const _Ty& _Left, const _Ty& _Right)
inline
bool
(
const
&
,
const
&
)
{
return
(!(
<
));
}
template
<
class
>
_NODISCARD inline bool operator>=(const _Ty& _Left, const _Ty& _Right)
inline
bool
(
const
&
,
const
&
)
{
return
(!(
<
));
}
}
template
<
class
>
struct
;
template
<
class
,
class
=
void
>
struct
{
};
template
<
class
>
struct
<
,
<
decltype
(
<
>::value)>>
:
<
,
<
>::value>
{
};
template
<
class
>
struct
<
const
>
:
<
>
{
};
template
<
class
>
struct
<
volatile
>
:
<
>
{
};
template
<
class
>
struct
<
const
volatile
>
:
<
>
{
};
template
<
class
>
_INLINE_VAR constexpr size_t tuple_size_v = tuple_size<_Ty>::value;
template
<
,
class
>
struct
;
template
<
,
class
>
struct
<
,
const
>
:
public
<
,
>
{
using
=
<
,
>;
using
=
<
typename
::type>;
};
template
<
,
class
>
struct
<
,
volatile
>
:
public
<
,
>
{
using
=
<
,
>;
using
=
<
typename
::
>;
};
template
<
,
class
>
struct
<
,
const
volatile
>
:
public
<
,
>
{
using
=
<
,
>;
using
=
<
typename
::
>;
};
template
<
,
class
>
using
=
typename
<
,
>::
;
template
<
class
,
>
class
;
template
<
class
,
>
struct
<
<
,
> >
:
<
,
>
{
};
template
<
,
class
,
>
struct
<
,
<
,
>>
{
static_assert
(
,
"array index out of bounds"
);
using
=
;
};
template
<
class
...
>
struct
<
<
...>>
:
<
,
sizeof
...(
)>
{
};
template
<
>
struct
<
,
<>>
{
static_assert
(
<
<
,
>>,
"tuple index out of bounds"
);
};
template
<
class
,
class
...
>
struct
<
0
,
<
,
...>>
{
using
=
;
using
=
<
,
...>;
};
template
<
,
class
,
class
...
>
struct
<
,
<
,
...>>
:
public
<
-
1
,
<
...>>
{
};
template
<
class
,
class
>
struct
<
<
,
>>
:
<
,
2
>
{
};
template
<
,
class
,
class
>
struct
<
,
<
,
>>
{
static_assert
(
2
,
"pair index out of bounds"
);
using
=
<
0
,
,
>;
};
template
<
class
,
class
>
constexpr
(
&
,
<
,
0
>)
noexcept
{
return
(
.first);
}
template
<
class
,
class
>
constexpr
(
&
,
<
,
1
>)
noexcept
{
return
(
.second);
}
template
<
,
class
,
class
>
_NODISCARD constexpr tuple_element_t<_Idx, pair<_Ty1, _Ty2>>&
(
<
,
>&
)
noexcept
{
using
=
<
,
<
,
>>&;
return
(
<
>(
,
<
,
>()));
}
template
<
class
,
class
>
_NODISCARD constexpr _Ty1& get(pair<_Ty1, _Ty2>& _Pr) noexcept
constexpr
&
(
<
,
>&
)
noexcept
{
return (_STD get<0>(_Pr));
}
template
<
class
,
class
>
_NODISCARD constexpr _Ty2& get(pair<_Ty1, _Ty2>& _Pr) noexcept
constexpr
&
(
<
,
>&
)
noexcept
{
return (_STD get<1>(_Pr));
}
template
<
,
class
,
class
>
_NODISCARD constexpr const tuple_element_t<_Idx, pair<_Ty1, _Ty2>>&
constexpr
const
<
,
<
,
>>&
(
const
<
,
>&
)
noexcept
{
using
=
const
<
,
<
,
>>&;
return
(
<
>(
,
<
,
>()));
}
template
<
class
,
class
>
_NODISCARD constexpr const _Ty1& get(const pair<_Ty1, _Ty2>& _Pr) noexcept
constexpr
const
&
(
const
<
,
>&
)
noexcept
{
return (_STD get<0>(_Pr));
}
template
<
class
,
class
>
_NODISCARD constexpr const _Ty2& get(const pair<_Ty1, _Ty2>& _Pr) noexcept
constexpr
const
&
(
const
<
,
>&
)
noexcept
{
return (_STD get<1>(_Pr));
}
template
<
,
class
,
class
>
_NODISCARD constexpr tuple_element_t<_Idx, pair<_Ty1, _Ty2>>&&
(
<
,
>&&
)
noexcept
{
using
=
<
,
<
,
>>&&;
return (_STD forward<_RRtype>(_STD get<_Idx>(_Pr)));
return
(::
std
::
<
>(::
std
::
<
>(
)));
}
template
<
class
,
class
>
_NODISCARD constexpr _Ty1&& get(pair<_Ty1, _Ty2>&& _Pr) noexcept
constexpr
&&
(
<
,
>&&
)
noexcept
{
return (_STD get<0>(_STD move(_Pr)));
return
(::
std
::
<
0
>(::
std
::
(
)));
}
template
<
class
,
class
>
_NODISCARD constexpr _Ty2&& get(pair<_Ty1, _Ty2>&& _Pr) noexcept
constexpr
&&
(
<
,
>&&
)
noexcept
{
return (_STD get<1>(_STD move(_Pr)));
return
(::
std
::
<
1
>(::
std
::
(
)));
}
template
<
,
class
,
class
>
_NODISCARD constexpr const tuple_element_t<_Idx, pair<_Ty1, _Ty2>>&&
constexpr
const
<
,
<
,
>>&&
(
const
<
,
>&&
)
noexcept
{
using
=
const
<
,
<
,
>>&&;
return (_STD forward<_RRtype>(_STD get<_Idx>(_Pr)));
return
(::
std
::
<
>(::
std
::
<
>(
)));
}
template
<
class
,
class
>
_NODISCARD constexpr const _Ty1&& get(const pair<_Ty1, _Ty2>&& _Pr) noexcept
constexpr
const
&&
(
const
<
,
>&&
)
noexcept
{
return (_STD get<0>(_STD move(_Pr)));
return
(::
std
::
<
0
>(::
std
::
(
)));
}
template
<
class
,
class
>
_NODISCARD constexpr const _Ty2&& get(const pair<_Ty1, _Ty2>&& _Pr) noexcept
constexpr
const
&&
(
const
<
,
>&&
)
noexcept
{
return (_STD get<1>(_STD move(_Pr)));
return
(::
std
::
<
1
>(::
std
::
(
)));
}
template
<
class
,
class
=
>
inline
(
&
,
&&
)
{
_Ty _Old_val = _STD move(_Val);
_Val = _STD forward<_Other>(_New_val);
return
(
_Old_val
);
}
template
<
class
>
_NODISCARD constexpr add_const_t<_Ty>& as_const(_Ty& _Val) noexcept
constexpr
<
>&
(
&
)
noexcept
{
return
(
);
}
template
<
class
>
void
(
const
&&) =
delete
;
#if _HAS_CXX17
// in_place TAG TYPE TEMPLATES
struct in_place_t
{ // tag used to select a constructor which initializes a contained object in place
explicit in_place_t() = default;
};
_INLINE_VAR constexpr in_place_t in_place{};
template<class>
struct in_place_type_t
{ // tag that selects a type to construct in place
explicit in_place_type_t() = default;
};
template<class _Ty>
_INLINE_VAR constexpr in_place_type_t<_Ty> in_place_type{};
template<size_t>
struct in_place_index_t
{ // tag that selects the index of a type to construct in place
explicit in_place_index_t() = default;
};
template<size_t _Idx>
_INLINE_VAR constexpr in_place_index_t<_Idx> in_place_index{};
#endif /* _HAS_CXX17 */
#if _HAS_TR1_NAMESPACE
namespace _DEPRECATE_TR1_NAMESPACE tr1 {
namespace
[[deprecated(
"warning STL4002: "
"The non-Standard std::tr1 namespace and TR1-only machinery are deprecated and will be REMOVED. You can "
"define _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING to acknowledge that you have received this warning."
)]]
{
using _STD tuple_element;
}
#endif /* _HAS_TR1_NAMESPACE */
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma warning(pop)
#pragma pack(pop)
#endif /* RC_INVOKED */
#endif /* _UTILITY_ */
#pragma pack(pop)