1#ifndef NEFORCE_CORE_MEMORY_CONSTRUCT_HPP__
2#define NEFORCE_CORE_MEMORY_CONSTRUCT_HPP__
13NEFORCE_BEGIN_NAMESPACE__
32template <
typename T,
typename... Args>
34 static_assert(
is_constructible_v<T, Args...>,
"T must be constructible with arguments");
35 return static_cast<T*
>(
new (
static_cast<void*
>(ptr)) T(_NEFORCE
forward<Args>(args)...));
59template <
typename Iterator>
62 for (; first < last; ++first) {
77template <
typename Iterator>
79destroy(Iterator first, Iterator last)
noexcept {
85struct temporary_guard {
93 constexpr explicit temporary_guard(T& value) :
95 temp(_NEFORCE
move(value)) {
99 NEFORCE_CONSTEXPR20 ~temporary_guard() {
105 temporary_guard(
const temporary_guard&) =
delete;
106 temporary_guard& operator=(
const temporary_guard&) =
delete;
108 constexpr T&& release() noexcept {
109 guarded_ptr =
nullptr;
110 return _NEFORCE
move(temp);
114template <
typename NT,
typename OT,
typename Arg>
122template <
typename NT,
typename OT,
typename Arg>
131template <
typename NT,
typename OT,
typename Arg>
134 temporary_guard<OT> guard(*old_val);
142NEFORCE_END_NAMESPACE__
NEFORCE_NODISCARD constexpr T * addressof(T &x) noexcept
获取对象的地址
NEFORCE_NODISCARD constexpr T && forward(remove_reference_t< T > &x) noexcept
完美转发左值
NEFORCE_CONSTEXPR20 T * construct(T *ptr, Args &&... args) noexcept(is_nothrow_constructible_v< T, Args... >)
在指定内存位置构造对象
NEFORCE_CONSTEXPR20 void destroy(T *pointer) noexcept(is_nothrow_destructible_v< T >)
销毁单个对象
constexpr Iterator2 move(Iterator1 first, Iterator1 last, Iterator2 result) noexcept(noexcept(inner::__move_aux(first, last, result)))
移动范围元素
NEFORCE_INLINE17 constexpr bool is_nothrow_constructible_v
is_nothrow_constructible的便捷变量模板
NEFORCE_INLINE17 constexpr bool is_trivially_destructible_v
is_trivially_destructible的便捷变量模板
NEFORCE_INLINE17 constexpr bool is_nothrow_destructible_v
is_nothrow_destructible的便捷变量模板
NEFORCE_INLINE17 constexpr bool is_constructible_v
is_constructible的便捷变量模板
NEFORCE_INLINE17 constexpr bool is_nothrow_move_constructible_v
is_nothrow_move_constructible的便捷变量模板
typename enable_if< Test, T >::type enable_if_t
enable_if的便捷别名