skypjack 1 месяц назад
Родитель
Сommit
68dbf7fe2d
1 измененных файлов с 12 добавлено и 12 удалено
  1. 12 12
      src/entt/core/any.hpp

+ 12 - 12
src/entt/core/any.hpp

@@ -368,38 +368,38 @@ public:
 
 
     /**
     /**
      * @brief Returns an opaque pointer to the contained instance.
      * @brief Returns an opaque pointer to the contained instance.
-     * @param req Expected type.
      * @return An opaque pointer the contained instance, if any.
      * @return An opaque pointer the contained instance, if any.
      */
      */
-    [[nodiscard]] const void *data(const type_info &req) const noexcept {
-        return has_value(req) ? data() : nullptr;
+    [[nodiscard]] void *data() noexcept {
+        return (mode == any_policy::cref) ? nullptr : const_cast<void *>(stl::as_const(*this).data());
     }
     }
 
 
     /**
     /**
      * @brief Returns an opaque pointer to the contained instance.
      * @brief Returns an opaque pointer to the contained instance.
-     * @tparam Type Expected type.
+     * @param req Expected type.
      * @return An opaque pointer the contained instance, if any.
      * @return An opaque pointer the contained instance, if any.
      */
      */
-    template<typename Type>
-    [[nodiscard]] const Type *data() const noexcept {
-        return has_value<stl::remove_const_t<Type>>() ? static_cast<const Type *>(data()) : nullptr;
+    [[nodiscard]] const void *data(const type_info &req) const noexcept {
+        return has_value(req) ? data() : nullptr;
     }
     }
 
 
     /**
     /**
      * @brief Returns an opaque pointer to the contained instance.
      * @brief Returns an opaque pointer to the contained instance.
+     * @param req Expected type.
      * @return An opaque pointer the contained instance, if any.
      * @return An opaque pointer the contained instance, if any.
      */
      */
-    [[nodiscard]] void *data() noexcept {
-        return (mode == any_policy::cref) ? nullptr : const_cast<void *>(stl::as_const(*this).data());
+    [[nodiscard]] void *data(const type_info &req) noexcept {
+        return (mode == any_policy::cref) ? nullptr : const_cast<void *>(stl::as_const(*this).data(req));
     }
     }
 
 
     /**
     /**
      * @brief Returns an opaque pointer to the contained instance.
      * @brief Returns an opaque pointer to the contained instance.
-     * @param req Expected type.
+     * @tparam Type Expected type.
      * @return An opaque pointer the contained instance, if any.
      * @return An opaque pointer the contained instance, if any.
      */
      */
-    [[nodiscard]] void *data(const type_info &req) noexcept {
-        return (mode == any_policy::cref) ? nullptr : const_cast<void *>(stl::as_const(*this).data(req));
+    template<typename Type>
+    [[nodiscard]] const Type *data() const noexcept {
+        return has_value<stl::remove_const_t<Type>>() ? static_cast<const Type *>(data()) : nullptr;
     }
     }
 
 
     /**
     /**