summaryrefslogtreecommitdiff
path: root/asl/memory.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'asl/memory.hpp')
-rw-r--r--asl/memory.hpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/asl/memory.hpp b/asl/memory.hpp
index 7601a7f..0441c8c 100644
--- a/asl/memory.hpp
+++ b/asl/memory.hpp
@@ -56,24 +56,23 @@ constexpr void destruct_n(T* data, isize_t n)
}
}
-template<typename T>
+template<move_constructible T>
constexpr void relocate_uninit_n(T* to, T* from, isize_t n)
{
- if constexpr (trivially_copyable<T>)
+ if constexpr (trivially_move_constructible<T>)
{
+ static_assert(trivially_destructible<T>);
memcpy(to, from, size_of<T> * n);
}
else
{
- static_assert(move_constructible<T>);
for (isize_t i = 0; i < n; ++i)
{
// NOLINTNEXTLINE(*-pointer-arithmetic)
construct_at<T>(to + i, ASL_MOVE(from[i]));
}
+ destruct_n(from, n);
}
-
- destruct_n(from, n);
}
} // namespace asl