Explorar o código

meta: fixed a bug on meta_type::construct with no arguments (close #413)

Michele Caini %!s(int64=6) %!d(string=hai) anos
pai
achega
688d435d8e
Modificáronse 2 ficheiros con 9 adicións e 1 borrados
  1. 1 1
      src/entt/meta/meta.hpp
  2. 8 0
      test/entt/meta/meta.cpp

+ 1 - 1
src/entt/meta/meta.hpp

@@ -1425,7 +1425,7 @@ public:
      */
     template<typename... Args>
     meta_any construct(Args &&... args) const {
-        auto construct_if = [this](auto *params) {
+        auto construct_if = [this](meta_any *params) {
             meta_any any{};
 
             internal::find_if<&internal::meta_type_node::ctor>([params, &any](const auto *curr) {

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

@@ -192,6 +192,7 @@ struct Meta: ::testing::Test {
                 .conv<&derived_type::g>();
 
         entt::meta<empty_type>()
+                .ctor<>()
                 .alias("empty"_hs)
                 .dtor<&empty_type::destroy>();
 
@@ -1686,6 +1687,13 @@ TEST_F(Meta, MetaTypeConstruct) {
     ASSERT_EQ(any.cast<derived_type>().c, 'c');
 }
 
+TEST_F(Meta, MetaTypeConstructNoArgs) {
+    // this should work, no other tests required
+    auto any = entt::resolve<empty_type>().construct();
+
+    ASSERT_TRUE(any);
+}
+
 TEST_F(Meta, MetaTypeConstructMetaAnyArgs) {
     auto any = entt::resolve<derived_type>().construct(base_type{}, 42, 'c');