#pragma once
#ifndef _XMEMORY_
#define _XMEMORY_
#ifndef RC_INVOKED
#include <xmemory0>
#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
>
inline
<
*,
>
(
)
noexcept
{
if
(
static_cast
<
>(
) <=
static_cast
<
>(-
1
) /
sizeof
(
))
{
for
(;
0
;
/=
2
)
{
const
auto
=
static_cast
<
>(
) *
sizeof
(
);
void
*
;
#if _HAS_ALIGNED_NEW
#pragma warning(push)
#pragma warning(disable: 4127) // conditional expression is constant
#pragma warning(disable: 6326) // Potential comparison of a constant with another constant
if /* constexpr */ (alignof(_Ty) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
{
_Pbuf = ::operator new(_Size, align_val_t{alignof(_Ty)}, nothrow);
}
else
#pragma warning(pop)
#endif /* _HAS_ALIGNED_NEW */
{
_Pbuf
= ::
_Size
,
nothrow
);
}
if
(
_Pbuf
)
{
return
{
static_cast
<
*>(
_Pbuf
),
};
}
}
}
return
{
nullptr
,
0
};
}
template
<
class
>
inline
void
(
*
const
)
noexcept
{
#if _HAS_ALIGNED_NEW
#pragma warning(push)
#pragma warning(disable: 4127) // conditional expression is constant
#pragma warning(disable: 6326) // Potential comparison of a constant with another constant
if /* constexpr */ (alignof(_Ty) > __STDCPP_DEFAULT_NEW_ALIGNMENT__)
{
::operator delete(_Pbuf, align_val_t{alignof(_Ty)});
}
else
#pragma warning(pop)
#endif /* _HAS_ALIGNED_NEW */
{
::
);
}
}
template
<
class
>
struct
{
;
;
explicit
(
)
: _First(
),
_Last(
)
{}
(
,
)
: _First(
),
_Last(
)
{}
(
const
&) =
delete
;
&
(
const
&) =
delete
;
()
{
(
,
);
}
template
<
class
...
>
void
(
&&...
)
{
_Construct_in_place(*_Last, _STD forward<_Types>(_Vals)...);
++
;
}
()
{
=
;
return
(
);
}
};
template
<
class
,
class
>
inline
_Uninitialized_move_unchecked1
(
,
const
,
const
,
_General_ptr_iterator_tag
)
{
<
>
{
};
for
(;
!=
; ++
)
{
_Backout._Emplace_back(_STD move(*_First));
}
return
(
_Backout
.
());
}
template
<
class
,
class
>
inline
_Uninitialized_move_unchecked1
(
const
,
const
,
const
,
_Really_trivial_ptr_iterator_tag
)
{
return
(
(
,
,
));
}
template
<
class
,
class
>
inline
_Uninitialized_move_unchecked
(
const
,
const
,
const
)
{
return
(
_Uninitialized_move_unchecked1
(
,
,
,
(
,
)));
}
template
<
class
,
class
>
class
_Uninitialized_backout_al
{
public
:
_Uninitialized_backout_al
(
,
&
)
: _First(
),
_Last(
),
_Al(
)
{
}
_Uninitialized_backout_al
(
const
_Uninitialized_backout_al
&) =
delete
;
_Uninitialized_backout_al
&
(
const
_Uninitialized_backout_al
&) =
delete
;
~
_Uninitialized_backout_al
()
{
(
,
,
);
}
template
<
class
...
>
void
(
&&...
)
{
allocator_traits<_Alloc>::construct(_Al, _Unfancy(_Last), _STD forward<_Types>(_Vals)...);
<
>::
(
,
(
), ::
std
::
<
>(
)...);
++
;
}
()
{
=
;
return
(
);
}
private
:
;
;
&
;
};
template
<
class
,
class
,
class
>
inline
_Uninitialized_copy_al_unchecked
(
,
const
,
const
,
&
,
_General_ptr_iterator_tag
,
)
{
_Uninitialized_backout_al
<
,
>
{
,
};
for
(;
!=
; ++
)
{
_Backout
.
(*
);
}
return
(
_Backout
.
());
}
template
<
class
,
class
,
class
>
inline
*
_Uninitialized_copy_al_unchecked
(
*
const
,
*
const
,
*
const
,
&,
_Really_trivial_ptr_iterator_tag
,
)
{
return
(
(
,
,
));
}
template
<
class
,
class
,
class
>
inline
(
const
,
const
,
,
&
)
{
const
auto
=
(
);
const
auto
=
(
);
const
auto
=
(
,
<
>(
_UFirst
,
_ULast
));
(
,
_Uninitialized_copy_al_unchecked
(
_UFirst
,
_ULast
,
_UDest
,
,
(
_UFirst
,
_UDest
),
_Uses_default_construct_t
<
,
decltype
(
(
_UDest
)),
decltype
(*
_UFirst
)>()));
return
(
);
}
template
<
class
,
class
,
class
>
inline
_Uninitialized_move_al_unchecked
(
,
const
,
const
,
&
,
_General_ptr_iterator_tag
,
)
{
_Uninitialized_backout_al
<
,
>
{
,
};
for
(;
!=
; ++
)
{
_Backout._Emplace_back(_STD move(*_First));
}
return
(
_Backout
.
());
}
template
<
class
,
class
,
class
>
inline
*
_Uninitialized_move_al_unchecked
(
*
const
,
*
const
,
*
const
,
&,
_Really_trivial_ptr_iterator_tag
,
)
{
return
(
(
,
,
));
}
template
<
class
,
class
,
class
>
inline
(
const
,
const
,
,
&
)
{
const
auto
=
(
);
const
auto
=
(
);
const
auto
=
(
,
<
>(
_UFirst
,
_ULast
));
(
,
_Uninitialized_move_al_unchecked
(
_UFirst
,
_ULast
,
_UDest
,
,
(
_UFirst
,
_UDest
),
_Uses_default_construct_t<_Alloc, decltype(_Unfancy(_UDest)), decltype(_STD move(*_UFirst))>()));
_Uses_default_construct_t
<
,
decltype
(
(
_UDest
)),
decltype
(::
std
::
(*
_UFirst
))>()));
return
(
);
}
template
<
class
,
class
,
class
>
inline
(
const
,
,
const
<
>&
,
&
,
)
{
_Uninitialized_backout_al
<
,
>
{
,
};
for
(;
0
<
; --
)
{
_Backout
.
(
);
}
return
(
_Backout
.
());
}
template
<
class
,
class
,
class
>
inline
(
const
,
const
,
const
<
>&
,
&,
)
{
_CSTD memset(_First, static_cast<unsigned char>(_Val), static_cast<size_t>(_Count));
::
(
,
static_cast
<
unsigned
char
>(
),
static_cast
<
>(
));
return
(
+
);
}
template
<
class
,
class
,
class
>
inline
(
const
,
const
,
const
<
>&
,
&
)
{
return
(
(
,
,
,
,
<
<
decltype
(
(
,
)),
<
,
decltype
(
(
)),
decltype
(
)>>>{}));
}
template
<
class
>
using
_Use_memset_value_construct_t
=
<
<
<
>,
<
<
>>,
<
<
<
>>>,
<
<
<
>>>>>;
template
<
class
>
inline
(
const
,
const
)
{
char
*
const
=
reinterpret_cast
<
char
*>(
);
char
*
const
=
reinterpret_cast
<
char
*>(
);
_CSTD memset(_First_ch, 0, static_cast<size_t>(_Last_ch - _First_ch));
::
(
_First_ch
,
0
,
static_cast
<
>(
_Last_ch
-
_First_ch
));
return
(
);
}
template
<
class
,
class
,
class
>
inline
_Uninitialized_value_construct_n1
(
const
,
,
&
,
)
{
_Uninitialized_backout_al
<
,
>
{
,
};
for
(;
0
<
; --
)
{
_Backout
.
();
}
return
(
_Backout
.
());
}
template
<
class
,
class
,
class
>
inline
_Uninitialized_value_construct_n1
(
,
,
&,
)
{
return
(
(
,
+
));
}
template
<
class
,
class
,
class
>
inline
_Uninitialized_value_construct_n
(
,
,
&
)
{
return
(
_Uninitialized_value_construct_n1
(
,
,
,
<
<
_Use_memset_value_construct_t
<
>,
<
,
decltype
(
(
))>>>{}));
}
struct
{
};
template
<
class
>
_NODISCARD _CXX17_DEPRECATE_TEMPORARY_BUFFER pair<_Ty *, ptrdiff_t> get_temporary_buffer(ptrdiff_t _Count) noexcept
{
return
(
<
>(
));
}
template
<
class
>
_CXX17_DEPRECATE_TEMPORARY_BUFFER void return_temporary_buffer(_Ty * _Pbuf)
{
(
);
}
#pragma pop_macro("new")
_STL_RESTORE_CLANG_WARNINGS
#pragma warning(pop)
#pragma warning(pop)
#pragma pack(pop)
#endif /* RC_INVOKED */
#endif /* _XMEMORY_ */
#pragma pack(pop)