Browse Source

any: avoid using addressof on the result of an operator assignment without a good reason :)

Michele Caini 4 years ago
parent
commit
3ece33b26a
1 changed files with 4 additions and 2 deletions
  1. 4 2
      src/entt/core/any.hpp

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

@@ -69,12 +69,14 @@ class basic_any {
             return (static_cast<basic_any *>(const_cast<void *>(to))->instance = std::exchange(const_cast<basic_any &>(from).instance, nullptr));
         case operation::transfer:
             if constexpr(std::is_move_assignable_v<Type>) {
-                return std::addressof(*const_cast<Type *>(instance) = std::move(*static_cast<Type *>(const_cast<void *>(to))));
+                *const_cast<Type *>(instance) = std::move(*static_cast<Type *>(const_cast<void *>(to)));
+                return to;
             }
             [[fallthrough]];
         case operation::assign:
             if constexpr(std::is_copy_assignable_v<Type>) {
-                return std::addressof(*const_cast<Type *>(instance) = *static_cast<const Type *>(to));
+                *const_cast<Type *>(instance) = *static_cast<const Type *>(to);
+                return to;
             }
             break;
         case operation::destroy: