sparse_set/storage: no virtual swap (the silliest thing I've ever done)

This commit is contained in:
Michele Caini
2021-11-19 11:22:27 +01:00
parent cd6c60fd46
commit ad3fbe2052
2 changed files with 11 additions and 15 deletions

View File

@@ -195,9 +195,6 @@ class basic_sparse_set {
}
protected:
/*! @brief Exchanges the contents with those of a given sparse set. */
virtual void swap_contents(basic_sparse_set &) {}
/*! @brief Swaps two entities in a sparse set. */
virtual void swap_at(const std::size_t, const std::size_t) {}
@@ -355,7 +352,6 @@ public:
*/
void swap(basic_sparse_set &other) {
using std::swap;
swap_contents(other);
swap(sparse, other.sparse);
swap(packed, other.packed);
swap(free_list, other.free_list);

View File

@@ -283,17 +283,6 @@ class basic_storage: public basic_sparse_set<Entity, typename std::allocator_tra
}
protected:
/**
* @brief Exchanges the contents with those of a given storage.
* @param base Reference to base storage to exchange the content with.
*/
void swap_contents(underlying_type &base) override {
using std::swap;
auto &other = static_cast<basic_storage &>(base);
propagate_on_container_swap(packed.second(), other.packed.second());
swap(packed.first(), other.packed.first());
}
/**
* @brief Swaps two elements in a storage.
* @param lhs A valid position of an element within a storage.
@@ -451,6 +440,17 @@ public:
return *this;
}
/**
* @brief Exchanges the contents with those of a given storage.
* @param other Storage to exchange the content with.
*/
void swap(basic_storage &other) {
using std::swap;
underlying_type::swap(other);
propagate_on_container_swap(packed.second(), other.packed.second());
swap(packed.first(), other.packed.first());
}
/**
* @brief Returns the associated allocator.
* @return The associated allocator.