Browse Source

storage/sparse_set: ctor review

Michele Caini 4 years ago
parent
commit
1baad08288
2 changed files with 21 additions and 11 deletions
  1. 13 8
      src/entt/entity/sparse_set.hpp
  2. 8 3
      src/entt/entity/storage.hpp

+ 13 - 8
src/entt/entity/sparse_set.hpp

@@ -306,6 +306,19 @@ public:
     /*! @brief Reverse iterator type. */
     /*! @brief Reverse iterator type. */
     using reverse_iterator = std::reverse_iterator<iterator>;
     using reverse_iterator = std::reverse_iterator<iterator>;
 
 
+    /*! @brief Default constructor. */
+    basic_sparse_set()
+        : basic_sparse_set{allocator_type{}}
+    {}
+
+    /**
+     * @brief Constructs an empty container with a given allocator.
+     * @param allocator The allocator to use.
+     */
+    explicit basic_sparse_set(const allocator_type &allocator)
+        : basic_sparse_set{deletion_policy::swap_and_pop, allocator}
+    {}
+
     /**
     /**
      * @brief Constructs an empty container with the given policy and allocator.
      * @brief Constructs an empty container with the given policy and allocator.
      * @param pol Type of deletion policy.
      * @param pol Type of deletion policy.
@@ -321,14 +334,6 @@ public:
           mode{pol}
           mode{pol}
     {}
     {}
 
 
-    /**
-     * @brief Constructs an empty container with the given allocator.
-     * @param allocator Allocator to use (possibly default-constructed).
-     */
-    explicit basic_sparse_set(const allocator_type &allocator = {})
-        : basic_sparse_set{deletion_policy::swap_and_pop, allocator}
-    {}
-
     /**
     /**
      * @brief Move constructor.
      * @brief Move constructor.
      * @param other The instance to move from.
      * @param other The instance to move from.

+ 8 - 3
src/entt/entity/storage.hpp

@@ -324,11 +324,16 @@ public:
     /*! @brief Constant reverse iterator type. */
     /*! @brief Constant reverse iterator type. */
     using const_reverse_iterator = std::reverse_iterator<const_iterator>;
     using const_reverse_iterator = std::reverse_iterator<const_iterator>;
 
 
+    /*! @brief Default constructor. */
+    basic_storage()
+        : basic_storage{allocator_type{}}
+    {}
+
     /**
     /**
-     * @brief Default constructor.
-     * @param allocator Allocator to use (possibly default-constructed).
+     * @brief Constructs an empty storage with a given allocator.
+     * @param allocator the allocator to use.
      */
      */
-    explicit basic_storage(const allocator_type &allocator = {})
+    explicit basic_storage(const allocator_type &allocator)
         : underlying_type{deletion_policy{comp_traits::in_place_delete::value}, allocator},
         : underlying_type{deletion_policy{comp_traits::in_place_delete::value}, allocator},
           bucket{allocator, 0u},
           bucket{allocator, 0u},
           packed{}
           packed{}