From c113dfe082aee69a93a097271179cc653bedb98b Mon Sep 17 00:00:00 2001 From: skypjack Date: Mon, 2 Mar 2026 13:54:46 +0100 Subject: [PATCH] test: use the mixin design a little more --- test/common/non_movable.h | 20 -------------------- test/common/value_type.h | 40 ++++++++++++++++++++++++++------------- test/entt/core/any.cpp | 2 +- 3 files changed, 28 insertions(+), 34 deletions(-) delete mode 100644 test/common/non_movable.h diff --git a/test/common/non_movable.h b/test/common/non_movable.h deleted file mode 100644 index 0aef348b0..000000000 --- a/test/common/non_movable.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef ENTT_COMMON_NON_MOVABLE_H -#define ENTT_COMMON_NON_MOVABLE_H - -namespace test { - -struct non_movable { - non_movable() = default; - - non_movable(const non_movable &) = default; - non_movable(non_movable &&) = delete; - - non_movable &operator=(const non_movable &) = default; - non_movable &operator=(non_movable &&) = delete; - - int value{}; -}; - -} // namespace test - -#endif diff --git a/test/common/value_type.h b/test/common/value_type.h index ef072e6fe..936e6352d 100644 --- a/test/common/value_type.h +++ b/test/common/value_type.h @@ -6,22 +6,32 @@ namespace test { -template -struct pointer_stable_mixin: Type... { +namespace internal { + +template +struct pointer_stable_mixin: Type { static constexpr auto in_place_delete = true; - [[nodiscard]] constexpr bool operator==(const pointer_stable_mixin &) const noexcept = default; - [[nodiscard]] constexpr auto operator<=>(const pointer_stable_mixin &) const noexcept = default; + using Type::Type; + using Type::operator=; }; -template -struct non_trivially_destructible_mixin: Type... { - [[nodiscard]] constexpr bool operator==(const non_trivially_destructible_mixin &) const noexcept = default; - [[nodiscard]] constexpr auto operator<=>(const non_trivially_destructible_mixin &) const noexcept = default; +template +struct non_trivially_destructible_mixin: Type { + using Type::Type; + using Type::operator=; virtual ~non_trivially_destructible_mixin() = default; }; -template -struct value_type final: Type... { +template +struct non_movable_mixin: Type { + using Type::Type; + non_movable_mixin(non_movable_mixin &&) = delete; + non_movable_mixin(const non_movable_mixin &) = default; + non_movable_mixin &operator=(non_movable_mixin &&) = delete; + non_movable_mixin &operator=(const non_movable_mixin &) = default; +}; + +struct value_type { constexpr value_type() = default; constexpr value_type(int elem): value{elem} {} [[nodiscard]] constexpr bool operator==(const value_type &) const noexcept = default; @@ -29,13 +39,17 @@ struct value_type final: Type... { int value{}; }; -using pointer_stable = value_type>; -using non_trivially_destructible = value_type>; -using pointer_stable_non_trivially_destructible = value_type>>; +} // namespace internal + +using pointer_stable = internal::pointer_stable_mixin; +using non_trivially_destructible = internal::non_trivially_destructible_mixin; +using pointer_stable_non_trivially_destructible = internal::pointer_stable_mixin>; +using non_movable = internal::non_movable_mixin; static_assert(std::is_trivially_destructible_v, "Not a trivially destructible type"); static_assert(!std::is_trivially_destructible_v, "Trivially destructible type"); static_assert(!std::is_trivially_destructible_v, "Trivially destructible type"); +static_assert(!std::is_move_constructible_v && !std::is_move_assignable_v, "Movable type"); } // namespace test diff --git a/test/entt/core/any.cpp b/test/entt/core/any.cpp index 7c4f98796..e83c59d17 100644 --- a/test/entt/core/any.cpp +++ b/test/entt/core/any.cpp @@ -14,7 +14,7 @@ #include "../../common/linter.hpp" #include "../../common/new_delete.h" #include "../../common/non_comparable.h" -#include "../../common/non_movable.h" +#include "../../common/value_type.h" template struct tracker {