Forráskód Böngészése

test: [[nodiscard]], const-correctness and other linter related stuff

Michele Caini 2 éve
szülő
commit
4d9ff926b6

+ 40 - 40
test/entt/meta/meta_any.cpp

@@ -115,7 +115,7 @@ TEST_F(MetaAny, SBO) {
 }
 
 TEST_F(MetaAny, NoSBO) {
-    fat_t instance{.1, .2, .3, .4};
+    const fat_t instance{.1, .2, .3, .4};
     entt::meta_any any{instance};
 
     ASSERT_TRUE(any);
@@ -124,7 +124,7 @@ TEST_F(MetaAny, NoSBO) {
     ASSERT_FALSE(any.try_cast<std::size_t>());
     ASSERT_EQ(any.cast<fat_t>(), instance);
     ASSERT_NE(any.data(), nullptr);
-    ASSERT_EQ(any, entt::meta_any{instance});
+    ASSERT_EQ(any, entt::meta_any{instance}); 
     ASSERT_NE(any, fat_t{});
 }
 
@@ -241,7 +241,7 @@ ENTT_DEBUG_TEST_F(MetaAnyDeathTest, SBOAsConstRefConstruction) {
 }
 
 TEST_F(MetaAny, SBOCopyConstruction) {
-    entt::meta_any any{42};
+    const entt::meta_any any{42};
     entt::meta_any other{any};
 
     ASSERT_TRUE(any);
@@ -253,7 +253,7 @@ TEST_F(MetaAny, SBOCopyConstruction) {
 }
 
 TEST_F(MetaAny, SBOCopyAssignment) {
-    entt::meta_any any{42};
+    const entt::meta_any any{42};
     entt::meta_any other{3};
 
     other = any;
@@ -304,8 +304,8 @@ TEST_F(MetaAny, SBODirectAssignment) {
 
 TEST_F(MetaAny, SBOAssignValue) {
     entt::meta_any any{42};
-    entt::meta_any other{3};
-    entt::meta_any invalid{empty_t{}};
+    const entt::meta_any other{3};
+    const entt::meta_any invalid{empty_t{}};
 
     ASSERT_TRUE(any);
     ASSERT_EQ(any.cast<int>(), 42);
@@ -317,8 +317,8 @@ TEST_F(MetaAny, SBOAssignValue) {
 
 TEST_F(MetaAny, SBOConvertAssignValue) {
     entt::meta_any any{42};
-    entt::meta_any other{3.5};
-    entt::meta_any invalid{empty_t{}};
+    const entt::meta_any other{3.5};
+    const entt::meta_any invalid{empty_t{}};
 
     ASSERT_TRUE(any);
     ASSERT_EQ(any.cast<int>(), 42);
@@ -331,8 +331,8 @@ TEST_F(MetaAny, SBOConvertAssignValue) {
 TEST_F(MetaAny, SBOAsRefAssignValue) {
     int value = 42;
     entt::meta_any any{entt::forward_as_meta(value)};
-    entt::meta_any other{3};
-    entt::meta_any invalid{empty_t{}};
+    const entt::meta_any other{3};
+    const entt::meta_any invalid{empty_t{}};
 
     ASSERT_TRUE(any);
     ASSERT_EQ(any.cast<int>(), 42);
@@ -346,8 +346,8 @@ TEST_F(MetaAny, SBOAsRefAssignValue) {
 TEST_F(MetaAny, SBOAsConstRefAssignValue) {
     const int value = 42;
     entt::meta_any any{entt::forward_as_meta(value)};
-    entt::meta_any other{3};
-    entt::meta_any invalid{empty_t{}};
+    const entt::meta_any other{3};
+    const entt::meta_any invalid{empty_t{}};
 
     ASSERT_TRUE(any);
     ASSERT_EQ(any.cast<int>(), 42);
@@ -418,7 +418,7 @@ TEST_F(MetaAny, SBOAsConstRefTransferValue) {
 }
 
 TEST_F(MetaAny, NoSBOInPlaceTypeConstruction) {
-    fat_t instance{.1, .2, .3, .4};
+    const fat_t instance{.1, .2, .3, .4};
     entt::meta_any any{std::in_place_type<fat_t>, instance};
 
     ASSERT_TRUE(any);
@@ -508,8 +508,8 @@ ENTT_DEBUG_TEST_F(MetaAnyDeathTest, NoSBOAsConstRefConstruction) {
 }
 
 TEST_F(MetaAny, NoSBOCopyConstruction) {
-    fat_t instance{.1, .2, .3, .4};
-    entt::meta_any any{instance};
+    const fat_t instance{.1, .2, .3, .4};
+    const entt::meta_any any{instance};
     entt::meta_any other{any};
 
     ASSERT_TRUE(any);
@@ -521,8 +521,8 @@ TEST_F(MetaAny, NoSBOCopyConstruction) {
 }
 
 TEST_F(MetaAny, NoSBOCopyAssignment) {
-    fat_t instance{.1, .2, .3, .4};
-    entt::meta_any any{instance};
+    const fat_t instance{.1, .2, .3, .4};
+    const entt::meta_any any{instance};
     entt::meta_any other{3};
 
     other = any;
@@ -536,7 +536,7 @@ TEST_F(MetaAny, NoSBOCopyAssignment) {
 }
 
 TEST_F(MetaAny, NoSBOMoveConstruction) {
-    fat_t instance{.1, .2, .3, .4};
+    const fat_t instance{.1, .2, .3, .4};
     entt::meta_any any{instance};
     entt::meta_any other{std::move(any)};
 
@@ -549,7 +549,7 @@ TEST_F(MetaAny, NoSBOMoveConstruction) {
 }
 
 TEST_F(MetaAny, NoSBOMoveAssignment) {
-    fat_t instance{.1, .2, .3, .4};
+    const fat_t instance{.1, .2, .3, .4};
     entt::meta_any any{instance};
     entt::meta_any other{3};
 
@@ -564,7 +564,7 @@ TEST_F(MetaAny, NoSBOMoveAssignment) {
 }
 
 TEST_F(MetaAny, NoSBODirectAssignment) {
-    fat_t instance{.1, .2, .3, .4};
+    const fat_t instance{.1, .2, .3, .4};
     entt::meta_any any{};
     any = instance;
 
@@ -576,8 +576,8 @@ TEST_F(MetaAny, NoSBODirectAssignment) {
 
 TEST_F(MetaAny, NoSBOAssignValue) {
     entt::meta_any any{fat_t{.1, .2, .3, .4}};
-    entt::meta_any other{fat_t{.0, .1, .2, .3}};
-    entt::meta_any invalid{'c'};
+    const entt::meta_any other{fat_t{.0, .1, .2, .3}};
+    const entt::meta_any invalid{'c'};
 
     const void *addr = std::as_const(any).data();
 
@@ -592,8 +592,8 @@ TEST_F(MetaAny, NoSBOAssignValue) {
 
 TEST_F(MetaAny, NoSBOConvertAssignValue) {
     entt::meta_any any{empty_t{}};
-    entt::meta_any other{fat_t{.0, .1, .2, .3}};
-    entt::meta_any invalid{'c'};
+    const entt::meta_any other{fat_t{.0, .1, .2, .3}};
+    const entt::meta_any invalid{'c'};
 
     const void *addr = std::as_const(any).data();
 
@@ -606,8 +606,8 @@ TEST_F(MetaAny, NoSBOConvertAssignValue) {
 TEST_F(MetaAny, NoSBOAsRefAssignValue) {
     fat_t instance{.1, .2, .3, .4};
     entt::meta_any any{entt::forward_as_meta(instance)};
-    entt::meta_any other{fat_t{.0, .1, .2, .3}};
-    entt::meta_any invalid{'c'};
+    const entt::meta_any other{fat_t{.0, .1, .2, .3}};
+    const entt::meta_any invalid{'c'};
 
     ASSERT_TRUE(any);
     ASSERT_EQ(any.cast<const fat_t &>(), (fat_t{.1, .2, .3, .4}));
@@ -621,8 +621,8 @@ TEST_F(MetaAny, NoSBOAsRefAssignValue) {
 TEST_F(MetaAny, NoSBOAsConstRefAssignValue) {
     const fat_t instance{.1, .2, .3, .4};
     entt::meta_any any{entt::forward_as_meta(instance)};
-    entt::meta_any other{fat_t{.0, .1, .2, .3}};
-    entt::meta_any invalid{'c'};
+    const entt::meta_any other{fat_t{.0, .1, .2, .3}};
+    const entt::meta_any invalid{'c'};
 
     ASSERT_TRUE(any);
     ASSERT_EQ(any.cast<const fat_t &>(), (fat_t{.1, .2, .3, .4}));
@@ -718,8 +718,8 @@ TEST_F(MetaAny, VoidInPlaceTypeConstruction) {
 }
 
 TEST_F(MetaAny, VoidCopyConstruction) {
-    entt::meta_any any{std::in_place_type<void>};
-    entt::meta_any other{any};
+    const entt::meta_any any{std::in_place_type<void>};
+    const entt::meta_any other{any};
 
     ASSERT_TRUE(any);
     ASSERT_TRUE(other);
@@ -728,7 +728,7 @@ TEST_F(MetaAny, VoidCopyConstruction) {
 }
 
 TEST_F(MetaAny, VoidCopyAssignment) {
-    entt::meta_any any{std::in_place_type<void>};
+    const entt::meta_any any{std::in_place_type<void>};
     entt::meta_any other{std::in_place_type<void>};
 
     other = any;
@@ -741,7 +741,7 @@ TEST_F(MetaAny, VoidCopyAssignment) {
 
 TEST_F(MetaAny, VoidMoveConstruction) {
     entt::meta_any any{std::in_place_type<void>};
-    entt::meta_any other{std::move(any)};
+    const entt::meta_any other{std::move(any)};
 
     ASSERT_FALSE(any);
     ASSERT_TRUE(other);
@@ -764,7 +764,7 @@ TEST_F(MetaAny, VoidMoveAssignment) {
 TEST_F(MetaAny, SBOMoveInvalidate) {
     entt::meta_any any{42};
     entt::meta_any other{std::move(any)};
-    entt::meta_any valid = std::move(other);
+    const entt::meta_any valid = std::move(other);
 
     ASSERT_FALSE(any);
     ASSERT_FALSE(other);
@@ -772,10 +772,10 @@ TEST_F(MetaAny, SBOMoveInvalidate) {
 }
 
 TEST_F(MetaAny, NoSBOMoveInvalidate) {
-    fat_t instance{.1, .2, .3, .4};
+    const fat_t instance{.1, .2, .3, .4};
     entt::meta_any any{instance};
     entt::meta_any other{std::move(any)};
-    entt::meta_any valid = std::move(other);
+    const entt::meta_any valid = std::move(other);
 
     ASSERT_FALSE(any);
     ASSERT_FALSE(other);
@@ -785,7 +785,7 @@ TEST_F(MetaAny, NoSBOMoveInvalidate) {
 TEST_F(MetaAny, VoidMoveInvalidate) {
     entt::meta_any any{std::in_place_type<void>};
     entt::meta_any other{std::move(any)};
-    entt::meta_any valid = std::move(other);
+    const entt::meta_any valid = std::move(other);
 
     ASSERT_FALSE(any);
     ASSERT_FALSE(other);
@@ -820,7 +820,7 @@ TEST_F(MetaAny, NoSBODestruction) {
 
 TEST_F(MetaAny, VoidDestruction) {
     // just let asan tell us if everything is ok here
-    [[maybe_unused]] entt::meta_any any{std::in_place_type<void>};
+    [[maybe_unused]] const entt::meta_any any{std::in_place_type<void>};
 }
 
 TEST_F(MetaAny, Emplace) {
@@ -1036,7 +1036,7 @@ ENTT_DEBUG_TEST_F(MetaAnyDeathTest, AsRef) {
 }
 
 TEST_F(MetaAny, Comparable) {
-    entt::meta_any any{'c'};
+    const entt::meta_any any{'c'};
 
     ASSERT_EQ(any, any);
     ASSERT_EQ(any, entt::meta_any{'c'});
@@ -1051,7 +1051,7 @@ TEST_F(MetaAny, Comparable) {
 }
 
 TEST_F(MetaAny, NonComparable) {
-    entt::meta_any any{test::non_comparable{}};
+    const entt::meta_any any{test::non_comparable{}};
 
     ASSERT_EQ(any, any);
     ASSERT_NE(any, entt::meta_any{test::non_comparable{}});
@@ -1063,7 +1063,7 @@ TEST_F(MetaAny, NonComparable) {
 }
 
 TEST_F(MetaAny, CompareVoid) {
-    entt::meta_any any{std::in_place_type<void>};
+    const entt::meta_any any{std::in_place_type<void>};
 
     ASSERT_EQ(any, any);
     ASSERT_EQ(any, entt::meta_any{std::in_place_type<void>});

+ 11 - 11
test/entt/meta/meta_container.cpp

@@ -377,7 +377,7 @@ ENTT_DEBUG_TEST(SequenceContainerDeathTest, Constness) {
 }
 
 TEST(SequenceContainer, FromConstAny) {
-    std::vector<int> vec{42};
+    const std::vector<int> vec{42};
     const entt::meta_any any{vec};
     auto view = any.as_sequence_container();
 
@@ -407,7 +407,7 @@ TEST(SequenceContainer, FromConstAnyConstRef) {
 }
 
 ENTT_DEBUG_TEST(SequenceContainerDeathTest, FromConstAny) {
-    std::vector<int> vec{42};
+    const std::vector<int> vec{42};
     const entt::meta_any any{vec};
     auto view = any.as_sequence_container();
 
@@ -477,7 +477,7 @@ TEST(AssociativeContainer, StdMap) {
     auto view = any.as_associative_container();
 
     ASSERT_TRUE(view);
-    ASSERT_FALSE(view.key_only());
+    ASSERT_FALSE(view.key_only()); // NOLINT
     ASSERT_EQ(view.key_type(), entt::resolve<int>());
     ASSERT_EQ(view.mapped_type(), entt::resolve<char>());
     ASSERT_EQ(view.value_type(), (entt::resolve<std::pair<const int, char>>()));
@@ -521,7 +521,7 @@ TEST(AssociativeContainer, StdSet) {
     auto view = any.as_associative_container();
 
     ASSERT_TRUE(view);
-    ASSERT_TRUE(view.key_only());
+    ASSERT_TRUE(view.key_only()); // NOLINT
     ASSERT_EQ(view.key_type(), entt::resolve<int>());
     ASSERT_EQ(view.mapped_type(), entt::meta_type{});
     ASSERT_EQ(view.value_type(), entt::resolve<int>());
@@ -568,7 +568,7 @@ TEST(AssociativeContainer, DenseMap) {
     map.emplace(4, '3');
 
     ASSERT_TRUE(view);
-    ASSERT_FALSE(view.key_only());
+    ASSERT_FALSE(view.key_only()); // NOLINT
     ASSERT_EQ(view.key_type(), entt::resolve<int>());
     ASSERT_EQ(view.mapped_type(), entt::resolve<char>());
     ASSERT_EQ(view.value_type(), (entt::resolve<std::pair<const int, char>>()));
@@ -616,7 +616,7 @@ TEST(AssociativeContainer, DenseSet) {
     set.emplace(4);
 
     ASSERT_TRUE(view);
-    ASSERT_TRUE(view.key_only());
+    ASSERT_TRUE(view.key_only()); // NOLINT
     ASSERT_EQ(view.key_type(), entt::resolve<int>());
     ASSERT_EQ(view.mapped_type(), entt::meta_type{});
     ASSERT_EQ(view.value_type(), entt::resolve<int>());
@@ -659,7 +659,7 @@ TEST(KeyValueAssociativeContainer, Constness) {
     auto view = any.as_associative_container();
 
     ASSERT_TRUE(view);
-    ASSERT_FALSE(view.key_only());
+    ASSERT_FALSE(view.key_only()); // NOLINT
     ASSERT_EQ(view.key_type(), entt::resolve<int>());
     ASSERT_EQ(view.mapped_type(), entt::resolve<char>());
     ASSERT_EQ(view.value_type(), (entt::resolve<std::pair<const int, char>>()));
@@ -702,7 +702,7 @@ TEST(KeyOnlyAssociativeContainer, Constness) {
     auto view = any.as_associative_container();
 
     ASSERT_TRUE(view);
-    ASSERT_TRUE(view.key_only());
+    ASSERT_TRUE(view.key_only()); // NOLINT
     ASSERT_EQ(view.key_type(), entt::resolve<int>());
     ASSERT_EQ(view.mapped_type(), entt::meta_type{});
     ASSERT_EQ(view.value_type(), (entt::resolve<int>()));
@@ -735,7 +735,7 @@ TEST(KeyOnlyAssociativeContainer, Constness) {
 }
 
 TEST(KeyValueAssociativeContainer, FromConstAny) {
-    std::map<int, char> map{{2, 'c'}};
+    const std::map<int, char> map{{2, 'c'}};
     const entt::meta_any any{map};
     auto view = any.as_associative_container();
 
@@ -765,7 +765,7 @@ TEST(KeyValueAssociativeContainer, FromConstAnyConstRef) {
 }
 
 ENTT_DEBUG_TEST(KeyValueAssociativeContainerDeathTest, FromConstAny) {
-    std::map<int, char> map{{2, 'c'}};
+    const std::map<int, char> map{{2, 'c'}};
     const entt::meta_any any{map};
     auto view = any.as_associative_container();
 
@@ -792,7 +792,7 @@ ENTT_DEBUG_TEST(KeyValueAssociativeContainerDeathTest, FromConstAnyConstRef) {
 }
 
 TEST(KeyOnlyAssociativeContainer, FromConstAny) {
-    std::set<int> set{2};
+    const std::set<int> set{2};
     const entt::meta_any any{set};
     auto view = any.as_associative_container();
 

+ 8 - 8
test/entt/meta/meta_context.cpp

@@ -19,7 +19,7 @@ struct base {
     base(char v)
         : value{v} {}
 
-    char get() const {
+    [[nodiscard]] char get() const {
         return value;
     }
 
@@ -37,11 +37,11 @@ struct clazz: base {
         : base{c},
           value{v} {}
 
-    int func(int v) {
+    [[nodiscard]] int func(int v) {
         return (value = v);
     }
 
-    int cfunc(int v) const {
+    [[nodiscard]] int cfunc(int v) const {
         return v;
     }
 
@@ -57,11 +57,11 @@ struct argument {
     argument(int val)
         : value{val} {}
 
-    int get() const {
+    [[nodiscard]] int get() const {
         return value;
     }
 
-    int get_mul() const {
+    [[nodiscard]] int get_mul() const {
         return value * 2;
     }
 
@@ -452,9 +452,9 @@ TEST_F(MetaContext, MetaSequenceContainer) {
 TEST_F(MetaContext, MetaAny) {
     using namespace entt::literals;
 
-    entt::meta_any global{42};
-    entt::meta_any ctx_value{context, 42};
-    entt::meta_any in_place{context, std::in_place_type<int>, 42};
+    const entt::meta_any global{42};
+    const entt::meta_any ctx_value{context, 42};
+    const entt::meta_any in_place{context, std::in_place_type<int>, 42};
     entt::meta_any two_step_local{entt::meta_ctx_arg, context};
 
     ASSERT_TRUE(global);

+ 1 - 1
test/entt/meta/meta_conv.cpp

@@ -15,7 +15,7 @@ struct clazz_t {
         return value;
     }
 
-    bool to_bool() const {
+    [[nodiscard]] bool to_bool() const {
         return (value != 0);
     }
 

+ 1 - 1
test/entt/meta/meta_data.cpp

@@ -307,7 +307,7 @@ TEST_F(MetaData, SetMetaAnyArg) {
     using namespace entt::literals;
 
     entt::meta_any any{clazz_t{}};
-    entt::meta_any value{42};
+    const entt::meta_any value{42};
 
     ASSERT_EQ(any.cast<clazz_t>().i, 0);
     ASSERT_TRUE(entt::resolve<clazz_t>().data("i"_hs).set(any, value));

+ 9 - 9
test/entt/meta/meta_func.cpp

@@ -23,7 +23,7 @@ struct base_t {
         value = v;
     }
 
-    int getter() const {
+    [[nodiscard]] int getter() const {
         return value;
     }
 
@@ -39,7 +39,7 @@ void fake_member(base_t &instance, int value) {
     instance.value = value;
 }
 
-int fake_const_member(const base_t &instance) {
+[[nodiscard]] int fake_const_member(const base_t &instance) {
     return instance.value;
 }
 
@@ -49,16 +49,16 @@ struct derived_t: base_t {
 };
 
 struct func_t {
-    int f(const base_t &, int a, int b) {
+    [[nodiscard]] int f(const base_t &, int a, int b) {
         return f(a, b);
     }
 
-    int f(int a, int b) {
+    [[nodiscard]] int f(int a, int b) {
         value = a;
         return b * b;
     }
 
-    int f(int v) const {
+    [[nodiscard]] int f(int v) const {
         return v * v;
     }
 
@@ -66,7 +66,7 @@ struct func_t {
         value = v * v;
     }
 
-    static int h(int &v) {
+    [[nodiscard]] static int h(int &v) {
         return (v *= value);
     }
 
@@ -74,15 +74,15 @@ struct func_t {
         value = v;
     }
 
-    int v(int v) const {
+    [[nodiscard]] int v(int v) const {
         return (value = v);
     }
 
-    int &a() const {
+    [[nodiscard]] int &a() const {
         return value;
     }
 
-    operator int() const {
+    [[nodiscard]] operator int() const {
         return value;
     }
 

+ 24 - 24
test/entt/meta/meta_pointer.cpp

@@ -14,7 +14,7 @@ struct wrapped_shared_ptr {
     wrapped_shared_ptr(Type init)
         : ptr{new Type{init}} {}
 
-    Type &deref() const {
+    [[nodiscard]] Type &deref() const {
         return *ptr;
     }
 
@@ -83,8 +83,8 @@ int test_function() {
 }
 
 TEST(MetaPointerLike, DereferenceOperatorInvalidType) {
-    int value = 0;
-    entt::meta_any any{value};
+    const int value = 0;
+    const entt::meta_any any{value};
 
     ASSERT_FALSE(any.type().is_pointer());
     ASSERT_FALSE(any.type().is_pointer_like());
@@ -97,7 +97,7 @@ TEST(MetaPointerLike, DereferenceOperatorInvalidType) {
 
 TEST(MetaPointerLike, DereferenceOperatorConstType) {
     const int value = 42;
-    entt::meta_any any{&value};
+    const entt::meta_any any{&value};
 
     ASSERT_TRUE(any.type().is_pointer());
     ASSERT_TRUE(any.type().is_pointer_like());
@@ -117,7 +117,7 @@ TEST(MetaPointerLike, DereferenceOperatorConstType) {
 
 ENTT_DEBUG_TEST(MetaPointerLikeDeathTest, DereferenceOperatorConstType) {
     const int value = 42;
-    entt::meta_any any{&value};
+    const entt::meta_any any{&value};
     auto deref = *any;
 
     ASSERT_TRUE(deref);
@@ -208,7 +208,7 @@ TEST(MetaPointerLike, DereferenceOperatorSmartPointer) {
 
 TEST(MetaPointerLike, PointerToConstMoveOnlyType) {
     const std::unique_ptr<int> instance;
-    entt::meta_any any{&instance};
+    const entt::meta_any any{&instance};
     auto deref = *any;
 
     ASSERT_TRUE(any);
@@ -264,7 +264,7 @@ TEST(MetaPointerLike, AsConstRef) {
 }
 
 TEST(MetaPointerLike, DereferenceOverloadAdl) {
-    entt::meta_any any{adl_wrapped_shared_ptr<int>{42}};
+    const entt::meta_any any{adl_wrapped_shared_ptr<int>{42}};
 
     ASSERT_FALSE(any.type().is_pointer());
     ASSERT_TRUE(any.type().is_pointer_like());
@@ -281,7 +281,7 @@ TEST(MetaPointerLike, DereferenceOverloadAdl) {
 }
 
 TEST(MetaPointerLike, DereferenceOverloadSpec) {
-    entt::meta_any any{spec_wrapped_shared_ptr<int>{42}};
+    const entt::meta_any any{spec_wrapped_shared_ptr<int>{42}};
 
     ASSERT_FALSE(any.type().is_pointer());
     ASSERT_TRUE(any.type().is_pointer_like());
@@ -298,7 +298,7 @@ TEST(MetaPointerLike, DereferenceOverloadSpec) {
 }
 
 TEST(MetaPointerLike, DereferencePointerToConstOverloadAdl) {
-    entt::meta_any any{adl_wrapped_shared_ptr<const int>{42}};
+    const entt::meta_any any{adl_wrapped_shared_ptr<const int>{42}};
 
     ASSERT_FALSE(any.type().is_pointer());
     ASSERT_TRUE(any.type().is_pointer_like());
@@ -313,7 +313,7 @@ TEST(MetaPointerLike, DereferencePointerToConstOverloadAdl) {
 }
 
 TEST(MetaPointerLike, DereferencePointerToConstOverloadSpec) {
-    entt::meta_any any{spec_wrapped_shared_ptr<const int>{42}};
+    const entt::meta_any any{spec_wrapped_shared_ptr<const int>{42}};
 
     ASSERT_FALSE(any.type().is_pointer());
     ASSERT_TRUE(any.type().is_pointer_like());
@@ -328,7 +328,7 @@ TEST(MetaPointerLike, DereferencePointerToConstOverloadSpec) {
 }
 
 ENTT_DEBUG_TEST(MetaPointerLikeDeathTest, DereferencePointerToConstOverloadAdl) {
-    entt::meta_any any{adl_wrapped_shared_ptr<const int>{42}};
+    const entt::meta_any any{adl_wrapped_shared_ptr<const int>{42}};
 
     auto deref = *any;
 
@@ -337,7 +337,7 @@ ENTT_DEBUG_TEST(MetaPointerLikeDeathTest, DereferencePointerToConstOverloadAdl)
 }
 
 ENTT_DEBUG_TEST(MetaPointerLikeDeathTest, DereferencePointerToConstOverloadSpec) {
-    entt::meta_any any{spec_wrapped_shared_ptr<const int>{42}};
+    const entt::meta_any any{spec_wrapped_shared_ptr<const int>{42}};
 
     auto deref = *any;
 
@@ -346,7 +346,7 @@ ENTT_DEBUG_TEST(MetaPointerLikeDeathTest, DereferencePointerToConstOverloadSpec)
 }
 
 TEST(MetaPointerLike, DereferencePointerToVoid) {
-    entt::meta_any any{static_cast<void *>(nullptr)};
+    const entt::meta_any any{static_cast<void *>(nullptr)};
 
     ASSERT_TRUE(any.type().is_pointer());
     ASSERT_TRUE(any.type().is_pointer_like());
@@ -357,7 +357,7 @@ TEST(MetaPointerLike, DereferencePointerToVoid) {
 }
 
 TEST(MetaPointerLike, DereferencePointerToConstVoid) {
-    entt::meta_any any{static_cast<const void *>(nullptr)};
+    const entt::meta_any any{static_cast<const void *>(nullptr)};
 
     ASSERT_TRUE(any.type().is_pointer());
     ASSERT_TRUE(any.type().is_pointer_like());
@@ -368,7 +368,7 @@ TEST(MetaPointerLike, DereferencePointerToConstVoid) {
 }
 
 TEST(MetaPointerLike, DereferenceSharedPointerToVoid) {
-    entt::meta_any any{std::shared_ptr<void>{}};
+    const entt::meta_any any{std::shared_ptr<void>{}};
 
     ASSERT_TRUE(any.type().is_class());
     ASSERT_FALSE(any.type().is_pointer());
@@ -380,7 +380,7 @@ TEST(MetaPointerLike, DereferenceSharedPointerToVoid) {
 }
 
 TEST(MetaPointerLike, DereferenceUniquePointerToVoid) {
-    entt::meta_any any{std::unique_ptr<void, void (*)(void *)>{nullptr, nullptr}};
+    const entt::meta_any any{std::unique_ptr<void, void (*)(void *)>{nullptr, nullptr}};
 
     ASSERT_TRUE(any.type().is_class());
     ASSERT_FALSE(any.type().is_pointer());
@@ -402,7 +402,7 @@ TEST(MetaPointerLike, DereferencePointerToFunction) {
 
 TEST(MetaPointerLike, DereferenceSelfPointer) {
     self_ptr obj{42};
-    entt::meta_any any{entt::forward_as_meta(obj)};
+    const entt::meta_any any{entt::forward_as_meta(obj)};
     entt::meta_any deref = *any;
 
     ASSERT_TRUE(deref);
@@ -413,8 +413,8 @@ TEST(MetaPointerLike, DereferenceSelfPointer) {
 
 TEST(MetaPointerLike, DereferenceProxyPointer) {
     int value = 3;
-    proxy_ptr obj{value};
-    entt::meta_any any{obj};
+    const proxy_ptr obj{value};
+    const entt::meta_any any{obj};
     entt::meta_any deref = *any;
 
     ASSERT_TRUE(deref);
@@ -428,8 +428,8 @@ TEST(MetaPointerLike, DereferenceProxyPointer) {
 }
 
 TEST(MetaPointerLike, DereferenceArray) {
-    entt::meta_any array{std::in_place_type<int[3]>};
-    entt::meta_any array_of_array{std::in_place_type<int[3][3]>};
+    const entt::meta_any array{std::in_place_type<int[3]>};
+    const entt::meta_any array_of_array{std::in_place_type<int[3][3]>};
 
     ASSERT_EQ(array.type(), entt::resolve<int[3]>());
     ASSERT_EQ(array_of_array.type(), entt::resolve<int[3][3]>());
@@ -439,21 +439,21 @@ TEST(MetaPointerLike, DereferenceArray) {
 }
 
 TEST(MetaPointerLike, DereferencePlainNullPointer) {
-    entt::meta_any any{static_cast<int *>(nullptr)};
+    const entt::meta_any any{static_cast<int *>(nullptr)};
 
     ASSERT_TRUE(any);
     ASSERT_FALSE(*any);
 }
 
 TEST(MetaPointerLike, DereferenceSharedNullPointer) {
-    entt::meta_any any{std::shared_ptr<int>{}};
+    const entt::meta_any any{std::shared_ptr<int>{}};
 
     ASSERT_TRUE(any);
     ASSERT_FALSE(*any);
 }
 
 TEST(MetaPointerLike, DereferenceUniqueNullPointer) {
-    entt::meta_any any{std::unique_ptr<int>{}};
+    const entt::meta_any any{std::unique_ptr<int>{}};
 
     ASSERT_TRUE(any);
     ASSERT_FALSE(*any);

+ 8 - 8
test/entt/meta/meta_type.cpp

@@ -66,7 +66,7 @@ struct clazz_t {
     void member() {}
     static void func() {}
 
-    operator int() const {
+    [[nodiscard]] operator int() const {
         return value;
     }
 
@@ -74,33 +74,33 @@ struct clazz_t {
 };
 
 struct overloaded_func_t {
-    int e(int v) const {
+    [[nodiscard]] int e(int v) const {
         return v + v;
     }
 
-    int f(const base_t &, int a, int b) {
+    [[nodiscard]] int f(const base_t &, int a, int b) {
         return f(a, b);
     }
 
-    int f(int a, int b) {
+    [[nodiscard]] int f(int a, int b) {
         value = a;
         return g(b);
     }
 
-    int f(int v) {
+    [[nodiscard]] int f(int v) {
         return 2 * std::as_const(*this).f(v);
     }
 
-    int f(int v) const {
+    [[nodiscard]] int f(int v) const {
         return g(v);
     }
 
-    float f(int a, float b) {
+    [[nodiscard]] float f(int a, float b) {
         value = a;
         return static_cast<float>(e(static_cast<int>(b)));
     }
 
-    int g(int v) const {
+    [[nodiscard]] int g(int v) const {
         return v * v;
     }