diff options
| author | untodesu <kirill@untode.su> | 2025-03-15 16:22:09 +0500 |
|---|---|---|
| committer | untodesu <kirill@untode.su> | 2025-03-15 16:22:09 +0500 |
| commit | 3bf42c6ff3805a0d42bbc661794a95ff31bedc26 (patch) | |
| tree | 05049955847504808d6bed2bb7b155f8b03807bb /deps/include/entt/resource/loader.hpp | |
| parent | 02294547dcde0d4ad76e229106702261e9f10a51 (diff) | |
| download | voxelius-3bf42c6ff3805a0d42bbc661794a95ff31bedc26.tar.bz2 voxelius-3bf42c6ff3805a0d42bbc661794a95ff31bedc26.zip | |
Add whatever I was working on for the last month
Diffstat (limited to 'deps/include/entt/resource/loader.hpp')
| -rw-r--r-- | deps/include/entt/resource/loader.hpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/deps/include/entt/resource/loader.hpp b/deps/include/entt/resource/loader.hpp new file mode 100644 index 0000000..6e12ff1 --- /dev/null +++ b/deps/include/entt/resource/loader.hpp @@ -0,0 +1,33 @@ +#ifndef ENTT_RESOURCE_LOADER_HPP
+#define ENTT_RESOURCE_LOADER_HPP
+
+#include <memory>
+#include <utility>
+#include "fwd.hpp"
+
+namespace entt {
+
+/**
+ * @brief Transparent loader for shared resources.
+ * @tparam Type Type of resources created by the loader.
+ */
+template<typename Type>
+struct resource_loader {
+ /*! @brief Result type. */
+ using result_type = std::shared_ptr<Type>;
+
+ /**
+ * @brief Constructs a shared pointer to a resource from its arguments.
+ * @tparam Args Types of arguments to use to construct the resource.
+ * @param args Parameters to use to construct the resource.
+ * @return A shared pointer to a resource of the given type.
+ */
+ template<typename... Args>
+ result_type operator()(Args &&...args) const {
+ return std::make_shared<Type>(std::forward<Args>(args)...);
+ }
+};
+
+} // namespace entt
+
+#endif
|
