stl: std::forward

This commit is contained in:
skypjack
2026-04-01 09:34:28 +02:00
parent 4f1897e864
commit 9aeffebc7b
30 changed files with 164 additions and 163 deletions
+13 -13
View File
@@ -36,12 +36,12 @@ struct dense_map_node final {
template<typename... Args>
dense_map_node(const std::size_t pos, Args &&...args)
: next{pos},
element{std::forward<Args>(args)...} {}
element{stl::forward<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)...)} {}
element{entt::make_obj_using_allocator<value_type>(allocator, stl::forward<Args>(args)...)} {}
dense_map_node(std::allocator_arg_t, const auto &allocator, const dense_map_node &other)
: next{other.next},
@@ -272,7 +272,7 @@ class dense_map {
return std::make_pair(it, false);
}
packed.first().emplace_back(sparse.first()[index], std::piecewise_construct, stl::forward_as_tuple(std::forward<Other>(key)), stl::forward_as_tuple(std::forward<Args>(args)...));
packed.first().emplace_back(sparse.first()[index], std::piecewise_construct, stl::forward_as_tuple(stl::forward<Other>(key)), stl::forward_as_tuple(stl::forward<Args>(args)...));
sparse.first()[index] = packed.first().size() - 1u;
rehash_if_required();
@@ -284,11 +284,11 @@ class dense_map {
const auto index = key_to_bucket(key);
if(auto it = constrained_find(key, index); it != end()) {
it->second = std::forward<Arg>(value);
it->second = stl::forward<Arg>(value);
return std::make_pair(it, false);
}
packed.first().emplace_back(sparse.first()[index], std::forward<Other>(key), std::forward<Arg>(value));
packed.first().emplace_back(sparse.first()[index], stl::forward<Other>(key), stl::forward<Arg>(value));
sparse.first()[index] = packed.first().size() - 1u;
rehash_if_required();
@@ -536,7 +536,7 @@ public:
template<typename Arg>
requires std::constructible_from<value_type, Arg &&>
std::pair<iterator, bool> insert(Arg &&value) {
return insert_or_do_nothing(std::forward<Arg>(value).first, std::forward<Arg>(value).second);
return insert_or_do_nothing(stl::forward<Arg>(value).first, stl::forward<Arg>(value).second);
}
/**
@@ -561,13 +561,13 @@ public:
*/
template<typename Arg>
std::pair<iterator, bool> insert_or_assign(const key_type &key, Arg &&value) {
return insert_or_overwrite(key, std::forward<Arg>(value));
return insert_or_overwrite(key, stl::forward<Arg>(value));
}
/*! @copydoc insert_or_assign */
template<typename Arg>
std::pair<iterator, bool> insert_or_assign(key_type &&key, Arg &&value) {
return insert_or_overwrite(std::move(key), std::forward<Arg>(value));
return insert_or_overwrite(std::move(key), stl::forward<Arg>(value));
}
/**
@@ -588,11 +588,11 @@ public:
if constexpr(sizeof...(Args) == 0u) {
return insert_or_do_nothing(key_type{});
} else if constexpr(sizeof...(Args) == 1u) {
return insert_or_do_nothing(std::forward<Args>(args).first..., std::forward<Args>(args).second...);
return insert_or_do_nothing(stl::forward<Args>(args).first..., stl::forward<Args>(args).second...);
} else if constexpr(sizeof...(Args) == 2u) {
return insert_or_do_nothing(std::forward<Args>(args)...);
return insert_or_do_nothing(stl::forward<Args>(args)...);
} else {
auto &node = packed.first().emplace_back(packed.first().size(), std::forward<Args>(args)...);
auto &node = packed.first().emplace_back(packed.first().size(), stl::forward<Args>(args)...);
const auto index = key_to_bucket(node.element.first);
if(auto it = constrained_find(node.element.first, index); it != end()) {
@@ -620,13 +620,13 @@ public:
*/
template<typename... Args>
std::pair<iterator, bool> try_emplace(const key_type &key, Args &&...args) {
return insert_or_do_nothing(key, std::forward<Args>(args)...);
return insert_or_do_nothing(key, stl::forward<Args>(args)...);
}
/*! @copydoc try_emplace */
template<typename... Args>
std::pair<iterator, bool> try_emplace(key_type &&key, Args &&...args) {
return insert_or_do_nothing(std::move(key), std::forward<Args>(args)...);
return insert_or_do_nothing(std::move(key), stl::forward<Args>(args)...);
}
/**
+3 -3
View File
@@ -235,7 +235,7 @@ class dense_set {
return std::make_pair(it, false);
}
packed.first().emplace_back(sparse.first()[index], std::forward<Other>(value));
packed.first().emplace_back(sparse.first()[index], stl::forward<Other>(value));
sparse.first()[index] = packed.first().size() - 1u;
rehash_if_required();
@@ -545,9 +545,9 @@ public:
template<typename... Args>
std::pair<iterator, bool> emplace(Args &&...args) {
if constexpr(((sizeof...(Args) == 1u) && ... && stl::is_same_v<std::decay_t<Args>, value_type>)) {
return insert_or_do_nothing(std::forward<Args>(args)...);
return insert_or_do_nothing(stl::forward<Args>(args)...);
} else {
auto &node = packed.first().emplace_back(std::piecewise_construct, stl::make_tuple(packed.first().size()), stl::forward_as_tuple(std::forward<Args>(args)...));
auto &node = packed.first().emplace_back(std::piecewise_construct, stl::make_tuple(packed.first().size()), stl::forward_as_tuple(stl::forward<Args>(args)...));
const auto index = value_to_bucket(node.second);
if(auto it = constrained_find(node.second, index); it != end()) {
+1 -1
View File
@@ -369,7 +369,7 @@ public:
if constexpr(sizeof...(Args) == 0u) {
return stl::forward_as_tuple(std::get<Container>(payload).emplace_back()...);
} else {
return stl::forward_as_tuple(std::get<Container>(payload).emplace_back(std::forward<Args>(args))...);
return stl::forward_as_tuple(std::get<Container>(payload).emplace_back(stl::forward<Args>(args))...);
}
}
+1 -1
View File
@@ -34,7 +34,7 @@ struct std_sort {
*/
template<typename Compare = std::less<>, typename... Args>
void operator()(stl::random_access_iterator auto first, stl::random_access_iterator auto last, Compare compare = Compare{}, Args &&...args) const {
std::sort(std::forward<Args>(args)..., std::move(first), std::move(last), std::move(compare));
std::sort(stl::forward<Args>(args)..., std::move(first), std::move(last), std::move(compare));
}
};
+10 -10
View File
@@ -152,22 +152,22 @@ class basic_any: private internal::basic_any_storage<Len, Align> {
mode = any_policy::embedded;
if constexpr(std::is_aggregate_v<plain_type> && (sizeof...(Args) != 0u || !std::is_default_constructible_v<plain_type>)) {
::new(&this->buffer) plain_type{std::forward<Args>(args)...};
::new(&this->buffer) plain_type{stl::forward<Args>(args)...};
} else {
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
::new(&this->buffer) plain_type(std::forward<Args>(args)...);
::new(&this->buffer) plain_type(stl::forward<Args>(args)...);
}
} else {
deleter = &basic_deleter<plain_type>;
mode = any_policy::dynamic;
if constexpr(std::is_aggregate_v<plain_type> && (sizeof...(Args) != 0u || !std::is_default_constructible_v<plain_type>)) {
this->instance = new plain_type{std::forward<Args>(args)...};
this->instance = new plain_type{stl::forward<Args>(args)...};
} else if constexpr(std::is_array_v<plain_type>) {
static_assert(sizeof...(Args) == 0u, "Invalid arguments");
this->instance = new plain_type[std::extent_v<plain_type>]();
} else {
this->instance = new plain_type(std::forward<Args>(args)...);
this->instance = new plain_type(stl::forward<Args>(args)...);
}
}
}
@@ -197,7 +197,7 @@ public:
template<typename Type, typename... Args>
explicit basic_any(std::in_place_type_t<Type>, Args &&...args)
: base_type{} {
initialize<Type>(std::forward<Args>(args)...);
initialize<Type>(stl::forward<Args>(args)...);
}
/**
@@ -226,7 +226,7 @@ public:
template<typename Type>
requires (!std::same_as<stl::remove_cvref_t<Type>, basic_any>)
basic_any(Type &&value)
: basic_any{std::in_place_type<std::decay_t<Type>>, std::forward<Type>(value)} {}
: basic_any{std::in_place_type<std::decay_t<Type>>, stl::forward<Type>(value)} {}
/**
* @brief Copy constructor.
@@ -311,7 +311,7 @@ public:
template<typename Type>
requires (!std::same_as<stl::remove_cvref_t<Type>, basic_any>)
basic_any &operator=(Type &&value) {
emplace<std::decay_t<Type>>(std::forward<Type>(value));
emplace<std::decay_t<Type>>(stl::forward<Type>(value));
return *this;
}
@@ -425,7 +425,7 @@ public:
template<typename Type, typename... Args>
void emplace(Args &&...args) {
invoke_deleter_if_exists();
initialize<Type>(std::forward<Args>(args)...);
initialize<Type>(stl::forward<Args>(args)...);
}
/**
@@ -601,7 +601,7 @@ template<typename Type, std::size_t Len, std::size_t Align>
*/
template<typename Type, std::size_t Len = basic_any<>::length, std::size_t Align = basic_any<Len>::alignment, typename... Args>
[[nodiscard]] basic_any<Len, Align> make_any(Args &&...args) {
return basic_any<Len, Align>{std::in_place_type<Type>, std::forward<Args>(args)...};
return basic_any<Len, Align>{std::in_place_type<Type>, stl::forward<Args>(args)...};
}
/**
@@ -614,7 +614,7 @@ template<typename Type, std::size_t Len = basic_any<>::length, std::size_t Align
*/
template<std::size_t Len = basic_any<>::length, std::size_t Align = basic_any<Len>::alignment, typename Type>
[[nodiscard]] basic_any<Len, Align> forward_as_any(Type &&value) {
return basic_any<Len, Align>{std::in_place_type<Type &&>, std::forward<Type>(value)};
return basic_any<Len, Align>{std::in_place_type<Type &&>, stl::forward<Type>(value)};
}
} // namespace entt
+6 -6
View File
@@ -26,11 +26,11 @@ struct compressed_pair_element {
template<typename Arg>
constexpr compressed_pair_element(Arg &&arg) noexcept(std::is_nothrow_constructible_v<Type, Arg>)
requires (!std::same_as<stl::remove_cvref_t<Arg>, compressed_pair_element>)
: value{std::forward<Arg>(arg)} {}
: value{stl::forward<Arg>(arg)} {}
template<typename... Args, std::size_t... Index>
constexpr compressed_pair_element(stl::tuple<Args...> args, std::index_sequence<Index...>) noexcept(std::is_nothrow_constructible_v<Type, Args...>)
: value{std::forward<Args>(std::get<Index>(args))...} {}
: value{stl::forward<Args>(std::get<Index>(args))...} {}
[[nodiscard]] constexpr reference get() noexcept {
return value;
@@ -58,11 +58,11 @@ struct compressed_pair_element<Type, Tag>: Type {
template<typename Arg>
constexpr compressed_pair_element(Arg &&arg) noexcept(std::is_nothrow_constructible_v<base_type, Arg>)
requires (!std::same_as<stl::remove_cvref_t<Arg>, compressed_pair_element>)
: base_type{std::forward<Arg>(arg)} {}
: base_type{stl::forward<Arg>(arg)} {}
template<typename... Args, std::size_t... Index>
constexpr compressed_pair_element(stl::tuple<Args...> args, std::index_sequence<Index...>) noexcept(std::is_nothrow_constructible_v<base_type, Args...>)
: base_type{std::forward<Args>(std::get<Index>(args))...} {}
: base_type{stl::forward<Args>(std::get<Index>(args))...} {}
[[nodiscard]] constexpr reference get() noexcept {
return *this;
@@ -130,8 +130,8 @@ public:
*/
template<typename Arg, typename Other>
constexpr compressed_pair(Arg &&arg, Other &&other) noexcept(std::is_nothrow_constructible_v<first_base, Arg> && std::is_nothrow_constructible_v<second_base, Other>)
: first_base{std::forward<Arg>(arg)},
second_base{std::forward<Other>(other)} {}
: first_base{stl::forward<Arg>(arg)},
second_base{stl::forward<Other>(other)} {}
/**
* @brief Constructs a pair by forwarding the arguments to its parts.
+10 -10
View File
@@ -102,7 +102,7 @@ constexpr auto allocate_unique(Allocator &allocator, Args &&...args) {
auto ptr = alloc_traits::allocate(alloc, 1u);
ENTT_TRY {
alloc_traits::construct(alloc, stl::to_address(ptr), std::forward<Args>(args)...);
alloc_traits::construct(alloc, stl::to_address(ptr), stl::forward<Args>(args)...);
}
ENTT_CATCH {
alloc_traits::deallocate(alloc, ptr, 1u);
@@ -120,15 +120,15 @@ struct uses_allocator_construction {
template<typename Allocator, typename... Params>
static constexpr auto args([[maybe_unused]] const Allocator &allocator, Params &&...params) noexcept {
if constexpr(!std::uses_allocator_v<Type, Allocator> && std::is_constructible_v<Type, Params...>) {
return stl::forward_as_tuple(std::forward<Params>(params)...);
return stl::forward_as_tuple(stl::forward<Params>(params)...);
} else {
static_assert(std::uses_allocator_v<Type, Allocator>, "Ill-formed request");
if constexpr(std::is_constructible_v<Type, std::allocator_arg_t, const Allocator &, Params...>) {
return stl::tuple<std::allocator_arg_t, const Allocator &, Params &&...>{std::allocator_arg, allocator, std::forward<Params>(params)...};
return stl::tuple<std::allocator_arg_t, const Allocator &, Params &&...>{std::allocator_arg, allocator, stl::forward<Params>(params)...};
} else {
static_assert(std::is_constructible_v<Type, Params..., const Allocator &>, "Ill-formed request");
return stl::forward_as_tuple(std::forward<Params>(params)..., allocator);
return stl::forward_as_tuple(stl::forward<Params>(params)..., allocator);
}
}
}
@@ -142,8 +142,8 @@ struct uses_allocator_construction<std::pair<Type, Other>> {
static constexpr auto args(const auto &allocator, std::piecewise_construct_t, First &&first, Second &&second) noexcept {
return stl::make_tuple(
std::piecewise_construct,
stl::apply([&allocator](auto &&...curr) { return uses_allocator_construction<Type>::args(allocator, std::forward<decltype(curr)>(curr)...); }, std::forward<First>(first)),
stl::apply([&allocator](auto &&...curr) { return uses_allocator_construction<Other>::args(allocator, std::forward<decltype(curr)>(curr)...); }, std::forward<Second>(second)));
stl::apply([&allocator](auto &&...curr) { return uses_allocator_construction<Type>::args(allocator, stl::forward<decltype(curr)>(curr)...); }, stl::forward<First>(first)),
stl::apply([&allocator](auto &&...curr) { return uses_allocator_construction<Other>::args(allocator, stl::forward<decltype(curr)>(curr)...); }, stl::forward<Second>(second)));
}
static constexpr auto args(const auto &allocator) noexcept {
@@ -152,7 +152,7 @@ struct uses_allocator_construction<std::pair<Type, Other>> {
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, stl::forward_as_tuple(std::forward<First>(first)), stl::forward_as_tuple(std::forward<Second>(second)));
return uses_allocator_construction<type>::args(allocator, std::piecewise_construct, stl::forward_as_tuple(stl::forward<First>(first)), stl::forward_as_tuple(stl::forward<Second>(second)));
}
template<typename First, typename Second>
@@ -183,7 +183,7 @@ struct uses_allocator_construction<std::pair<Type, Other>> {
*/
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)...);
return internal::uses_allocator_construction<Type>::args(allocator, stl::forward<Args>(args)...);
}
/**
@@ -200,7 +200,7 @@ constexpr auto uses_allocator_construction_args(const auto &allocator, 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)...));
return std::make_from_tuple<Type>(internal::uses_allocator_construction<Type>::args(allocator, stl::forward<Args>(args)...));
}
/**
@@ -218,7 +218,7 @@ constexpr Type make_obj_using_allocator(const auto &allocator, Args &&...args) {
*/
template<typename Type, typename... Args>
constexpr Type *uninitialized_construct_using_allocator(Type *value, const auto &allocator, Args &&...args) {
return stl::apply([value](auto &&...curr) { return ::new(value) Type(std::forward<decltype(curr)>(curr)...); }, internal::uses_allocator_construction<Type>::args(allocator, std::forward<Args>(args)...));
return stl::apply([value](auto &&...curr) { return ::new(value) Type(stl::forward<decltype(curr)>(curr)...); }, internal::uses_allocator_construction<Type>::args(allocator, stl::forward<Args>(args)...));
}
} // namespace entt
+5 -5
View File
@@ -39,9 +39,9 @@ inline constexpr bool is_tuple_v = is_tuple<Type>::value;
template<typename Type>
constexpr decltype(auto) unwrap_tuple(Type &&value) noexcept {
if constexpr(stl::tuple_size_v<std::remove_reference_t<Type>> == 1u) {
return std::get<0>(std::forward<Type>(value));
return std::get<0>(stl::forward<Type>(value));
} else {
return std::forward<Type>(value);
return stl::forward<Type>(value);
}
}
@@ -58,7 +58,7 @@ struct forward_apply: private Func {
*/
template<typename... Args>
constexpr forward_apply(Args &&...args) noexcept(std::is_nothrow_constructible_v<Func, Args...>)
: Func{std::forward<Args>(args)...} {}
: Func{stl::forward<Args>(args)...} {}
/**
* @brief Forwards and applies the arguments with the underlying function.
@@ -68,13 +68,13 @@ struct forward_apply: private Func {
*/
template<typename Type>
constexpr decltype(auto) operator()(Type &&args) noexcept(noexcept(stl::apply(stl::declval<Func &>(), args))) {
return stl::apply(static_cast<Func &>(*this), std::forward<Type>(args));
return stl::apply(static_cast<Func &>(*this), stl::forward<Type>(args));
}
/*! @copydoc operator()() */
template<typename Type>
constexpr decltype(auto) operator()(Type &&args) const noexcept(noexcept(stl::apply(stl::declval<const Func &>(), args))) {
return stl::apply(static_cast<const Func &>(*this), std::forward<Type>(args));
return stl::apply(static_cast<const Func &>(*this), stl::forward<Type>(args));
}
};
+2 -2
View File
@@ -66,13 +66,13 @@ struct y_combinator {
*/
template<typename... Args>
constexpr decltype(auto) operator()(Args &&...args) const noexcept(std::is_nothrow_invocable_v<Func, const y_combinator &, Args...>) {
return func(*this, std::forward<Args>(args)...);
return func(*this, stl::forward<Args>(args)...);
}
/*! @copydoc operator()() */
template<typename... Args>
constexpr decltype(auto) operator()(Args &&...args) noexcept(std::is_nothrow_invocable_v<Func, y_combinator &, Args...>) {
return func(*this, std::forward<Args>(args)...);
return func(*this, stl::forward<Args>(args)...);
}
private:
+7 -7
View File
@@ -597,7 +597,7 @@ public:
*/
template<typename Type, typename... Other, typename Compare, typename Sort = std_sort, typename... Args>
void sort(Compare compare, Sort algo = Sort{}, Args &&...args) {
sort<index_of<Type>, index_of<Other>...>(std::move(compare), std::move(algo), std::forward<Args>(args)...);
sort<index_of<Type>, index_of<Other>...>(std::move(compare), std::move(algo), stl::forward<Args>(args)...);
}
/**
@@ -618,7 +618,7 @@ public:
if(*this) {
if constexpr(sizeof...(Index) == 0) {
static_assert(std::is_invocable_v<Compare, const entity_type, const entity_type>, "Invalid comparison function");
descriptor->handle().sort(std::move(compare), std::move(algo), std::forward<Args>(args)...);
descriptor->handle().sort(std::move(compare), std::move(algo), stl::forward<Args>(args)...);
} else {
auto comp = [&compare, cpools = pools_for(std::index_sequence_for<Get...>{})](const entity_type lhs, const entity_type rhs) {
if constexpr(sizeof...(Index) == 1) {
@@ -628,7 +628,7 @@ public:
}
};
descriptor->handle().sort(std::move(comp), std::move(algo), std::forward<Args>(args)...);
descriptor->handle().sort(std::move(comp), std::move(algo), stl::forward<Args>(args)...);
}
}
}
@@ -938,7 +938,7 @@ public:
if constexpr(is_applicable_v<Func, decltype(stl::tuple_cat(stl::tuple<entity_type>{}, stl::declval<basic_group>().get({})))>) {
stl::apply(func, args);
} else {
stl::apply([&func](auto, auto &&...less) { func(std::forward<decltype(less)>(less)...); }, args);
stl::apply([&func](auto, auto &&...less) { func(stl::forward<decltype(less)>(less)...); }, args);
}
}
}
@@ -997,7 +997,7 @@ public:
*/
template<typename Type, typename... Other, typename Compare, typename Sort = std_sort, typename... Args>
void sort(Compare compare, Sort algo = Sort{}, Args &&...args) const {
sort<index_of<Type>, index_of<Other>...>(std::move(compare), std::move(algo), std::forward<Args>(args)...);
sort<index_of<Type>, index_of<Other>...>(std::move(compare), std::move(algo), stl::forward<Args>(args)...);
}
/**
@@ -1019,7 +1019,7 @@ public:
if constexpr(sizeof...(Index) == 0) {
static_assert(std::is_invocable_v<Compare, const entity_type, const entity_type>, "Invalid comparison function");
storage<0>()->sort_n(descriptor->length(), std::move(compare), std::move(algo), std::forward<Args>(args)...);
storage<0>()->sort_n(descriptor->length(), std::move(compare), std::move(algo), stl::forward<Args>(args)...);
} else {
auto comp = [&compare, &cpools](const entity_type lhs, const entity_type rhs) {
if constexpr(sizeof...(Index) == 1) {
@@ -1029,7 +1029,7 @@ public:
}
};
storage<0>()->sort_n(descriptor->length(), std::move(comp), std::move(algo), std::forward<Args>(args)...);
storage<0>()->sort_n(descriptor->length(), std::move(comp), std::move(algo), stl::forward<Args>(args)...);
}
auto cb = [this](auto *head, auto *...other) {
+5 -5
View File
@@ -195,7 +195,7 @@ public:
// NOLINTNEXTLINE(modernize-use-nodiscard)
decltype(auto) emplace(Args &&...args) const {
static_assert(((sizeof...(Scope) == 0) || ... || stl::is_same_v<Type, Scope>), "Invalid type");
return owner_or_assert().template emplace<Type>(entt, std::forward<Args>(args)...);
return owner_or_assert().template emplace<Type>(entt, stl::forward<Args>(args)...);
}
/**
@@ -208,7 +208,7 @@ public:
template<typename Type, typename... Args>
decltype(auto) emplace_or_replace(Args &&...args) const {
static_assert(((sizeof...(Scope) == 0) || ... || stl::is_same_v<Type, Scope>), "Invalid type");
return owner_or_assert().template emplace_or_replace<Type>(entt, std::forward<Args>(args)...);
return owner_or_assert().template emplace_or_replace<Type>(entt, stl::forward<Args>(args)...);
}
/**
@@ -221,7 +221,7 @@ public:
template<typename Type, typename... Func>
decltype(auto) patch(Func &&...func) const {
static_assert(((sizeof...(Scope) == 0) || ... || stl::is_same_v<Type, Scope>), "Invalid type");
return owner_or_assert().template patch<Type>(entt, std::forward<Func>(func)...);
return owner_or_assert().template patch<Type>(entt, stl::forward<Func>(func)...);
}
/**
@@ -234,7 +234,7 @@ public:
template<typename Type, typename... Args>
decltype(auto) replace(Args &&...args) const {
static_assert(((sizeof...(Scope) == 0) || ... || stl::is_same_v<Type, Scope>), "Invalid type");
return owner_or_assert().template replace<Type>(entt, std::forward<Args>(args)...);
return owner_or_assert().template replace<Type>(entt, stl::forward<Args>(args)...);
}
/**
@@ -301,7 +301,7 @@ public:
template<typename Type, typename... Args>
[[nodiscard]] decltype(auto) get_or_emplace(Args &&...args) const {
static_assert(((sizeof...(Scope) == 0) || ... || stl::is_same_v<Type, Scope>), "Invalid type");
return owner_or_assert().template get_or_emplace<Type>(entt, std::forward<Args>(args)...);
return owner_or_assert().template get_or_emplace<Type>(entt, stl::forward<Args>(args)...);
}
/**
+3 -3
View File
@@ -210,7 +210,7 @@ struct sigh_helper<Registry, Type> final: sigh_helper<Registry> {
*/
template<auto Candidate, typename... Args>
auto on_construct(Args &&...args) {
this->registry().template on_construct<Type>(name).template connect<Candidate>(std::forward<Args>(args)...);
this->registry().template on_construct<Type>(name).template connect<Candidate>(stl::forward<Args>(args)...);
return *this;
}
@@ -223,7 +223,7 @@ struct sigh_helper<Registry, Type> final: sigh_helper<Registry> {
*/
template<auto Candidate, typename... Args>
auto on_update(Args &&...args) {
this->registry().template on_update<Type>(name).template connect<Candidate>(std::forward<Args>(args)...);
this->registry().template on_update<Type>(name).template connect<Candidate>(stl::forward<Args>(args)...);
return *this;
}
@@ -236,7 +236,7 @@ struct sigh_helper<Registry, Type> final: sigh_helper<Registry> {
*/
template<auto Candidate, typename... Args>
auto on_destroy(Args &&...args) {
this->registry().template on_destroy<Type>(name).template connect<Candidate>(std::forward<Args>(args)...);
this->registry().template on_destroy<Type>(name).template connect<Candidate>(stl::forward<Args>(args)...);
return *this;
}
+3 -3
View File
@@ -336,7 +336,7 @@ public:
*/
template<typename... Args>
decltype(auto) emplace(const entity_type entt, Args &&...args) {
underlying_type::emplace(entt, std::forward<Args>(args)...);
underlying_type::emplace(entt, stl::forward<Args>(args)...);
construction.publish(owner_or_assert(), entt);
return this->get(entt);
}
@@ -350,7 +350,7 @@ public:
*/
template<typename... Func>
decltype(auto) patch(const entity_type entt, Func &&...func) {
underlying_type::patch(entt, std::forward<Func>(func)...);
underlying_type::patch(entt, stl::forward<Func>(func)...);
update.publish(owner_or_assert(), entt);
return this->get(entt);
}
@@ -366,7 +366,7 @@ public:
template<typename... Args>
void insert(stl::input_iterator auto first, stl::input_iterator auto last, Args &&...args) {
auto from = underlying_type::size();
underlying_type::insert(first, last, std::forward<Args>(args)...);
underlying_type::insert(first, last, stl::forward<Args>(args)...);
if(auto &reg = owner_or_assert(); !construction.empty()) {
// fine as long as insert passes force_back true to try_emplace
+11 -11
View File
@@ -144,22 +144,22 @@ public:
template<typename Type, typename... Args>
Type &emplace_as(const id_type id, Args &&...args) {
return any_cast<Type &>(ctx.try_emplace(id, std::in_place_type<Type>, std::forward<Args>(args)...).first->second);
return any_cast<Type &>(ctx.try_emplace(id, std::in_place_type<Type>, stl::forward<Args>(args)...).first->second);
}
template<typename Type, typename... Args>
Type &emplace(Args &&...args) {
return emplace_as<Type>(type_id<Type>().hash(), std::forward<Args>(args)...);
return emplace_as<Type>(type_id<Type>().hash(), stl::forward<Args>(args)...);
}
template<typename Type>
Type &insert_or_assign(const id_type id, Type &&value) {
return any_cast<stl::remove_cvref_t<Type> &>(ctx.insert_or_assign(id, std::forward<Type>(value)).first->second);
return any_cast<stl::remove_cvref_t<Type> &>(ctx.insert_or_assign(id, stl::forward<Type>(value)).first->second);
}
template<typename Type>
Type &insert_or_assign(Type &&value) {
return insert_or_assign(type_id<Type>().hash(), std::forward<Type>(value));
return insert_or_assign(type_id<Type>().hash(), stl::forward<Type>(value));
}
template<typename Type>
@@ -566,7 +566,7 @@ public:
template<typename Type, typename... Args>
decltype(auto) emplace(const entity_type entt, Args &&...args) {
ENTT_ASSERT(valid(entt), "Invalid entity");
return assure<Type>().emplace(entt, std::forward<Args>(args)...);
return assure<Type>().emplace(entt, stl::forward<Args>(args)...);
}
/**
@@ -620,7 +620,7 @@ public:
decltype(auto) emplace_or_replace(const entity_type entt, Args &&...args) {
auto &cpool = assure<Type>();
ENTT_ASSERT(valid(entt), "Invalid entity");
return cpool.contains(entt) ? cpool.patch(entt, [&args...](auto &...curr) { ((curr = Type{std::forward<Args>(args)...}), ...); }) : cpool.emplace(entt, std::forward<Args>(args)...);
return cpool.contains(entt) ? cpool.patch(entt, [&args...](auto &...curr) { ((curr = Type{stl::forward<Args>(args)...}), ...); }) : cpool.emplace(entt, stl::forward<Args>(args)...);
}
/**
@@ -644,7 +644,7 @@ public:
*/
template<typename Type, typename... Func>
decltype(auto) patch(const entity_type entt, Func &&...func) {
return assure<Type>().patch(entt, std::forward<Func>(func)...);
return assure<Type>().patch(entt, stl::forward<Func>(func)...);
}
/**
@@ -664,7 +664,7 @@ public:
*/
template<typename Type, typename... Args>
decltype(auto) replace(const entity_type entt, Args &&...args) {
return patch<Type>(entt, [&args...](auto &...curr) { ((curr = Type{std::forward<Args>(args)...}), ...); });
return patch<Type>(entt, [&args...](auto &...curr) { ((curr = Type{stl::forward<Args>(args)...}), ...); });
}
/**
@@ -882,7 +882,7 @@ public:
[[nodiscard]] decltype(auto) get_or_emplace(const entity_type entt, Args &&...args) {
auto &cpool = assure<Type>();
ENTT_ASSERT(valid(entt), "Invalid entity");
return cpool.contains(entt) ? cpool.get(entt) : cpool.emplace(entt, std::forward<Args>(args)...);
return cpool.contains(entt) ? cpool.get(entt) : cpool.emplace(entt, stl::forward<Args>(args)...);
}
/**
@@ -1131,9 +1131,9 @@ public:
if constexpr(std::is_invocable_v<Compare, decltype(cpool.get({})), decltype(cpool.get({}))>) {
auto comp = [&cpool, compare = std::move(compare)](const auto lhs, const auto rhs) { return compare(std::as_const(cpool.get(lhs)), std::as_const(cpool.get(rhs))); };
cpool.sort(std::move(comp), std::move(algo), std::forward<Args>(args)...);
cpool.sort(std::move(comp), std::move(algo), stl::forward<Args>(args)...);
} else {
cpool.sort(std::move(compare), std::move(algo), std::forward<Args>(args)...);
cpool.sort(std::move(compare), std::move(algo), stl::forward<Args>(args)...);
}
}
+3 -3
View File
@@ -107,12 +107,12 @@ public:
archive(static_cast<entity_type>(null));
} else {
archive(entt);
stl::apply([&archive](auto &&...args) { (archive(std::forward<decltype(args)>(args)), ...); }, storage->get_as_tuple(entt));
stl::apply([&archive](auto &&...args) { (archive(stl::forward<decltype(args)>(args)), ...); }, storage->get_as_tuple(entt));
}
}
} else {
for(auto elem: storage->reach()) {
stl::apply([&archive](auto &&...args) { (archive(std::forward<decltype(args)>(args)), ...); }, elem);
stl::apply([&archive](auto &&...args) { (archive(stl::forward<decltype(args)>(args)), ...); }, elem);
}
}
} else {
@@ -143,7 +143,7 @@ public:
for(; first != last; ++first) {
if(const auto entt = *first; storage->contains(entt)) {
archive(entt);
stl::apply([&archive](auto &&...args) { (archive(std::forward<decltype(args)>(args)), ...); }, storage->get_as_tuple(entt));
stl::apply([&archive](auto &&...args) { (archive(stl::forward<decltype(args)>(args)), ...); }, storage->get_as_tuple(entt));
} else {
archive(static_cast<entity_type>(null));
}
+3 -3
View File
@@ -967,7 +967,7 @@ public:
ENTT_ASSERT((mode != deletion_policy::in_place) || (head == max_size), "Sorting with tombstones not allowed");
ENTT_ASSERT(!(length > packed.size()), "Length exceeds the number of elements");
algo(packed.rend() - static_cast<difference_type>(length), packed.rend(), std::move(compare), std::forward<Args>(args)...);
algo(packed.rend() - static_cast<difference_type>(length), packed.rend(), std::move(compare), stl::forward<Args>(args)...);
for(size_type pos{}; pos < length; ++pos) {
auto curr = pos;
@@ -1000,7 +1000,7 @@ public:
template<typename Compare, typename Sort = std_sort, typename... Args>
void sort(Compare compare, Sort algo = Sort{}, Args &&...args) {
const size_type len = (mode == deletion_policy::swap_only) ? head : packed.size();
sort_n(len, std::move(compare), std::move(algo), std::forward<Args>(args)...);
sort_n(len, std::move(compare), std::move(algo), stl::forward<Args>(args)...);
}
/**
@@ -1060,7 +1060,7 @@ public:
*/
template<typename Type>
void bind(Type &&value) noexcept {
bind_any(forward_as_any(std::forward<Type>(value)));
bind_any(forward_as_any(stl::forward<Type>(value)));
}
private:
+6 -6
View File
@@ -246,7 +246,7 @@ class basic_storage: public basic_sparse_set<Entity, typename std::allocator_tra
ENTT_TRY {
auto *elem = stl::to_address(assure_at_least(static_cast<size_type>(it.index())));
entt::uninitialized_construct_using_allocator(elem, get_allocator(), std::forward<Args>(args)...);
entt::uninitialized_construct_using_allocator(elem, get_allocator(), stl::forward<Args>(args)...);
}
ENTT_CATCH {
base_type::pop(it, it + 1u);
@@ -668,10 +668,10 @@ public:
template<typename... Args>
value_type &emplace(const entity_type entt, Args &&...args) {
if constexpr(std::is_aggregate_v<value_type> && (sizeof...(Args) != 0u || !std::is_default_constructible_v<value_type>)) {
const auto it = emplace_element(entt, false, Type{std::forward<Args>(args)...});
const auto it = emplace_element(entt, false, Type{stl::forward<Args>(args)...});
return element_at(static_cast<size_type>(it.index()));
} else {
const auto it = emplace_element(entt, false, std::forward<Args>(args)...);
const auto it = emplace_element(entt, false, stl::forward<Args>(args)...);
return element_at(static_cast<size_type>(it.index()));
}
}
@@ -687,7 +687,7 @@ public:
value_type &patch(const entity_type entt, Func &&...func) {
const auto idx = base_type::index(entt);
auto &elem = element_at(idx);
(std::forward<Func>(func)(elem), ...);
(stl::forward<Func>(func)(elem), ...);
return elem;
}
@@ -903,7 +903,7 @@ public:
template<typename... Func>
void patch([[maybe_unused]] const entity_type entt, Func &&...func) {
ENTT_ASSERT(base_type::contains(entt), "Invalid entity");
(std::forward<Func>(func)(), ...);
(stl::forward<Func>(func)(), ...);
}
/**
@@ -1164,7 +1164,7 @@ public:
template<typename... Func>
void patch([[maybe_unused]] const entity_type entt, Func &&...func) {
ENTT_ASSERT(base_type::index(entt) < base_type::free_list(), "The requested entity is not a live one");
(std::forward<Func>(func)(), ...);
(stl::forward<Func>(func)(), ...);
}
/**
+1 -1
View File
@@ -1073,7 +1073,7 @@ public:
static_assert(Get::storage_policy == deletion_policy::in_place, "Unexpected storage policy");
for(const auto pack: each()) {
stl::apply([&func](const auto, auto &&...elem) { func(std::forward<decltype(elem)>(elem)...); }, pack);
stl::apply([&func](const auto, auto &&...elem) { func(stl::forward<decltype(elem)>(elem)...); }, pack);
}
}
}
+3 -3
View File
@@ -88,7 +88,7 @@ public:
template<std::derived_from<Service> Type = Service, typename... Args>
requires std::constructible_from<Type, Args...>
[[nodiscard]] static Service &value_or(Args &&...args) {
return service ? *service : emplace<Type>(std::forward<Args>(args)...);
return service ? *service : emplace<Type>(stl::forward<Args>(args)...);
}
/**
@@ -101,7 +101,7 @@ public:
template<std::derived_from<Service> Type = Service, typename... Args>
requires std::constructible_from<Type, Args...>
static Service &emplace(Args &&...args) {
service = std::make_shared<Type>(std::forward<Args>(args)...);
service = std::make_shared<Type>(stl::forward<Args>(args)...);
return *service;
}
@@ -116,7 +116,7 @@ public:
template<std::derived_from<Service> Type = Service, typename... Args>
requires std::constructible_from<Type, Args...>
static Service &emplace(std::allocator_arg_t, auto alloc, Args &&...args) {
service = std::allocate_shared<Type>(alloc, std::forward<Args>(args)...);
service = std::allocate_shared<Type>(alloc, stl::forward<Args>(args)...);
return *service;
}
+1 -1
View File
@@ -534,7 +534,7 @@ public:
*/
template<typename Value, typename... Args>
meta_factory custom(Args &&...args) {
base_type::custom(internal::meta_custom_node{type_id<Value>().hash(), std::make_shared<Value>(std::forward<Args>(args)...)});
base_type::custom(internal::meta_custom_node{type_id<Value>().hash(), std::make_shared<Value>(stl::forward<Args>(args)...)});
return *this;
}
};
+22 -22
View File
@@ -249,7 +249,7 @@ public:
*/
template<typename Type, typename... Args>
explicit meta_any(std::in_place_type_t<Type>, Args &&...args)
: meta_any{locator<meta_ctx>::value_or(), std::in_place_type<Type>, std::forward<Args>(args)...} {}
: meta_any{locator<meta_ctx>::value_or(), std::in_place_type<Type>, stl::forward<Args>(args)...} {}
/**
* @brief Constructs a wrapper by directly initializing the new object.
@@ -260,7 +260,7 @@ public:
*/
template<typename Type, typename... Args>
explicit meta_any(const meta_ctx &area, std::in_place_type_t<Type>, Args &&...args)
: storage{std::in_place_type<Type>, std::forward<Args>(args)...},
: storage{std::in_place_type<Type>, stl::forward<Args>(args)...},
ctx{&area},
vtable{&basic_vtable<stl::remove_cvref_t<Type>>} {}
@@ -294,7 +294,7 @@ public:
template<typename Type>
requires (!std::same_as<stl::remove_cvref_t<Type>, meta_any>)
meta_any(Type &&value)
: meta_any{locator<meta_ctx>::value_or(), std::forward<Type>(value)} {}
: meta_any{locator<meta_ctx>::value_or(), stl::forward<Type>(value)} {}
/**
* @brief Constructs a wrapper from a given value.
@@ -305,7 +305,7 @@ public:
template<typename Type>
requires (!std::same_as<stl::remove_cvref_t<Type>, meta_any>)
meta_any(const meta_ctx &area, Type &&value)
: meta_any{area, std::in_place_type<std::decay_t<Type>>, std::forward<Type>(value)} {}
: meta_any{area, std::in_place_type<std::decay_t<Type>>, stl::forward<Type>(value)} {}
/**
* @brief Context aware copy constructor.
@@ -391,7 +391,7 @@ public:
template<typename Type>
requires (!std::same_as<stl::remove_cvref_t<Type>, meta_any>)
meta_any &operator=(Type &&value) {
emplace<std::decay_t<Type>>(std::forward<Type>(value));
emplace<std::decay_t<Type>>(stl::forward<Type>(value));
return *this;
}
@@ -550,7 +550,7 @@ public:
/*! @copydoc any::emplace */
template<typename Type, typename... Args>
void emplace(Args &&...args) {
storage.emplace<Type>(std::forward<Args>(args)...);
storage.emplace<Type>(stl::forward<Args>(args)...);
auto *prev = stl::exchange(vtable, &basic_vtable<stl::remove_cvref_t<Type>>);
node = (prev == vtable) ? node : nullptr;
}
@@ -672,7 +672,7 @@ private:
*/
template<typename Type>
[[nodiscard]] meta_any forward_as_meta(const meta_ctx &ctx, Type &&value) {
return meta_any{ctx, std::in_place_type<Type &&>, std::forward<Type>(value)};
return meta_any{ctx, std::in_place_type<Type &&>, stl::forward<Type>(value)};
}
/**
@@ -683,7 +683,7 @@ template<typename Type>
*/
template<typename Type>
[[nodiscard]] meta_any forward_as_meta(Type &&value) {
return forward_as_meta(locator<meta_ctx>::value_or(), std::forward<Type>(value));
return forward_as_meta(locator<meta_ctx>::value_or(), stl::forward<Type>(value));
}
/*! @brief Opaque pointers to instances of any type. */
@@ -691,11 +691,11 @@ class meta_handle {
template<typename Type, typename... Args>
requires std::same_as<stl::remove_cvref_t<Type>, meta_any>
meta_handle(int, Type &value, Args &&...args)
: any{std::forward<Args>(args)..., value.as_ref()} {}
: any{stl::forward<Args>(args)..., value.as_ref()} {}
template<typename Type, typename... Args>
meta_handle(char, Type &value, Args &&...args)
: any{std::forward<Args>(args)..., std::in_place_type<Type &>, value} {}
: any{stl::forward<Args>(args)..., std::in_place_type<Type &>, value} {}
public:
/*! Default constructor. */
@@ -898,7 +898,7 @@ struct meta_data: meta_object<internal::meta_data_node> {
template<typename Instance = meta_handle, typename Type>
// NOLINTNEXTLINE(modernize-use-nodiscard)
bool set(Instance &&instance, Type &&value) const {
return node_or_assert().set(meta_handle{*ctx, std::forward<Instance>(instance)}, meta_any{*ctx, std::forward<Type>(value)});
return node_or_assert().set(meta_handle{*ctx, stl::forward<Instance>(instance)}, meta_any{*ctx, stl::forward<Type>(value)});
}
/**
@@ -909,7 +909,7 @@ struct meta_data: meta_object<internal::meta_data_node> {
*/
template<typename Instance = meta_handle>
[[nodiscard]] meta_any get(Instance &&instance) const {
return node_or_assert().get(meta_handle{*ctx, std::forward<Instance>(instance)});
return node_or_assert().get(meta_handle{*ctx, stl::forward<Instance>(instance)});
}
/**
@@ -1000,7 +1000,7 @@ struct meta_func: meta_object<internal::meta_func_node> {
*/
template<typename Instance = meta_handle>
meta_any invoke(Instance &&instance, meta_any *const args, const size_type sz) const {
return (sz == arity()) ? node_or_assert().invoke(meta_handle{*ctx, std::forward<Instance>(instance)}, args) : meta_any{meta_ctx_arg, *ctx};
return (sz == arity()) ? node_or_assert().invoke(meta_handle{*ctx, stl::forward<Instance>(instance)}, args) : meta_any{meta_ctx_arg, *ctx};
}
/**
@@ -1014,7 +1014,7 @@ struct meta_func: meta_object<internal::meta_func_node> {
template<typename Instance = meta_handle, typename... Args>
// NOLINTNEXTLINE(modernize-use-nodiscard)
meta_any invoke(Instance &&instance, Args &&...args) const {
return invoke(std::forward<Instance>(instance), std::array<meta_any, sizeof...(Args)>{meta_any{*ctx, std::forward<Args>(args)}...}.data(), sizeof...(Args));
return invoke(stl::forward<Instance>(instance), std::array<meta_any, sizeof...(Args)>{meta_any{*ctx, stl::forward<Args>(args)}...}.data(), sizeof...(Args));
}
/*! @copydoc meta_data::traits */
@@ -1385,7 +1385,7 @@ public:
*/
template<typename... Args>
[[nodiscard]] meta_any construct(Args &&...args) const {
return construct(std::array<meta_any, sizeof...(Args)>{meta_any{*ctx, std::forward<Args>(args)}...}.data(), sizeof...(Args));
return construct(std::array<meta_any, sizeof...(Args)>{meta_any{*ctx, stl::forward<Args>(args)}...}.data(), sizeof...(Args));
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
}
@@ -1420,7 +1420,7 @@ public:
template<typename Instance = meta_handle>
// NOLINTNEXTLINE(modernize-use-nodiscard)
meta_any invoke(const id_type id, Instance &&instance, meta_any *const args, const size_type sz) const {
meta_handle wrapped{*ctx, std::forward<Instance>(instance)};
meta_handle wrapped{*ctx, stl::forward<Instance>(instance)};
if(const auto &ref = fetch_node(); ref.details) {
if(auto *elem = internal::find_member(ref.details->func, id); elem != nullptr) {
@@ -1451,7 +1451,7 @@ public:
template<typename Instance = meta_handle, typename... Args>
// NOLINTNEXTLINE(modernize-use-nodiscard)
meta_any invoke(const id_type id, Instance &&instance, Args &&...args) const {
return invoke(id, std::forward<Instance>(instance), std::array<meta_any, sizeof...(Args)>{meta_any{*ctx, std::forward<Args>(args)}...}.data(), sizeof...(Args));
return invoke(id, stl::forward<Instance>(instance), std::array<meta_any, sizeof...(Args)>{meta_any{*ctx, stl::forward<Args>(args)}...}.data(), sizeof...(Args));
}
/**
@@ -1467,7 +1467,7 @@ public:
// NOLINTNEXTLINE(modernize-use-nodiscard)
bool set(const id_type id, Instance &&instance, Type &&value) const {
const auto candidate = data(id);
return candidate && candidate.set(std::forward<Instance>(instance), std::forward<Type>(value));
return candidate && candidate.set(stl::forward<Instance>(instance), stl::forward<Type>(value));
}
/**
@@ -1480,7 +1480,7 @@ public:
template<typename Instance = meta_handle>
[[nodiscard]] meta_any get(const id_type id, Instance &&instance) const {
const auto candidate = data(id);
return candidate ? candidate.get(std::forward<Instance>(instance)) : meta_any{meta_ctx_arg, *ctx};
return candidate ? candidate.get(stl::forward<Instance>(instance)) : meta_any{meta_ctx_arg, *ctx};
}
/*! @copydoc meta_data::traits */
@@ -1516,17 +1516,17 @@ private:
template<typename... Args>
// NOLINTNEXTLINE(modernize-use-nodiscard)
meta_any meta_any::invoke(const id_type id, Args &&...args) const {
return type().invoke(id, *this, std::forward<Args>(args)...);
return type().invoke(id, *this, stl::forward<Args>(args)...);
}
template<typename... Args>
meta_any meta_any::invoke(const id_type id, Args &&...args) {
return type().invoke(id, *this, std::forward<Args>(args)...);
return type().invoke(id, *this, stl::forward<Args>(args)...);
}
template<typename Type>
bool meta_any::set(const id_type id, Type &&value) {
return type().set(id, *this, std::forward<Type>(value));
return type().set(id, *this, stl::forward<Type>(value));
}
[[nodiscard]] inline meta_any meta_any::get(const id_type id) const {
+12 -12
View File
@@ -175,7 +175,7 @@ template<meta_policy Policy = as_value_t, typename Type>
} else if constexpr(stl::is_same_v<Policy, as_void_t>) {
return meta_any{ctx, std::in_place_type<void>};
} else {
return meta_any{ctx, std::forward<Type>(value)};
return meta_any{ctx, stl::forward<Type>(value)};
}
}
@@ -188,7 +188,7 @@ template<meta_policy Policy = as_value_t, typename Type>
*/
template<meta_policy Policy = as_value_t, typename Type>
[[nodiscard]] meta_any meta_dispatch(Type &&value) {
return meta_dispatch<Policy, Type>(locator<meta_ctx>::value_or(), std::forward<Type>(value));
return meta_dispatch<Policy, Type>(locator<meta_ctx>::value_or(), stl::forward<Type>(value));
}
/*! @cond ENTT_INTERNAL */
@@ -196,11 +196,11 @@ namespace internal {
template<typename Policy, typename Candidate, typename... Args>
[[nodiscard]] meta_any meta_invoke_with_args(const meta_ctx &ctx, Candidate &&candidate, Args &&...args) {
if constexpr(std::is_void_v<decltype(std::invoke(std::forward<Candidate>(candidate), args...))>) {
std::invoke(std::forward<Candidate>(candidate), args...);
if constexpr(std::is_void_v<decltype(std::invoke(stl::forward<Candidate>(candidate), args...))>) {
std::invoke(stl::forward<Candidate>(candidate), args...);
return meta_any{ctx, std::in_place_type<void>};
} else {
return meta_dispatch<Policy>(ctx, std::invoke(std::forward<Candidate>(candidate), args...));
return meta_dispatch<Policy>(ctx, std::invoke(stl::forward<Candidate>(candidate), args...));
}
}
@@ -211,15 +211,15 @@ template<typename Type, typename Policy, typename Candidate, std::size_t... Inde
// NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic) - waiting for C++20 (and std::span)
if constexpr(std::is_invocable_v<std::remove_reference_t<Candidate>, const Type &, type_list_element_t<Index, typename descriptor::args_type>...>) {
if(const auto *const clazz = instance.try_cast<const Type>(); clazz && ((args + Index)->allow_cast<type_list_element_t<Index, typename descriptor::args_type>>() && ...)) {
return meta_invoke_with_args<Policy>(instance.context(), std::forward<Candidate>(candidate), *clazz, (args + Index)->cast<type_list_element_t<Index, typename descriptor::args_type>>()...);
return meta_invoke_with_args<Policy>(instance.context(), stl::forward<Candidate>(candidate), *clazz, (args + Index)->cast<type_list_element_t<Index, typename descriptor::args_type>>()...);
}
} else if constexpr(std::is_invocable_v<std::remove_reference_t<Candidate>, Type &, type_list_element_t<Index, typename descriptor::args_type>...>) {
if(auto *const clazz = instance.try_cast<Type>(); clazz && ((args + Index)->allow_cast<type_list_element_t<Index, typename descriptor::args_type>>() && ...)) {
return meta_invoke_with_args<Policy>(instance.context(), std::forward<Candidate>(candidate), *clazz, (args + Index)->cast<type_list_element_t<Index, typename descriptor::args_type>>()...);
return meta_invoke_with_args<Policy>(instance.context(), stl::forward<Candidate>(candidate), *clazz, (args + Index)->cast<type_list_element_t<Index, typename descriptor::args_type>>()...);
}
} else {
if(((args + Index)->allow_cast<type_list_element_t<Index, typename descriptor::args_type>>() && ...)) {
return meta_invoke_with_args<Policy>(instance.context(), std::forward<Candidate>(candidate), (args + Index)->cast<type_list_element_t<Index, typename descriptor::args_type>>()...);
return meta_invoke_with_args<Policy>(instance.context(), stl::forward<Candidate>(candidate), (args + Index)->cast<type_list_element_t<Index, typename descriptor::args_type>>()...);
}
}
// NOLINTEND(cppcoreguidelines-pro-bounds-pointer-arithmetic)
@@ -355,7 +355,7 @@ template<typename Type, auto Data, meta_policy Policy = as_value_t>
*/
template<typename Type, meta_policy Policy = as_value_t, typename Candidate>
[[nodiscard]] meta_any meta_invoke(meta_handle instance, Candidate &&candidate, meta_any *const args) {
return internal::meta_invoke<Type, Policy>(*instance.operator->(), std::forward<Candidate>(candidate), args, std::make_index_sequence<meta_function_helper_t<Type, std::remove_reference_t<Candidate>>::args_type::size>{});
return internal::meta_invoke<Type, Policy>(*instance.operator->(), stl::forward<Candidate>(candidate), args, std::make_index_sequence<meta_function_helper_t<Type, std::remove_reference_t<Candidate>>::args_type::size>{});
}
/**
@@ -421,10 +421,10 @@ template<typename Type, typename Policy = as_value_t, typename Candidate>
[[nodiscard]] meta_any meta_construct(const meta_ctx &ctx, Candidate &&candidate, meta_any *const args) {
if constexpr(meta_function_helper_t<Type, Candidate>::is_static || std::is_class_v<stl::remove_cvref_t<Candidate>>) {
meta_any placeholder{meta_ctx_arg, ctx};
return internal::meta_invoke<Type, Policy>(placeholder, std::forward<Candidate>(candidate), args, std::make_index_sequence<meta_function_helper_t<Type, std::remove_reference_t<Candidate>>::args_type::size>{});
return internal::meta_invoke<Type, Policy>(placeholder, stl::forward<Candidate>(candidate), args, std::make_index_sequence<meta_function_helper_t<Type, std::remove_reference_t<Candidate>>::args_type::size>{});
} else {
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) - waiting for C++20 (and std::span)
return internal::meta_invoke<Type, Policy>(*args, std::forward<Candidate>(candidate), args + 1u, std::make_index_sequence<meta_function_helper_t<Type, std::remove_reference_t<Candidate>>::args_type::size>{});
return internal::meta_invoke<Type, Policy>(*args, stl::forward<Candidate>(candidate), args + 1u, std::make_index_sequence<meta_function_helper_t<Type, std::remove_reference_t<Candidate>>::args_type::size>{});
}
}
@@ -439,7 +439,7 @@ template<typename Type, typename Policy = as_value_t, typename Candidate>
*/
template<typename Type, meta_policy Policy = as_value_t, typename Candidate>
[[nodiscard]] meta_any meta_construct(Candidate &&candidate, meta_any *const args) {
return meta_construct<Type, Policy>(locator<meta_ctx>::value_or(), std::forward<Candidate>(candidate), args);
return meta_construct<Type, Policy>(locator<meta_ctx>::value_or(), stl::forward<Candidate>(candidate), args);
}
/**
+10 -10
View File
@@ -85,11 +85,11 @@ class poly_vtable {
static void fill_vtable_entry(Ret (*&entry)(Any &, Args...)) noexcept {
if constexpr(stl::is_invocable_r_v<Ret, decltype(Candidate), Args...>) {
entry = +[](Any &, Args... args) -> Ret {
return std::invoke(Candidate, std::forward<Args>(args)...);
return std::invoke(Candidate, stl::forward<Args>(args)...);
};
} else {
entry = +[](Any &instance, Args... args) -> Ret {
return static_cast<Ret>(std::invoke(Candidate, any_cast<constness_as_t<Type, Any> &>(instance), std::forward<Args>(args)...));
return static_cast<Ret>(std::invoke(Candidate, any_cast<constness_as_t<Type, Any> &>(instance), stl::forward<Args>(args)...));
};
}
}
@@ -144,9 +144,9 @@ struct poly_base {
const auto &poly = static_cast<const Poly &>(self);
if constexpr(std::is_function_v<std::remove_pointer_t<decltype(poly.vtable)>>) {
return poly.vtable(poly.storage, std::forward<Args>(args)...);
return poly.vtable(poly.storage, stl::forward<Args>(args)...);
} else {
return std::get<Member>(*poly.vtable)(poly.storage, std::forward<Args>(args)...);
return std::get<Member>(*poly.vtable)(poly.storage, stl::forward<Args>(args)...);
}
}
@@ -157,9 +157,9 @@ struct poly_base {
if constexpr(std::is_function_v<std::remove_pointer_t<decltype(poly.vtable)>>) {
static_assert(Member == 0u, "Unknown member");
return poly.vtable(poly.storage, std::forward<Args>(args)...);
return poly.vtable(poly.storage, stl::forward<Args>(args)...);
} else {
return std::get<Member>(*poly.vtable)(poly.storage, std::forward<Args>(args)...);
return std::get<Member>(*poly.vtable)(poly.storage, stl::forward<Args>(args)...);
}
}
};
@@ -175,7 +175,7 @@ struct poly_base {
*/
template<std::size_t Member, typename Poly, typename... Args>
decltype(auto) poly_call(Poly &&self, Args &&...args) {
return std::forward<Poly>(self).template invoke<Member>(self, std::forward<Args>(args)...);
return stl::forward<Poly>(self).template invoke<Member>(self, stl::forward<Args>(args)...);
}
/**
@@ -214,7 +214,7 @@ public:
*/
template<typename Type, typename... Args>
explicit basic_poly(std::in_place_type_t<Type>, Args &&...args)
: storage{std::in_place_type<Type>, std::forward<Args>(args)...},
: storage{std::in_place_type<Type>, stl::forward<Args>(args)...},
vtable{poly_vtable<Concept, Len, Align>::template instance<stl::remove_cvref_t<Type>>()} {}
/**
@@ -225,7 +225,7 @@ public:
template<typename Type>
requires (!std::same_as<stl::remove_cvref_t<Type>, basic_poly>)
basic_poly(Type &&value) noexcept
: basic_poly{std::in_place_type<stl::remove_cvref_t<Type>>, std::forward<Type>(value)} {}
: basic_poly{std::in_place_type<stl::remove_cvref_t<Type>>, stl::forward<Type>(value)} {}
/**
* @brief Returns the object type info if any, `type_id<void>()` otherwise.
@@ -256,7 +256,7 @@ public:
*/
template<typename Type, typename... Args>
void emplace(Args &&...args) {
storage.template emplace<Type>(std::forward<Args>(args)...);
storage.template emplace<Type>(stl::forward<Args>(args)...);
vtable = poly_vtable<Concept, Len, Align>::template instance<stl::remove_cvref_t<Type>>();
}
+1 -1
View File
@@ -221,7 +221,7 @@ public:
template<typename Type, typename... Args>
basic_process &then(Args &&...args) {
const auto &allocator = next.second();
return *(next.first() = std::allocate_shared<Type>(allocator, allocator, std::forward<Args>(args)...));
return *(next.first() = std::allocate_shared<Type>(allocator, allocator, stl::forward<Args>(args)...));
}
/**
+1 -1
View File
@@ -153,7 +153,7 @@ public:
template<typename Type, typename... Args>
type &attach(Args &&...args) {
const auto &allocator = handlers.second();
return *handlers.first().emplace_back(std::allocate_shared<Type>(allocator, allocator, std::forward<Args>(args)...));
return *handlers.first().emplace_back(std::allocate_shared<Type>(allocator, allocator, stl::forward<Args>(args)...));
}
/**
+2 -2
View File
@@ -292,7 +292,7 @@ public:
return {it, false};
}
return pool.first().emplace(id, pool.second()(std::forward<Args>(args)...));
return pool.first().emplace(id, pool.second()(stl::forward<Args>(args)...));
}
/**
@@ -301,7 +301,7 @@ public:
*/
template<typename... Args>
std::pair<iterator, bool> force_load(const id_type id, Args &&...args) {
return {pool.first().insert_or_assign(id, pool.second()(std::forward<Args>(args)...)).first, true};
return {pool.first().insert_or_assign(id, pool.second()(stl::forward<Args>(args)...)).first, true};
}
/**
+1 -1
View File
@@ -24,7 +24,7 @@ struct resource_loader {
*/
template<typename... Args>
result_type operator()(Args &&...args) const {
return std::make_shared<Type>(std::forward<Args>(args)...);
return std::make_shared<Type>(stl::forward<Args>(args)...);
}
};
+11 -11
View File
@@ -71,9 +71,9 @@ class delegate<Ret(Args...)> {
template<auto Candidate, std::size_t... Index>
[[nodiscard]] auto wrap(std::index_sequence<Index...>) noexcept {
return [](const void *, Args... args) -> return_type {
[[maybe_unused]] const auto arguments = stl::forward_as_tuple(std::forward<Args>(args)...);
[[maybe_unused]] const auto arguments = stl::forward_as_tuple(stl::forward<Args>(args)...);
[[maybe_unused]] constexpr auto offset = !stl::is_invocable_r_v<Ret, decltype(Candidate), type_list_element_t<Index, type_list<Args...>>...> * (sizeof...(Args) - sizeof...(Index));
return static_cast<Ret>(std::invoke(Candidate, std::forward<type_list_element_t<Index + offset, type_list<Args...>>>(std::get<Index + offset>(arguments))...));
return static_cast<Ret>(std::invoke(Candidate, stl::forward<type_list_element_t<Index + offset, type_list<Args...>>>(std::get<Index + offset>(arguments))...));
};
}
@@ -81,9 +81,9 @@ class delegate<Ret(Args...)> {
[[nodiscard]] auto wrap(Type &, std::index_sequence<Index...>) noexcept {
return [](const void *payload, Args... args) -> return_type {
Type *curr = static_cast<Type *>(const_cast<constness_as_t<void, Type> *>(payload));
[[maybe_unused]] const auto arguments = stl::forward_as_tuple(std::forward<Args>(args)...);
[[maybe_unused]] const auto arguments = stl::forward_as_tuple(stl::forward<Args>(args)...);
[[maybe_unused]] constexpr auto offset = !stl::is_invocable_r_v<Ret, decltype(Candidate), Type &, type_list_element_t<Index, type_list<Args...>>...> * (sizeof...(Args) - sizeof...(Index));
return static_cast<Ret>(std::invoke(Candidate, *curr, std::forward<type_list_element_t<Index + offset, type_list<Args...>>>(std::get<Index + offset>(arguments))...));
return static_cast<Ret>(std::invoke(Candidate, *curr, stl::forward<type_list_element_t<Index + offset, type_list<Args...>>>(std::get<Index + offset>(arguments))...));
};
}
@@ -91,9 +91,9 @@ class delegate<Ret(Args...)> {
[[nodiscard]] auto wrap(Type *, std::index_sequence<Index...>) noexcept {
return [](const void *payload, Args... args) -> return_type {
Type *curr = static_cast<Type *>(const_cast<constness_as_t<void, Type> *>(payload));
[[maybe_unused]] const auto arguments = stl::forward_as_tuple(std::forward<Args>(args)...);
[[maybe_unused]] const auto arguments = stl::forward_as_tuple(stl::forward<Args>(args)...);
[[maybe_unused]] constexpr auto offset = !stl::is_invocable_r_v<Ret, decltype(Candidate), Type *, type_list_element_t<Index, type_list<Args...>>...> * (sizeof...(Args) - sizeof...(Index));
return static_cast<Ret>(std::invoke(Candidate, curr, std::forward<type_list_element_t<Index + offset, type_list<Args...>>>(std::get<Index + offset>(arguments))...));
return static_cast<Ret>(std::invoke(Candidate, curr, stl::forward<type_list_element_t<Index + offset, type_list<Args...>>>(std::get<Index + offset>(arguments))...));
};
}
@@ -116,7 +116,7 @@ public:
*/
template<auto Candidate, typename... Type>
delegate(connect_arg_t<Candidate>, Type &&...value_or_instance) noexcept {
connect<Candidate>(std::forward<Type>(value_or_instance)...);
connect<Candidate>(stl::forward<Type>(value_or_instance)...);
}
/**
@@ -139,7 +139,7 @@ public:
if constexpr(stl::is_invocable_r_v<Ret, decltype(Candidate), Args...>) {
fn = [](const void *, Args... args) -> return_type {
return Ret(std::invoke(Candidate, std::forward<Args>(args)...));
return Ret(std::invoke(Candidate, stl::forward<Args>(args)...));
};
} else if constexpr(std::is_member_pointer_v<decltype(Candidate)>) {
fn = wrap<Candidate>(internal::index_sequence_for<type_list_element_t<0, type_list<Args...>>>(internal::function_pointer_t<decltype(Candidate)>{}));
@@ -170,7 +170,7 @@ public:
if constexpr(stl::is_invocable_r_v<Ret, decltype(Candidate), Type &, Args...>) {
fn = [](const void *payload, Args... args) -> return_type {
Type *curr = static_cast<Type *>(const_cast<constness_as_t<void, Type> *>(payload));
return Ret(std::invoke(Candidate, *curr, std::forward<Args>(args)...));
return Ret(std::invoke(Candidate, *curr, stl::forward<Args>(args)...));
};
} else {
fn = wrap<Candidate>(value_or_instance, internal::index_sequence_for(internal::function_pointer_t<decltype(Candidate), Type>{}));
@@ -194,7 +194,7 @@ public:
if constexpr(stl::is_invocable_r_v<Ret, decltype(Candidate), Type *, Args...>) {
fn = [](const void *payload, Args... args) -> return_type {
Type *curr = static_cast<Type *>(const_cast<constness_as_t<void, Type> *>(payload));
return Ret(std::invoke(Candidate, curr, std::forward<Args>(args)...));
return Ret(std::invoke(Candidate, curr, stl::forward<Args>(args)...));
};
} else {
fn = wrap<Candidate>(value_or_instance, internal::index_sequence_for(internal::function_pointer_t<decltype(Candidate), Type>{}));
@@ -260,7 +260,7 @@ public:
*/
Ret operator()(Args... args) const {
ENTT_ASSERT(static_cast<bool>(*this), "Uninitialized delegate");
return fn(instance, std::forward<Args>(args)...);
return fn(instance, stl::forward<Args>(args)...);
}
/**
+6 -6
View File
@@ -70,9 +70,9 @@ public:
template<typename... Args>
void enqueue(Args &&...args) {
if constexpr(std::is_aggregate_v<Type> && (sizeof...(Args) != 0u || !std::is_default_constructible_v<Type>)) {
events.push_back(Type{std::forward<Args>(args)...});
events.push_back(Type{stl::forward<Args>(args)...});
} else {
events.emplace_back(std::forward<Args>(args)...);
events.emplace_back(stl::forward<Args>(args)...);
}
}
@@ -289,7 +289,7 @@ public:
*/
template<typename Type, typename... Args>
void enqueue(Args &&...args) {
enqueue_hint<Type>(type_hash<Type>::value(), std::forward<Args>(args)...);
enqueue_hint<Type>(type_hash<Type>::value(), stl::forward<Args>(args)...);
}
/**
@@ -299,7 +299,7 @@ public:
*/
template<typename Type>
void enqueue(Type &&value) {
enqueue_hint(type_hash<std::decay_t<Type>>::value(), std::forward<Type>(value));
enqueue_hint(type_hash<std::decay_t<Type>>::value(), stl::forward<Type>(value));
}
/**
@@ -311,7 +311,7 @@ public:
*/
template<typename Type, typename... Args>
void enqueue_hint(const id_type id, Args &&...args) {
assure<Type>(id).enqueue(std::forward<Args>(args)...);
assure<Type>(id).enqueue(stl::forward<Args>(args)...);
}
/**
@@ -322,7 +322,7 @@ public:
*/
template<typename Type>
void enqueue_hint(const id_type id, Type &&value) {
assure<std::decay_t<Type>>(id).enqueue(std::forward<Type>(value));
assure<std::decay_t<Type>>(id).enqueue(stl::forward<Type>(value));
}
/**
+1
View File
@@ -8,6 +8,7 @@ namespace entt::stl {
using std::declval;
using std::exchange;
using std::forward;
} // namespace entt::stl
/*! @endcond */