Browse Source

any (meta/poly): make T& in place construction work with references rather than pointers

Michele Caini 5 years ago
parent
commit
f75a2dab8d
3 changed files with 5 additions and 6 deletions
  1. 3 4
      src/entt/core/any.hpp
  2. 1 1
      src/entt/meta/meta.hpp
  3. 1 1
      src/entt/poly/poly.hpp

+ 3 - 4
src/entt/core/any.hpp

@@ -163,9 +163,8 @@ public:
     {
         if constexpr(!std::is_void_v<Type>) {
             if constexpr(std::is_lvalue_reference_v<Type>) {
-                static_assert(sizeof...(Args) == 1u && (std::is_pointer_v<std::remove_reference_t<Args>> && ...));
-                ENTT_ASSERT(((args != nullptr) && ...));
-                instance = (args, ...);
+                static_assert(sizeof...(Args) == 1u && (std::is_lvalue_reference_v<Args> && ...));
+                instance = (&args, ...);
             } else if constexpr(in_situ<Type>) {
                 new (&storage) Type(std::forward<Args>(args)...);
             } else {
@@ -181,7 +180,7 @@ public:
      */
     template<typename Type>
     any(std::reference_wrapper<Type> value) ENTT_NOEXCEPT
-        : any{std::in_place_type<Type &>, &value.get()}
+        : any{std::in_place_type<Type &>, value.get()}
     {}
 
     /**

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

@@ -425,7 +425,7 @@ public:
      */
     template<typename Type>
     meta_any(std::reference_wrapper<Type> value)
-        : meta_any{std::in_place_type<Type &>, &value.get()}
+        : meta_any{std::in_place_type<Type &>, value.get()}
     {}
 
     /**

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

@@ -208,7 +208,7 @@ public:
      */
     template<typename Type>
     poly(std::reference_wrapper<Type> value)
-        : poly{std::in_place_type<Type &>, &value.get()}
+        : poly{std::in_place_type<Type &>, value.get()}
     {}
 
     /**