Browse Source

resource: add member function handle

Michele Caini 3 years ago
parent
commit
8780d536c7
2 changed files with 9 additions and 1 deletions
  1. 8 0
      src/entt/resource/resource.hpp
  2. 1 1
      test/entt/resource/resource.cpp

+ 8 - 0
src/entt/resource/resource.hpp

@@ -157,6 +157,14 @@ public:
         return value.use_count();
     }
 
+    /**
+     * @brief Returns the underlying resource handle.
+     * @return The underlying resource handle.
+     */
+    [[nodiscard]] handle_type handle() const noexcept {
+        return value;
+    }
+
 private:
     handle_type value;
 };

+ 1 - 1
test/entt/resource/resource.cpp

@@ -30,7 +30,7 @@ TEST(Resource, Functionalities) {
 
     ASSERT_FALSE(resource);
     ASSERT_EQ(resource.operator->(), nullptr);
-    ASSERT_EQ(resource.use_count(), 0l);
+    ASSERT_EQ(resource.handle().use_count(), 0l);
 
     const auto value = std::make_shared<derived>();
     entt::resource<derived> other{value};