Compare commits

...

6 Commits

Author SHA1 Message Date
Michele Caini
2909e7ab1f update single include file 2024-02-02 10:09:52 +01:00
Ezekiel Warren
60703f6845 build: don't install include/BUILD.bazel (#1107) 2024-01-22 09:55:58 +01:00
Michele Caini
062c95fc11 test: avoid warnings due to unused variables 2024-01-19 14:35:45 +01:00
Michele Caini
15ce55bc60 group: avoid swapping observed types - close #1100 2024-01-19 14:23:02 +01:00
Michele Caini
2d3fa3e51a snapshot: refine the check in the constructor of the loader class - close #1106 2024-01-19 09:22:58 +01:00
Michele Caini
7f49768739 now working on version v3.13.1 2024-01-19 08:52:00 +01:00
7 changed files with 111 additions and 90 deletions

View File

@@ -282,7 +282,13 @@ install(
DESTINATION ${CMAKE_INSTALL_LIBDIR}/EnTT/cmake
)
install(DIRECTORY src/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(
DIRECTORY src/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.hpp"
)
export(PACKAGE EnTT)

View File

@@ -19,7 +19,7 @@
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -127,7 +127,7 @@
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -169,7 +169,7 @@
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -296,7 +296,7 @@
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -5248,7 +5248,7 @@ struct radix_sort {
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -10297,7 +10297,7 @@ private:
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -10419,7 +10419,7 @@ private:
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -18188,27 +18188,28 @@ class group_handler<owned_t<Owned...>, get_t<Get...>, exclude_t<Exclude...>> fin
using base_type = std::common_type_t<typename Owned::base_type..., typename Get::base_type..., typename Exclude::base_type...>;
using entity_type = typename base_type::entity_type;
void swap_elements(const std::size_t pos, const entity_type entt) {
std::apply([pos, entt](auto *...cpool) { (cpool->swap_elements(cpool->data()[pos], entt), ...); }, pools);
template<std::size_t... Index>
void swap_elements(const std::size_t pos, const entity_type entt, std::index_sequence<Index...>) {
(std::get<Index>(pools)->swap_elements(std::get<Index>(pools)->data()[pos], entt), ...);
}
void push_on_construct(const entity_type entt) {
if(std::apply([entt, len = len](auto *cpool, auto *...other) { return cpool->contains(entt) && !(cpool->index(entt) < len) && (other->contains(entt) && ...); }, pools)
&& std::apply([entt](auto *...cpool) { return (!cpool->contains(entt) && ...); }, filter)) {
swap_elements(len++, entt);
swap_elements(len++, entt, std::index_sequence_for<Owned...>{});
}
}
void push_on_destroy(const entity_type entt) {
if(std::apply([entt, len = len](auto *cpool, auto *...other) { return cpool->contains(entt) && !(cpool->index(entt) < len) && (other->contains(entt) && ...); }, pools)
&& std::apply([entt](auto *...cpool) { return (0u + ... + cpool->contains(entt)) == 1u; }, filter)) {
swap_elements(len++, entt);
swap_elements(len++, entt, std::index_sequence_for<Owned...>{});
}
}
void remove_if(const entity_type entt) {
if(std::get<0>(pools)->contains(entt) && (std::get<0>(pools)->index(entt) < len)) {
swap_elements(--len, entt);
swap_elements(--len, entt, std::index_sequence_for<Owned...>{});
}
}
@@ -18242,13 +18243,11 @@ public:
return len;
}
template<typename Type>
Type pools_as() const noexcept {
auto pools_as_tuple() const noexcept {
return pools;
}
template<typename Type>
Type filter_as() const noexcept {
auto filter_as_tuple() const noexcept {
return filter;
}
@@ -18310,13 +18309,11 @@ public:
return elem;
}
template<typename Type>
Type pools_as() const noexcept {
auto pools_as_tuple() const noexcept {
return pools;
}
template<typename Type>
Type filter_as() const noexcept {
auto filter_as_tuple() const noexcept {
return filter;
}
@@ -18370,12 +18367,12 @@ class basic_group<owned_t<>, get_t<Get...>, exclude_t<Exclude...>> {
auto pools() const noexcept {
using return_type = std::tuple<Get *...>;
return descriptor ? descriptor->template pools_as<return_type>() : return_type{};
return descriptor ? descriptor->pools_as_tuple() : return_type{};
}
auto filter() const noexcept {
using return_type = std::tuple<Exclude *...>;
return descriptor ? descriptor->template filter_as<return_type>() : return_type{};
return descriptor ? descriptor->filter_as_tuple() : return_type{};
}
public:
@@ -18791,12 +18788,12 @@ class basic_group<owned_t<Owned...>, get_t<Get...>, exclude_t<Exclude...>> {
auto pools() const noexcept {
using return_type = std::tuple<Owned *..., Get *...>;
return descriptor ? descriptor->template pools_as<return_type>() : return_type{};
return descriptor ? descriptor->pools_as_tuple() : return_type{};
}
auto filter() const noexcept {
using return_type = std::tuple<Exclude *...>;
return descriptor ? descriptor->template filter_as<return_type>() : return_type{};
return descriptor ? descriptor->filter_as_tuple() : return_type{};
}
public:
@@ -19569,7 +19566,7 @@ template<typename... Args, typename... Other>
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -19688,7 +19685,7 @@ template<typename... Args, typename... Other>
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -21214,27 +21211,28 @@ class group_handler<owned_t<Owned...>, get_t<Get...>, exclude_t<Exclude...>> fin
using base_type = std::common_type_t<typename Owned::base_type..., typename Get::base_type..., typename Exclude::base_type...>;
using entity_type = typename base_type::entity_type;
void swap_elements(const std::size_t pos, const entity_type entt) {
std::apply([pos, entt](auto *...cpool) { (cpool->swap_elements(cpool->data()[pos], entt), ...); }, pools);
template<std::size_t... Index>
void swap_elements(const std::size_t pos, const entity_type entt, std::index_sequence<Index...>) {
(std::get<Index>(pools)->swap_elements(std::get<Index>(pools)->data()[pos], entt), ...);
}
void push_on_construct(const entity_type entt) {
if(std::apply([entt, len = len](auto *cpool, auto *...other) { return cpool->contains(entt) && !(cpool->index(entt) < len) && (other->contains(entt) && ...); }, pools)
&& std::apply([entt](auto *...cpool) { return (!cpool->contains(entt) && ...); }, filter)) {
swap_elements(len++, entt);
swap_elements(len++, entt, std::index_sequence_for<Owned...>{});
}
}
void push_on_destroy(const entity_type entt) {
if(std::apply([entt, len = len](auto *cpool, auto *...other) { return cpool->contains(entt) && !(cpool->index(entt) < len) && (other->contains(entt) && ...); }, pools)
&& std::apply([entt](auto *...cpool) { return (0u + ... + cpool->contains(entt)) == 1u; }, filter)) {
swap_elements(len++, entt);
swap_elements(len++, entt, std::index_sequence_for<Owned...>{});
}
}
void remove_if(const entity_type entt) {
if(std::get<0>(pools)->contains(entt) && (std::get<0>(pools)->index(entt) < len)) {
swap_elements(--len, entt);
swap_elements(--len, entt, std::index_sequence_for<Owned...>{});
}
}
@@ -21268,13 +21266,11 @@ public:
return len;
}
template<typename Type>
Type pools_as() const noexcept {
auto pools_as_tuple() const noexcept {
return pools;
}
template<typename Type>
Type filter_as() const noexcept {
auto filter_as_tuple() const noexcept {
return filter;
}
@@ -21336,13 +21332,11 @@ public:
return elem;
}
template<typename Type>
Type pools_as() const noexcept {
auto pools_as_tuple() const noexcept {
return pools;
}
template<typename Type>
Type filter_as() const noexcept {
auto filter_as_tuple() const noexcept {
return filter;
}
@@ -21396,12 +21390,12 @@ class basic_group<owned_t<>, get_t<Get...>, exclude_t<Exclude...>> {
auto pools() const noexcept {
using return_type = std::tuple<Get *...>;
return descriptor ? descriptor->template pools_as<return_type>() : return_type{};
return descriptor ? descriptor->pools_as_tuple() : return_type{};
}
auto filter() const noexcept {
using return_type = std::tuple<Exclude *...>;
return descriptor ? descriptor->template filter_as<return_type>() : return_type{};
return descriptor ? descriptor->filter_as_tuple() : return_type{};
}
public:
@@ -21817,12 +21811,12 @@ class basic_group<owned_t<Owned...>, get_t<Get...>, exclude_t<Exclude...>> {
auto pools() const noexcept {
using return_type = std::tuple<Owned *..., Get *...>;
return descriptor ? descriptor->template pools_as<return_type>() : return_type{};
return descriptor ? descriptor->pools_as_tuple() : return_type{};
}
auto filter() const noexcept {
using return_type = std::tuple<Exclude *...>;
return descriptor ? descriptor->template filter_as<return_type>() : return_type{};
return descriptor ? descriptor->filter_as_tuple() : return_type{};
}
public:
@@ -25126,7 +25120,7 @@ private:
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -25446,7 +25440,7 @@ private:
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -25952,7 +25946,7 @@ private:
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -26079,7 +26073,7 @@ private:
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -33480,7 +33474,7 @@ private:
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -33607,7 +33601,7 @@ private:
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -39350,7 +39344,7 @@ public:
basic_snapshot_loader(registry_type &source) noexcept
: reg{&source} {
// restoring a snapshot as a whole requires a clean registry
ENTT_ASSERT(reg->template storage<entity_type>().empty() && (reg->storage().begin() == reg->storage().end()), "Registry must be empty");
ENTT_ASSERT(reg->template storage<entity_type>().free_list() == 0u, "Registry must be empty");
}
/*! @brief Default move constructor. */
@@ -42964,7 +42958,7 @@ basic_view(std::tuple<Get &...>, std::tuple<Exclude &...> = {}) -> basic_view<ge
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -43284,7 +43278,7 @@ private:
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -43851,7 +43845,7 @@ void dot(std::ostream &out, const Graph &graph) {
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -43978,7 +43972,7 @@ void dot(std::ostream &out, const Graph &graph) {
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -50681,7 +50675,7 @@ private:
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -50998,7 +50992,7 @@ struct adl_meta_pointer_like {
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -51125,7 +51119,7 @@ struct adl_meta_pointer_like {
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -55838,7 +55832,7 @@ private:
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -56122,7 +56116,7 @@ class meta_ctx: private internal::meta_context {
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -59830,7 +59824,7 @@ struct std::tuple_element<Index, entt::value_list<Value...>>: entt::value_list_e
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -67805,7 +67799,7 @@ using invoke_result_t = typename std::invoke_result<Func, Args...>::type;
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -71981,7 +71975,7 @@ struct process_adaptor: process<process_adaptor<Func, Delta>, Delta>, private Fu
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -72108,7 +72102,7 @@ struct process_adaptor: process<process_adaptor<Func, Delta>, Delta>, private Fu
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -74120,7 +74114,7 @@ private:
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -74247,7 +74241,7 @@ private:
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -78034,7 +78028,7 @@ struct uses_allocator<entt::internal::dense_map_node<Key, Value>, Allocator>
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -80659,7 +80653,7 @@ template<typename Lhs, typename Rhs>
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -80778,7 +80772,7 @@ template<typename Lhs, typename Rhs>
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -82225,7 +82219,7 @@ delegate(Ret (*)(const void *, Args...), const void * = nullptr) -> delegate<Ret
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \
@@ -82352,7 +82346,7 @@ delegate(Ret (*)(const void *, Args...), const void * = nullptr) -> delegate<Ret
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \

View File

@@ -5,7 +5,7 @@
#define ENTT_VERSION_MAJOR 3
#define ENTT_VERSION_MINOR 13
#define ENTT_VERSION_PATCH 0
#define ENTT_VERSION_PATCH 1
#define ENTT_VERSION \
ENTT_XSTR(ENTT_VERSION_MAJOR) \

View File

@@ -109,27 +109,28 @@ class group_handler<owned_t<Owned...>, get_t<Get...>, exclude_t<Exclude...>> fin
using base_type = std::common_type_t<typename Owned::base_type..., typename Get::base_type..., typename Exclude::base_type...>;
using entity_type = typename base_type::entity_type;
void swap_elements(const std::size_t pos, const entity_type entt) {
std::apply([pos, entt](auto *...cpool) { (cpool->swap_elements(cpool->data()[pos], entt), ...); }, pools);
template<std::size_t... Index>
void swap_elements(const std::size_t pos, const entity_type entt, std::index_sequence<Index...>) {
(std::get<Index>(pools)->swap_elements(std::get<Index>(pools)->data()[pos], entt), ...);
}
void push_on_construct(const entity_type entt) {
if(std::apply([entt, len = len](auto *cpool, auto *...other) { return cpool->contains(entt) && !(cpool->index(entt) < len) && (other->contains(entt) && ...); }, pools)
&& std::apply([entt](auto *...cpool) { return (!cpool->contains(entt) && ...); }, filter)) {
swap_elements(len++, entt);
swap_elements(len++, entt, std::index_sequence_for<Owned...>{});
}
}
void push_on_destroy(const entity_type entt) {
if(std::apply([entt, len = len](auto *cpool, auto *...other) { return cpool->contains(entt) && !(cpool->index(entt) < len) && (other->contains(entt) && ...); }, pools)
&& std::apply([entt](auto *...cpool) { return (0u + ... + cpool->contains(entt)) == 1u; }, filter)) {
swap_elements(len++, entt);
swap_elements(len++, entt, std::index_sequence_for<Owned...>{});
}
}
void remove_if(const entity_type entt) {
if(std::get<0>(pools)->contains(entt) && (std::get<0>(pools)->index(entt) < len)) {
swap_elements(--len, entt);
swap_elements(--len, entt, std::index_sequence_for<Owned...>{});
}
}
@@ -163,13 +164,11 @@ public:
return len;
}
template<typename Type>
Type pools_as() const noexcept {
auto pools_as_tuple() const noexcept {
return pools;
}
template<typename Type>
Type filter_as() const noexcept {
auto filter_as_tuple() const noexcept {
return filter;
}
@@ -231,13 +230,11 @@ public:
return elem;
}
template<typename Type>
Type pools_as() const noexcept {
auto pools_as_tuple() const noexcept {
return pools;
}
template<typename Type>
Type filter_as() const noexcept {
auto filter_as_tuple() const noexcept {
return filter;
}
@@ -291,12 +288,12 @@ class basic_group<owned_t<>, get_t<Get...>, exclude_t<Exclude...>> {
auto pools() const noexcept {
using return_type = std::tuple<Get *...>;
return descriptor ? descriptor->template pools_as<return_type>() : return_type{};
return descriptor ? descriptor->pools_as_tuple() : return_type{};
}
auto filter() const noexcept {
using return_type = std::tuple<Exclude *...>;
return descriptor ? descriptor->template filter_as<return_type>() : return_type{};
return descriptor ? descriptor->filter_as_tuple() : return_type{};
}
public:
@@ -712,12 +709,12 @@ class basic_group<owned_t<Owned...>, get_t<Get...>, exclude_t<Exclude...>> {
auto pools() const noexcept {
using return_type = std::tuple<Owned *..., Get *...>;
return descriptor ? descriptor->template pools_as<return_type>() : return_type{};
return descriptor ? descriptor->pools_as_tuple() : return_type{};
}
auto filter() const noexcept {
using return_type = std::tuple<Exclude *...>;
return descriptor ? descriptor->template filter_as<return_type>() : return_type{};
return descriptor ? descriptor->filter_as_tuple() : return_type{};
}
public:

View File

@@ -164,7 +164,7 @@ public:
basic_snapshot_loader(registry_type &source) noexcept
: reg{&source} {
// restoring a snapshot as a whole requires a clean registry
ENTT_ASSERT(reg->template storage<entity_type>().empty() && (reg->storage().begin() == reg->storage().end()), "Registry must be empty");
ENTT_ASSERT(reg->template storage<entity_type>().free_list() == 0u, "Registry must be empty");
}
/*! @brief Default move constructor. */

View File

@@ -1503,6 +1503,25 @@ TEST(OwningGroup, PreventEarlyOptOut) {
});
}
TEST(OwningGroup, SwapElements) {
entt::registry registry;
std::array entity{registry.create(), registry.create(), registry.create()};
registry.emplace<int>(entity[1u]);
registry.emplace<int>(entity[0u]);
registry.emplace<char>(entity[2u]);
registry.emplace<char>(entity[0u]);
ASSERT_EQ(registry.storage<int>().index(entity[0u]), 1u);
ASSERT_EQ(registry.storage<char>().index(entity[0u]), 1u);
registry.group<int>(entt::get<char>);
ASSERT_EQ(registry.storage<int>().index(entity[0u]), 0u);
ASSERT_EQ(registry.storage<char>().index(entity[0u]), 1u);
}
TEST(OwningGroup, SwappingValuesIsAllowed) {
entt::registry registry;
const auto group = registry.group<test::boxed_int>(entt::get<test::empty>);

View File

@@ -222,6 +222,11 @@ TEST(BasicSnapshotLoader, Constructors) {
static_assert(std::is_move_assignable_v<entt::basic_snapshot_loader<entt::registry>>, "Move assignable type required");
entt::registry registry;
// helps stress the check in the constructor
registry.emplace<int>(registry.create(), 0);
registry.clear();
entt::basic_snapshot_loader loader{registry};
entt::basic_snapshot_loader other{std::move(loader)};