Browse Source

test: use the mixin design a little more

skypjack 1 ngày trước cách đây
mục cha
commit
93cb729322
4 tập tin đã thay đổi với 13 bổ sung24 xóa
  1. 0 22
      test/common/new_delete.h
  2. 13 0
      test/common/value_type.h
  3. 0 1
      test/entt/core/any.cpp
  4. 0 1
      test/entt/entity/storage.cpp

+ 0 - 22
test/common/new_delete.h

@@ -1,22 +0,0 @@
-#ifndef ENTT_COMMON_NEW_DELETE_H
-#define ENTT_COMMON_NEW_DELETE_H
-
-#include <cstddef>
-
-namespace test {
-
-struct new_delete {
-    static void *operator new(std::size_t count) {
-        return ::operator new(count);
-    }
-
-    static void operator delete(void *ptr) {
-        ::operator delete(ptr);
-    }
-
-    int value{};
-};
-
-} // namespace test
-
-#endif

+ 13 - 0
test/common/value_type.h

@@ -45,6 +45,17 @@ struct non_movable_mixin: Type {
     non_movable_mixin &operator=(const non_movable_mixin &) noexcept = default;
 };
 
+template<typename Type>
+struct new_delete_mixin: Type {
+    static void *operator new(std::size_t count) {
+        return ::operator new(count);
+    }
+
+    static void operator delete(void *ptr) {
+        ::operator delete(ptr);
+    }
+};
+
 struct empty_type {};
 
 struct aggregate_type {
@@ -75,6 +86,8 @@ using non_trivially_destructible = internal::non_trivially_destructible_mixin<in
 using non_comparable = internal::non_comparable_mixin<internal::empty_type>;
 using non_movable = internal::non_movable_mixin<internal::value_type<int>>;
 
+using new_delete = internal::new_delete_mixin<internal::value_type<int>>;
+
 using boxed_int = internal::value_type<int>;
 using boxed_char = internal::value_type<char>;
 

+ 0 - 1
test/entt/core/any.cpp

@@ -11,7 +11,6 @@
 #include <entt/core/type_info.hpp>
 #include "../../common/config.h"
 #include "../../common/linter.hpp"
-#include "../../common/new_delete.h"
 #include "../../common/value_type.h"
 
 template<std::size_t Len>

+ 0 - 1
test/entt/entity/storage.cpp

@@ -14,7 +14,6 @@
 #include <entt/entity/storage.hpp>
 #include "../../common/config.h"
 #include "../../common/linter.hpp"
-#include "../../common/new_delete.h"
 #include "../../common/throwing_allocator.hpp"
 #include "../../common/throwing_type.hpp"
 #include "../../common/tracked_memory_resource.hpp"