summaryrefslogtreecommitdiff
path: root/asl/memory.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'asl/memory.hpp')
-rw-r--r--asl/memory.hpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/asl/memory.hpp b/asl/memory.hpp
index cfc7057..1209bf6 100644
--- a/asl/memory.hpp
+++ b/asl/memory.hpp
@@ -75,5 +75,24 @@ constexpr void relocate_uninit_n(T* to, T* from, isize_t n)
}
}
+template<move_assignable T>
+constexpr void relocate_assign_n(T* to, T* from, isize_t n)
+{
+ if constexpr (trivially_move_assignable<T>)
+ {
+ static_assert(trivially_destructible<T>);
+ memcpy(to, from, size_of<T> * n);
+ }
+ else
+ {
+ for (isize_t i = 0; i < n; ++i)
+ {
+ // NOLINTNEXTLINE(*-pointer-arithmetic)
+ to[i] = ASL_MOVE(from[i]);
+ }
+ destroy_n(from, n);
+ }
+}
+
} // namespace asl