Skip to content

Commit e7650e2

Browse files
committed
entt: cleanup
1 parent f93d289 commit e7650e2

File tree

4 files changed

+22
-31
lines changed

4 files changed

+22
-31
lines changed

src/entt/container/dense_map.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,16 @@ struct dense_map_node final {
3939
: next{pos},
4040
element{std::forward<Args>(args)...} {}
4141

42-
template<typename Allocator, typename... Args>
43-
dense_map_node(std::allocator_arg_t, const Allocator &allocator, const std::size_t pos, Args &&...args)
42+
template<typename... Args>
43+
dense_map_node(std::allocator_arg_t, const auto &allocator, const std::size_t pos, Args &&...args)
4444
: next{pos},
4545
element{entt::make_obj_using_allocator<value_type>(allocator, std::forward<Args>(args)...)} {}
4646

47-
template<typename Allocator>
48-
dense_map_node(std::allocator_arg_t, const Allocator &allocator, const dense_map_node &other)
47+
dense_map_node(std::allocator_arg_t, const auto &allocator, const dense_map_node &other)
4948
: next{other.next},
5049
element{entt::make_obj_using_allocator<value_type>(allocator, other.element)} {}
5150

52-
template<typename Allocator>
53-
dense_map_node(std::allocator_arg_t, const Allocator &allocator, dense_map_node &&other)
51+
dense_map_node(std::allocator_arg_t, const auto &allocator, dense_map_node &&other)
5452
: next{other.next},
5553
element{entt::make_obj_using_allocator<value_type>(allocator, std::move(other.element))} {}
5654

src/entt/container/table.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,9 @@ class basic_table {
170170

171171
/**
172172
* @brief Constructs the underlying containers using a given allocator.
173-
* @tparam Allocator Type of allocator.
174173
* @param allocator A valid allocator.
175174
*/
176-
template<typename Allocator>
177-
explicit basic_table(const Allocator &allocator)
175+
explicit basic_table(const auto &allocator)
178176
: payload{Container{allocator}...} {}
179177

180178
/**

src/entt/core/memory.hpp

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -138,31 +138,30 @@ template<typename Type, typename Other>
138138
struct uses_allocator_construction<std::pair<Type, Other>> {
139139
using type = std::pair<Type, Other>;
140140

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 {
141+
template<typename First, typename Second>
142+
static constexpr auto args(const auto &allocator, std::piecewise_construct_t, First &&first, Second &&second) noexcept {
143143
return std::make_tuple(
144144
std::piecewise_construct,
145145
std::apply([&allocator](auto &&...curr) { return uses_allocator_construction<Type>::args(allocator, std::forward<decltype(curr)>(curr)...); }, std::forward<First>(first)),
146146
std::apply([&allocator](auto &&...curr) { return uses_allocator_construction<Other>::args(allocator, std::forward<decltype(curr)>(curr)...); }, std::forward<Second>(second)));
147147
}
148148

149-
template<typename Allocator>
150-
static constexpr auto args(const Allocator &allocator) noexcept {
149+
static constexpr auto args(const auto &allocator) noexcept {
151150
return uses_allocator_construction<type>::args(allocator, std::piecewise_construct, std::tuple<>{}, std::tuple<>{});
152151
}
153152

154-
template<typename Allocator, typename First, typename Second>
155-
static constexpr auto args(const Allocator &allocator, First &&first, Second &&second) noexcept {
153+
template<typename First, typename Second>
154+
static constexpr auto args(const auto &allocator, First &&first, Second &&second) noexcept {
156155
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)));
157156
}
158157

159-
template<typename Allocator, typename First, typename Second>
160-
static constexpr auto args(const Allocator &allocator, const std::pair<First, Second> &value) noexcept {
158+
template<typename First, typename Second>
159+
static constexpr auto args(const auto &allocator, const std::pair<First, Second> &value) noexcept {
161160
return uses_allocator_construction<type>::args(allocator, std::piecewise_construct, std::forward_as_tuple(value.first), std::forward_as_tuple(value.second));
162161
}
163162

164-
template<typename Allocator, typename First, typename Second>
165-
static constexpr auto args(const Allocator &allocator, std::pair<First, Second> &&value) noexcept {
163+
template<typename First, typename Second>
164+
static constexpr auto args(const auto &allocator, std::pair<First, Second> &&value) noexcept {
166165
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)));
167166
}
168167
};
@@ -177,14 +176,13 @@ struct uses_allocator_construction<std::pair<Type, Other>> {
177176
* create an object of a given type by means of uses-allocator construction.
178177
*
179178
* @tparam Type Type to return arguments for.
180-
* @tparam Allocator Type of allocator used to manage memory and elements.
181179
* @tparam Args Types of arguments to use to construct the object.
182180
* @param allocator The allocator to use.
183181
* @param args Parameters to use to construct the object.
184182
* @return The arguments needed to create an object of the given type.
185183
*/
186-
template<typename Type, typename Allocator, typename... Args>
187-
constexpr auto uses_allocator_construction_args(const Allocator &allocator, Args &&...args) noexcept {
184+
template<typename Type, typename... Args>
185+
constexpr auto uses_allocator_construction_args(const auto &allocator, Args &&...args) noexcept {
188186
return internal::uses_allocator_construction<Type>::args(allocator, std::forward<Args>(args)...);
189187
}
190188

@@ -195,14 +193,13 @@ constexpr auto uses_allocator_construction_args(const Allocator &allocator, Args
195193
* means of uses-allocator construction.
196194
*
197195
* @tparam Type Type of object to create.
198-
* @tparam Allocator Type of allocator used to manage memory and elements.
199196
* @tparam Args Types of arguments to use to construct the object.
200197
* @param allocator The allocator to use.
201198
* @param args Parameters to use to construct the object.
202199
* @return A newly created object of the given type.
203200
*/
204-
template<typename Type, typename Allocator, typename... Args>
205-
constexpr Type make_obj_using_allocator(const Allocator &allocator, Args &&...args) {
201+
template<typename Type, typename... Args>
202+
constexpr Type make_obj_using_allocator(const auto &allocator, Args &&...args) {
206203
return std::make_from_tuple<Type>(internal::uses_allocator_construction<Type>::args(allocator, std::forward<Args>(args)...));
207204
}
208205

@@ -213,15 +210,14 @@ constexpr Type make_obj_using_allocator(const Allocator &allocator, Args &&...ar
213210
* means of uses-allocator construction at an uninitialized memory location.
214211
*
215212
* @tparam Type Type of object to create.
216-
* @tparam Allocator Type of allocator used to manage memory and elements.
217213
* @tparam Args Types of arguments to use to construct the object.
218214
* @param value Memory location in which to place the object.
219215
* @param allocator The allocator to use.
220216
* @param args Parameters to use to construct the object.
221217
* @return A pointer to the newly created object of the given type.
222218
*/
223-
template<typename Type, typename Allocator, typename... Args>
224-
constexpr Type *uninitialized_construct_using_allocator(Type *value, const Allocator &allocator, Args &&...args) {
219+
template<typename Type, typename... Args>
220+
constexpr Type *uninitialized_construct_using_allocator(Type *value, const auto &allocator, Args &&...args) {
225221
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)...));
226222
}
227223

src/entt/locator/locator.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,14 @@ class locator final {
108108
/**
109109
* @brief Sets or replaces a service using a given allocator.
110110
* @tparam Type Service type.
111-
* @tparam Allocator Type of allocator used to manage memory and elements.
112111
* @tparam Args Types of arguments to use to construct the service.
113112
* @param alloc The allocator to use.
114113
* @param args Parameters to use to construct the service.
115114
* @return A reference to a valid service.
116115
*/
117-
template<std::derived_from<Service> Type = Service, typename Allocator, typename... Args>
116+
template<std::derived_from<Service> Type = Service, typename... Args>
118117
requires std::constructible_from<Type, Args...>
119-
static Service &emplace(std::allocator_arg_t, Allocator alloc, Args &&...args) {
118+
static Service &emplace(std::allocator_arg_t, auto alloc, Args &&...args) {
120119
service = std::allocate_shared<Type>(alloc, std::forward<Args>(args)...);
121120
return *service;
122121
}

0 commit comments

Comments
 (0)