From 5642cba31b5f7610eddf552b1acd984cf718340d Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Fri, 27 Dec 2024 19:19:40 +0100 Subject: Rework some metaprogramming stuff --- asl/memory.hpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'asl/memory.hpp') 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 +template constexpr void relocate_uninit_n(T* to, T* from, isize_t n) { - if constexpr (trivially_copyable) + if constexpr (trivially_move_constructible) { + static_assert(trivially_destructible); memcpy(to, from, size_of * n); } else { - static_assert(move_constructible); for (isize_t i = 0; i < n; ++i) { // NOLINTNEXTLINE(*-pointer-arithmetic) construct_at(to + i, ASL_MOVE(from[i])); } + destruct_n(from, n); } - - destruct_n(from, n); } } // namespace asl -- cgit