Răsfoiți Sursa

entt: cleanup

skypjack 3 săptămâni în urmă
părinte
comite
e7650e263f

+ 4 - 6
src/entt/container/dense_map.hpp

@@ -39,18 +39,16 @@ struct dense_map_node final {
         : next{pos},
           element{std::forward<Args>(args)...} {}
 
-    template<typename Allocator, typename... Args>
-    dense_map_node(std::allocator_arg_t, const Allocator &allocator, const std::size_t pos, Args &&...args)
+    template<typename... Args>
+    dense_map_node(std::allocator_arg_t, const auto &allocator, const std::size_t pos, Args &&...args)
         : next{pos},
           element{entt::make_obj_using_allocator<value_type>(allocator, std::forward<Args>(args)...)} {}
 
-    template<typename Allocator>
-    dense_map_node(std::allocator_arg_t, const Allocator &allocator, const dense_map_node &other)
+    dense_map_node(std::allocator_arg_t, const auto &allocator, const dense_map_node &other)
         : next{other.next},
           element{entt::make_obj_using_allocator<value_type>(allocator, other.element)} {}
 
-    template<typename Allocator>
-    dense_map_node(std::allocator_arg_t, const Allocator &allocator, dense_map_node &&other)
+    dense_map_node(std::allocator_arg_t, const auto &allocator, dense_map_node &&other)
         : next{other.next},
           element{entt::make_obj_using_allocator<value_type>(allocator, std::move(other.element))} {}
 

+ 1 - 3
src/entt/container/table.hpp

@@ -170,11 +170,9 @@ public:
 
     /**
      * @brief Constructs the underlying containers using a given allocator.
-     * @tparam Allocator Type of allocator.
      * @param allocator A valid allocator.
      */
-    template<typename Allocator>
-    explicit basic_table(const Allocator &allocator)
+    explicit basic_table(const auto &allocator)
         : payload{Container{allocator}...} {}
 
     /**

+ 15 - 19
src/entt/core/memory.hpp

@@ -138,31 +138,30 @@ template<typename Type, typename Other>
 struct uses_allocator_construction<std::pair<Type, Other>> {
     using type = std::pair<Type, Other>;
 
-    template<typename Allocator, typename First, typename Second>
-    static constexpr auto args(const Allocator &allocator, std::piecewise_construct_t, First &&first, Second &&second) noexcept {
+    template<typename First, typename Second>
+    static constexpr auto args(const auto &allocator, std::piecewise_construct_t, First &&first, Second &&second) noexcept {
         return std::make_tuple(
             std::piecewise_construct,
             std::apply([&allocator](auto &&...curr) { return uses_allocator_construction<Type>::args(allocator, std::forward<decltype(curr)>(curr)...); }, std::forward<First>(first)),
             std::apply([&allocator](auto &&...curr) { return uses_allocator_construction<Other>::args(allocator, std::forward<decltype(curr)>(curr)...); }, std::forward<Second>(second)));
     }
 
-    template<typename Allocator>
-    static constexpr auto args(const Allocator &allocator) noexcept {
+    static constexpr auto args(const auto &allocator) noexcept {
         return uses_allocator_construction<type>::args(allocator, std::piecewise_construct, std::tuple<>{}, std::tuple<>{});
     }
 
-    template<typename Allocator, typename First, typename Second>
-    static constexpr auto args(const Allocator &allocator, First &&first, Second &&second) noexcept {
+    template<typename First, typename Second>
+    static constexpr auto args(const auto &allocator, First &&first, Second &&second) noexcept {
         return uses_allocator_construction<type>::args(allocator, std::piecewise_construct, std::forward_as_tuple(std::forward<First>(first)), std::forward_as_tuple(std::forward<Second>(second)));
     }
 
-    template<typename Allocator, typename First, typename Second>
-    static constexpr auto args(const Allocator &allocator, const std::pair<First, Second> &value) noexcept {
+    template<typename First, typename Second>
+    static constexpr auto args(const auto &allocator, const std::pair<First, Second> &value) noexcept {
         return uses_allocator_construction<type>::args(allocator, std::piecewise_construct, std::forward_as_tuple(value.first), std::forward_as_tuple(value.second));
     }
 
-    template<typename Allocator, typename First, typename Second>
-    static constexpr auto args(const Allocator &allocator, std::pair<First, Second> &&value) noexcept {
+    template<typename First, typename Second>
+    static constexpr auto args(const auto &allocator, std::pair<First, Second> &&value) noexcept {
         return uses_allocator_construction<type>::args(allocator, std::piecewise_construct, std::forward_as_tuple(std::move(value.first)), std::forward_as_tuple(std::move(value.second)));
     }
 };
@@ -177,14 +176,13 @@ struct uses_allocator_construction<std::pair<Type, Other>> {
  * create an object of a given type by means of uses-allocator construction.
  *
  * @tparam Type Type to return arguments for.
- * @tparam Allocator Type of allocator used to manage memory and elements.
  * @tparam Args Types of arguments to use to construct the object.
  * @param allocator The allocator to use.
  * @param args Parameters to use to construct the object.
  * @return The arguments needed to create an object of the given type.
  */
-template<typename Type, typename Allocator, typename... Args>
-constexpr auto uses_allocator_construction_args(const Allocator &allocator, Args &&...args) noexcept {
+template<typename Type, typename... Args>
+constexpr auto uses_allocator_construction_args(const auto &allocator, Args &&...args) noexcept {
     return internal::uses_allocator_construction<Type>::args(allocator, std::forward<Args>(args)...);
 }
 
@@ -195,14 +193,13 @@ constexpr auto uses_allocator_construction_args(const Allocator &allocator, Args
  * means of uses-allocator construction.
  *
  * @tparam Type Type of object to create.
- * @tparam Allocator Type of allocator used to manage memory and elements.
  * @tparam Args Types of arguments to use to construct the object.
  * @param allocator The allocator to use.
  * @param args Parameters to use to construct the object.
  * @return A newly created object of the given type.
  */
-template<typename Type, typename Allocator, typename... Args>
-constexpr Type make_obj_using_allocator(const Allocator &allocator, Args &&...args) {
+template<typename Type, typename... Args>
+constexpr Type make_obj_using_allocator(const auto &allocator, Args &&...args) {
     return std::make_from_tuple<Type>(internal::uses_allocator_construction<Type>::args(allocator, std::forward<Args>(args)...));
 }
 
@@ -213,15 +210,14 @@ constexpr Type make_obj_using_allocator(const Allocator &allocator, Args &&...ar
  * means of uses-allocator construction at an uninitialized memory location.
  *
  * @tparam Type Type of object to create.
- * @tparam Allocator Type of allocator used to manage memory and elements.
  * @tparam Args Types of arguments to use to construct the object.
  * @param value Memory location in which to place the object.
  * @param allocator The allocator to use.
  * @param args Parameters to use to construct the object.
  * @return A pointer to the newly created object of the given type.
  */
-template<typename Type, typename Allocator, typename... Args>
-constexpr Type *uninitialized_construct_using_allocator(Type *value, const Allocator &allocator, Args &&...args) {
+template<typename Type, typename... Args>
+constexpr Type *uninitialized_construct_using_allocator(Type *value, const auto &allocator, Args &&...args) {
     return std::apply([value](auto &&...curr) { return ::new(value) Type(std::forward<decltype(curr)>(curr)...); }, internal::uses_allocator_construction<Type>::args(allocator, std::forward<Args>(args)...));
 }
 

+ 2 - 3
src/entt/locator/locator.hpp

@@ -108,15 +108,14 @@ public:
     /**
      * @brief Sets or replaces a service using a given allocator.
      * @tparam Type Service type.
-     * @tparam Allocator Type of allocator used to manage memory and elements.
      * @tparam Args Types of arguments to use to construct the service.
      * @param alloc The allocator to use.
      * @param args Parameters to use to construct the service.
      * @return A reference to a valid service.
      */
-    template<std::derived_from<Service> Type = Service, typename Allocator, typename... Args>
+    template<std::derived_from<Service> Type = Service, typename... Args>
     requires std::constructible_from<Type, Args...>
-    static Service &emplace(std::allocator_arg_t, Allocator alloc, Args &&...args) {
+    static Service &emplace(std::allocator_arg_t, auto alloc, Args &&...args) {
         service = std::allocate_shared<Type>(alloc, std::forward<Args>(args)...);
         return *service;
     }