test: use the mixin design a little more

This commit is contained in:
skypjack
2026-03-02 14:06:54 +01:00
parent c113dfe082
commit b5797912d3
5 changed files with 15 additions and 20 deletions

View File

@@ -1,12 +0,0 @@
#ifndef ENTT_COMMON_NON_COMPARABLE_H
#define ENTT_COMMON_NON_COMPARABLE_H
namespace test {
struct non_comparable {
bool operator==(const non_comparable &) const noexcept = delete;
};
} // namespace test
#endif

View File

@@ -19,16 +19,23 @@ template<typename Type>
struct non_trivially_destructible_mixin: Type {
using Type::Type;
using Type::operator=;
virtual ~non_trivially_destructible_mixin() = default;
virtual ~non_trivially_destructible_mixin() noexcept = default;
};
template<typename Type>
struct non_comparable_mixin: Type {
using Type::Type;
using Type::operator=;
bool operator==(const non_comparable_mixin &) const noexcept = delete;
};
template<typename Type>
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;
non_movable_mixin(non_movable_mixin &&) noexcept = delete;
non_movable_mixin(const non_movable_mixin &) noexcept = default;
non_movable_mixin &operator=(non_movable_mixin &&) noexcept = delete;
non_movable_mixin &operator=(const non_movable_mixin &) noexcept = default;
};
struct value_type {
@@ -44,6 +51,7 @@ struct value_type {
using pointer_stable = internal::pointer_stable_mixin<internal::value_type>;
using non_trivially_destructible = internal::non_trivially_destructible_mixin<internal::value_type>;
using pointer_stable_non_trivially_destructible = internal::pointer_stable_mixin<internal::non_trivially_destructible_mixin<internal::value_type>>;
using non_comparable = internal::non_comparable_mixin<internal::value_type>;
using non_movable = internal::non_movable_mixin<internal::value_type>;
static_assert(std::is_trivially_destructible_v<test::pointer_stable>, "Not a trivially destructible type");

View File

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

View File

@@ -8,7 +8,7 @@
#include <gtest/gtest.h>
#include <entt/core/hashed_string.hpp>
#include <entt/core/type_traits.hpp>
#include "../../common/non_comparable.h"
#include "../../common/value_type.h"
struct nlohmann_json_like final {
using value_type = nlohmann_json_like;

View File

@@ -14,7 +14,7 @@
#include <entt/meta/resolve.hpp>
#include "../../common/config.h"
#include "../../common/linter.hpp"
#include "../../common/non_comparable.h"
#include "../../common/value_type.h"
struct MetaAny: ::testing::Test {
struct clazz {