summaryrefslogtreecommitdiff
path: root/AK/Vector.h
diff options
context:
space:
mode:
authorasynts <asynts@gmail.com>2020-09-09 13:41:58 +0200
committerAndreas Kling <kling@serenityos.org>2020-09-09 20:15:50 +0200
commit910924f55963f282d575fe42f54eeed6d93a7acd (patch)
treed39558155977ea89c50518d0d0f3b4d9b4ca5811 /AK/Vector.h
parent678bbd29cac72b819ed2d8304418f72146d7fb52 (diff)
downloadserenity-910924f55963f282d575fe42f54eeed6d93a7acd.zip
AK: Moved TypedTransfer into it's own header.
Diffstat (limited to 'AK/Vector.h')
-rw-r--r--AK/Vector.h44
1 files changed, 1 insertions, 43 deletions
diff --git a/AK/Vector.h b/AK/Vector.h
index c65f1753a1..94804368a9 100644
--- a/AK/Vector.h
+++ b/AK/Vector.h
@@ -33,6 +33,7 @@
#include <AK/Span.h>
#include <AK/StdLibExtras.h>
#include <AK/Traits.h>
+#include <AK/TypedTransfer.h>
#include <AK/kmalloc.h>
// NOTE: We can't include <initializer_list> during the toolchain bootstrap,
@@ -48,49 +49,6 @@
namespace AK {
-template<typename T>
-class TypedTransfer {
-public:
- static void move(T* destination, T* source, size_t count)
- {
- if (!count)
- return;
- if constexpr (Traits<T>::is_trivial()) {
- __builtin_memmove(destination, source, count * sizeof(T));
- return;
- }
- for (size_t i = 0; i < count; ++i)
- new (&destination[i]) T(AK::move(source[i]));
- }
-
- static void copy(T* destination, const T* source, size_t count)
- {
- if (!count)
- return;
- if constexpr (Traits<T>::is_trivial()) {
- __builtin_memmove(destination, source, count * sizeof(T));
- return;
- }
- for (size_t i = 0; i < count; ++i)
- new (&destination[i]) T(source[i]);
- }
-
- static bool compare(const T* a, const T* b, size_t count)
- {
- if (!count)
- return true;
-
- if constexpr (Traits<T>::is_trivial())
- return !__builtin_memcmp(a, b, count * sizeof(T));
-
- for (size_t i = 0; i < count; ++i) {
- if (a[i] != b[i])
- return false;
- }
- return true;
- }
-};
-
template<typename T, size_t inline_capacity>
class Vector {
public: