77#include < type_traits>
88#include < utility>
99#include " ../config/config.h"
10- #include " ../core/concepts.hpp"
1110#include " ../stl/memory.hpp"
1211
1312namespace entt {
@@ -18,7 +17,7 @@ namespace entt {
1817 * @param lhs A valid allocator.
1918 * @param rhs Another valid allocator.
2019 */
21- template <allocator_like Allocator>
20+ template <typename Allocator>
2221constexpr void propagate_on_container_copy_assignment ([[maybe_unused]] Allocator &lhs, [[maybe_unused]] Allocator &rhs) noexcept {
2322 if constexpr (std::allocator_traits<Allocator>::propagate_on_container_copy_assignment::value) {
2423 lhs = rhs;
@@ -31,7 +30,7 @@ constexpr void propagate_on_container_copy_assignment([[maybe_unused]] Allocator
3130 * @param lhs A valid allocator.
3231 * @param rhs Another valid allocator.
3332 */
34- template <allocator_like Allocator>
33+ template <typename Allocator>
3534constexpr void propagate_on_container_move_assignment ([[maybe_unused]] Allocator &lhs, [[maybe_unused]] Allocator &rhs) noexcept {
3635 if constexpr (std::allocator_traits<Allocator>::propagate_on_container_move_assignment::value) {
3736 lhs = std::move (rhs);
@@ -44,7 +43,7 @@ constexpr void propagate_on_container_move_assignment([[maybe_unused]] Allocator
4443 * @param lhs A valid allocator.
4544 * @param rhs Another valid allocator.
4645 */
47- template <allocator_like Allocator>
46+ template <typename Allocator>
4847constexpr void propagate_on_container_swap ([[maybe_unused]] Allocator &lhs, [[maybe_unused]] Allocator &rhs) noexcept {
4948 if constexpr (std::allocator_traits<Allocator>::propagate_on_container_swap::value) {
5049 using std::swap;
@@ -58,7 +57,7 @@ constexpr void propagate_on_container_swap([[maybe_unused]] Allocator &lhs, [[ma
5857 * @brief Deleter for allocator-aware unique pointers (waiting for C++20).
5958 * @tparam Allocator Type of allocator used to manage memory and elements.
6059 */
61- template <allocator_like Allocator>
60+ template <typename Allocator>
6261struct allocation_deleter : private Allocator {
6362 /* ! @brief Allocator type. */
6463 using allocator_type = Allocator;
@@ -92,7 +91,7 @@ struct allocation_deleter: private Allocator {
9291 * @param args Parameters to use to construct the object.
9392 * @return A properly initialized unique pointer with a custom deleter.
9493 */
95- template <typename Type, allocator_like Allocator, typename ... Args>
94+ template <typename Type, typename Allocator, typename ... Args>
9695constexpr auto allocate_unique (Allocator &allocator, Args &&...args) {
9796 static_assert (!std::is_array_v<Type>, " Array types are not supported" );
9897
@@ -118,7 +117,7 @@ namespace internal {
118117
119118template <typename Type>
120119struct uses_allocator_construction {
121- template <allocator_like Allocator, typename ... Params>
120+ template <typename Allocator, typename ... Params>
122121 static constexpr auto args ([[maybe_unused]] const Allocator &allocator, Params &&...params) noexcept {
123122 if constexpr (!std::uses_allocator_v<Type, Allocator> && std::is_constructible_v<Type, Params...>) {
124123 return std::forward_as_tuple (std::forward<Params>(params)...);
@@ -139,30 +138,31 @@ template<typename Type, typename Other>
139138struct uses_allocator_construction <std::pair<Type, Other>> {
140139 using type = std::pair<Type, Other>;
141140
142- template <typename First, typename Second>
143- static constexpr auto args (const allocator_like auto &allocator, std::piecewise_construct_t , First &&first, Second &&second) noexcept {
141+ template <typename Allocator, typename First, typename Second>
142+ static constexpr auto args (const Allocator &allocator, std::piecewise_construct_t , First &&first, Second &&second) noexcept {
144143 return std::make_tuple (
145144 std::piecewise_construct,
146145 std::apply ([&allocator](auto &&...curr ) { return uses_allocator_construction<Type>::args (allocator, std::forward<decltype (curr)>(curr)...); }, std::forward<First>(first)),
147146 std::apply ([&allocator](auto &&...curr ) { return uses_allocator_construction<Other>::args (allocator, std::forward<decltype (curr)>(curr)...); }, std::forward<Second>(second)));
148147 }
149148
150- static constexpr auto args (const allocator_like auto &allocator) noexcept {
149+ template <typename Allocator>
150+ static constexpr auto args (const Allocator &allocator) noexcept {
151151 return uses_allocator_construction<type>::args (allocator, std::piecewise_construct, std::tuple<>{}, std::tuple<>{});
152152 }
153153
154- template <typename First, typename Second>
155- static constexpr auto args (const allocator_like auto &allocator, First &&first, Second &&second) noexcept {
154+ template <typename Allocator, typename First, typename Second>
155+ static constexpr auto args (const Allocator &allocator, First &&first, Second &&second) noexcept {
156156 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)));
157157 }
158158
159- template <typename First, typename Second>
160- static constexpr auto args (const allocator_like auto &allocator, const std::pair<First, Second> &value) noexcept {
159+ template <typename Allocator, typename First, typename Second>
160+ static constexpr auto args (const Allocator &allocator, const std::pair<First, Second> &value) noexcept {
161161 return uses_allocator_construction<type>::args (allocator, std::piecewise_construct, std::forward_as_tuple (value.first ), std::forward_as_tuple (value.second ));
162162 }
163163
164- template <typename First, typename Second>
165- static constexpr auto args (const allocator_like auto &allocator, std::pair<First, Second> &&value) noexcept {
164+ template <typename Allocator, typename First, typename Second>
165+ static constexpr auto args (const Allocator &allocator, std::pair<First, Second> &&value) noexcept {
166166 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 )));
167167 }
168168};
@@ -177,13 +177,14 @@ struct uses_allocator_construction<std::pair<Type, Other>> {
177177 * create an object of a given type by means of uses-allocator construction.
178178 *
179179 * @tparam Type Type to return arguments for.
180+ * @tparam Allocator Type of allocator used to manage memory and elements.
180181 * @tparam Args Types of arguments to use to construct the object.
181182 * @param allocator The allocator to use.
182183 * @param args Parameters to use to construct the object.
183184 * @return The arguments needed to create an object of the given type.
184185 */
185- template <typename Type, typename ... Args>
186- constexpr auto uses_allocator_construction_args (const allocator_like auto &allocator, Args &&...args) noexcept {
186+ template <typename Type, typename Allocator, typename ... Args>
187+ constexpr auto uses_allocator_construction_args (const Allocator &allocator, Args &&...args) noexcept {
187188 return internal::uses_allocator_construction<Type>::args (allocator, std::forward<Args>(args)...);
188189}
189190
@@ -194,13 +195,14 @@ constexpr auto uses_allocator_construction_args(const allocator_like auto &alloc
194195 * means of uses-allocator construction.
195196 *
196197 * @tparam Type Type of object to create.
198+ * @tparam Allocator Type of allocator used to manage memory and elements.
197199 * @tparam Args Types of arguments to use to construct the object.
198200 * @param allocator The allocator to use.
199201 * @param args Parameters to use to construct the object.
200202 * @return A newly created object of the given type.
201203 */
202- template <typename Type, typename ... Args>
203- constexpr Type make_obj_using_allocator (const allocator_like auto &allocator, Args &&...args) {
204+ template <typename Type, typename Allocator, typename ... Args>
205+ constexpr Type make_obj_using_allocator (const Allocator &allocator, Args &&...args) {
204206 return std::make_from_tuple<Type>(internal::uses_allocator_construction<Type>::args (allocator, std::forward<Args>(args)...));
205207}
206208
@@ -211,14 +213,15 @@ constexpr Type make_obj_using_allocator(const allocator_like auto &allocator, Ar
211213 * means of uses-allocator construction at an uninitialized memory location.
212214 *
213215 * @tparam Type Type of object to create.
216+ * @tparam Allocator Type of allocator used to manage memory and elements.
214217 * @tparam Args Types of arguments to use to construct the object.
215218 * @param value Memory location in which to place the object.
216219 * @param allocator The allocator to use.
217220 * @param args Parameters to use to construct the object.
218221 * @return A pointer to the newly created object of the given type.
219222 */
220- template <typename Type, typename ... Args>
221- constexpr Type *uninitialized_construct_using_allocator (Type *value, const allocator_like auto &allocator, Args &&...args) {
223+ template <typename Type, typename Allocator, typename ... Args>
224+ constexpr Type *uninitialized_construct_using_allocator (Type *value, const Allocator &allocator, Args &&...args) {
222225 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)...));
223226}
224227
0 commit comments