stl: vector

This commit is contained in:
skypjack
2026-03-30 18:57:01 +02:00
parent 008dd6987c
commit c7556f9245
18 changed files with 67 additions and 49 deletions
+3 -3
View File
@@ -13,7 +13,6 @@
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>
#include "../config/config.h"
#include "../core/bit.hpp"
#include "../core/compressed_pair.hpp"
@@ -21,6 +20,7 @@
#include "../core/memory.hpp"
#include "../core/type_traits.hpp"
#include "../stl/iterator.hpp"
#include "../stl/vector.hpp"
#include "fwd.hpp"
namespace entt {
@@ -237,8 +237,8 @@ class dense_map {
using node_type = internal::dense_map_node<Key, Type>;
using alloc_traits = std::allocator_traits<Allocator>;
static_assert(std::is_same_v<typename alloc_traits::value_type, std::pair<const Key, Type>>, "Invalid value type");
using sparse_container_type = std::vector<std::size_t, typename alloc_traits::template rebind_alloc<std::size_t>>;
using packed_container_type = std::vector<node_type, typename alloc_traits::template rebind_alloc<node_type>>;
using sparse_container_type = stl::vector<std::size_t, typename alloc_traits::template rebind_alloc<std::size_t>>;
using packed_container_type = stl::vector<node_type, typename alloc_traits::template rebind_alloc<node_type>>;
[[nodiscard]] std::size_t key_to_bucket(const auto &key) const noexcept {
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
+3 -3
View File
@@ -13,12 +13,12 @@
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>
#include "../config/config.h"
#include "../core/bit.hpp"
#include "../core/compressed_pair.hpp"
#include "../core/type_traits.hpp"
#include "../stl/iterator.hpp"
#include "../stl/vector.hpp"
#include "fwd.hpp"
namespace entt {
@@ -201,8 +201,8 @@ class dense_set {
using node_type = std::pair<std::size_t, Type>;
using alloc_traits = std::allocator_traits<Allocator>;
static_assert(std::is_same_v<typename alloc_traits::value_type, Type>, "Invalid value type");
using sparse_container_type = std::vector<std::size_t, typename alloc_traits::template rebind_alloc<std::size_t>>;
using packed_container_type = std::vector<node_type, typename alloc_traits::template rebind_alloc<node_type>>;
using sparse_container_type = stl::vector<std::size_t, typename alloc_traits::template rebind_alloc<std::size_t>>;
using packed_container_type = stl::vector<node_type, typename alloc_traits::template rebind_alloc<node_type>>;
[[nodiscard]] std::size_t value_to_bucket(const auto &value) const noexcept {
return fast_mod(static_cast<size_type>(sparse.second()(value)), bucket_count());
+2 -2
View File
@@ -4,7 +4,7 @@
#include <functional>
#include <memory>
#include <utility>
#include <vector>
#include "../stl/vector.hpp"
namespace entt {
@@ -31,7 +31,7 @@ class basic_table;
* @tparam Type Element types.
*/
template<typename... Type>
using table = basic_table<std::vector<Type>...>;
using table = basic_table<stl::vector<Type>...>;
} // namespace entt
+2 -2
View File
@@ -6,9 +6,9 @@
#include <functional>
#include <iterator>
#include <utility>
#include <vector>
#include "../stl/functional.hpp"
#include "../stl/iterator.hpp"
#include "../stl/vector.hpp"
namespace entt {
@@ -100,7 +100,7 @@ struct radix_sort {
using value_type = std::iterator_traits<It>::value_type;
using difference_type = std::iterator_traits<It>::difference_type;
std::vector<value_type> aux(static_cast<std::size_t>(std::distance(first, last)));
stl::vector<value_type> aux(static_cast<std::size_t>(std::distance(first, last)));
auto part = [getter = std::move(getter)](auto from, auto to, auto out, auto start) {
constexpr auto mask = (1 << Bit) - 1;
+2 -1
View File
@@ -9,6 +9,7 @@
#include "../core/type_info.hpp"
#include "../signal/sigh.hpp"
#include "../stl/iterator.hpp"
#include "../stl/vector.hpp"
#include "entity.hpp"
#include "fwd.hpp"
@@ -394,7 +395,7 @@ class basic_reactive_mixin final: public Type {
using alloc_traits = std::allocator_traits<typename underlying_type::allocator_type>;
using basic_registry_type = basic_registry<typename owner_type::entity_type, typename owner_type::allocator_type>;
using container_type = std::vector<connection, typename alloc_traits::template rebind_alloc<connection>>;
using container_type = stl::vector<connection, typename alloc_traits::template rebind_alloc<connection>>;
static_assert(std::is_base_of_v<basic_registry_type, owner_type>, "Invalid registry type");
+11 -11
View File
@@ -4,12 +4,12 @@
#include <cstddef>
#include <type_traits>
#include <utility>
#include <vector>
#include "../core/type_info.hpp"
#include "../core/type_traits.hpp"
#include "../core/utility.hpp"
#include "../graph/adjacency_matrix.hpp"
#include "../graph/flow.hpp"
#include "../stl/vector.hpp"
#include "fwd.hpp"
#include "helper.hpp"
@@ -195,7 +195,7 @@ public:
* @param from List of in-edges of the vertex.
* @param to List of out-edges of the vertex.
*/
vertex(vertex_data data, std::vector<std::size_t> from, std::vector<std::size_t> to)
vertex(vertex_data data, stl::vector<std::size_t> from, stl::vector<std::size_t> to)
: node{std::move(data)},
in{std::move(from)},
out{std::move(to)} {}
@@ -282,7 +282,7 @@ public:
* @brief Returns the list of in-edges of a vertex.
* @return The list of in-edges of a vertex.
*/
[[nodiscard]] const std::vector<std::size_t> &in_edges() const noexcept {
[[nodiscard]] const stl::vector<std::size_t> &in_edges() const noexcept {
return in;
}
@@ -290,7 +290,7 @@ public:
* @brief Returns the list of out-edges of a vertex.
* @return The list of out-edges of a vertex.
*/
[[nodiscard]] const std::vector<std::size_t> &out_edges() const noexcept {
[[nodiscard]] const stl::vector<std::size_t> &out_edges() const noexcept {
return out;
}
@@ -305,8 +305,8 @@ public:
private:
vertex_data node;
std::vector<std::size_t> in;
std::vector<std::size_t> out;
stl::vector<std::size_t> in;
stl::vector<std::size_t> out;
};
/**
@@ -399,13 +399,13 @@ public:
* @brief Generates a task graph for the current content.
* @return The adjacency list of the task graph.
*/
[[nodiscard]] std::vector<vertex> graph() const {
std::vector<vertex> adjacency_list{};
[[nodiscard]] stl::vector<vertex> graph() const {
stl::vector<vertex> adjacency_list{};
adjacency_list.reserve(vertices.size());
for(auto adjacency_matrix = builder.graph(); auto curr: adjacency_matrix.vertices()) {
std::vector<std::size_t> in{};
std::vector<std::size_t> out{};
stl::vector<std::size_t> in{};
stl::vector<std::size_t> out{};
for(auto &&edge: adjacency_matrix.in_edges(curr)) {
in.push_back(edge.first);
@@ -428,7 +428,7 @@ public:
}
private:
std::vector<vertex_data> vertices;
stl::vector<vertex_data> vertices;
flow builder;
};
+5 -5
View File
@@ -5,7 +5,7 @@
#include <cstddef>
#include <iterator>
#include <utility>
#include <vector>
#include "../stl/vector.hpp"
#include "entity.hpp"
#include "fwd.hpp"
@@ -38,7 +38,7 @@ public:
it{},
tombstone_check{} {}
runtime_view_iterator(const std::vector<Set *> &cpools, iterator_type curr, const std::vector<Set *> &ignore) noexcept
runtime_view_iterator(const stl::vector<Set *> &cpools, iterator_type curr, const stl::vector<Set *> &ignore) noexcept
: pools{&cpools},
filter{&ignore},
it{curr},
@@ -83,8 +83,8 @@ public:
}
private:
const std::vector<Set *> *pools;
const std::vector<Set *> *filter;
const stl::vector<Set *> *pools;
const stl::vector<Set *> *filter;
iterator_type it;
bool tombstone_check;
};
@@ -119,7 +119,7 @@ template<typename Type, typename Allocator>
class basic_runtime_view {
using alloc_traits = std::allocator_traits<Allocator>;
static_assert(std::is_same_v<typename alloc_traits::value_type, Type *>, "Invalid value type");
using container_type = std::vector<Type *, Allocator>;
using container_type = stl::vector<Type *, Allocator>;
[[nodiscard]] auto offset() const noexcept {
ENTT_ASSERT(!pools.empty(), "Invalid view");
+3 -3
View File
@@ -8,13 +8,13 @@
#include <memory>
#include <type_traits>
#include <utility>
#include <vector>
#include "../config/config.h"
#include "../core/algorithm.hpp"
#include "../core/any.hpp"
#include "../core/bit.hpp"
#include "../core/type_info.hpp"
#include "../stl/iterator.hpp"
#include "../stl/vector.hpp"
#include "entity.hpp"
#include "fwd.hpp"
@@ -140,8 +140,8 @@ template<typename Entity, typename Allocator>
class basic_sparse_set {
using alloc_traits = std::allocator_traits<Allocator>;
static_assert(std::is_same_v<typename alloc_traits::value_type, Entity>, "Invalid value type");
using sparse_container_type = std::vector<typename alloc_traits::pointer, typename alloc_traits::template rebind_alloc<typename alloc_traits::pointer>>;
using packed_container_type = std::vector<Entity, Allocator>;
using sparse_container_type = stl::vector<typename alloc_traits::pointer, typename alloc_traits::template rebind_alloc<typename alloc_traits::pointer>>;
using packed_container_type = stl::vector<Entity, Allocator>;
using traits_type = entt_traits<Entity>;
static constexpr auto max_size = static_cast<std::size_t>(traits_type::to_entity(null));
+2 -2
View File
@@ -9,7 +9,6 @@
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>
#include "../config/config.h"
#include "../core/bit.hpp"
#include "../core/iterator.hpp"
@@ -17,6 +16,7 @@
#include "../core/type_info.hpp"
#include "../stl/iterator.hpp"
#include "../stl/memory.hpp"
#include "../stl/vector.hpp"
#include "component.hpp"
#include "entity.hpp"
#include "fwd.hpp"
@@ -210,7 +210,7 @@ template<typename Type, typename Entity, typename Allocator>
class basic_storage: public basic_sparse_set<Entity, typename std::allocator_traits<Allocator>::template rebind_alloc<Entity>> {
using alloc_traits = std::allocator_traits<Allocator>;
static_assert(std::is_same_v<typename alloc_traits::value_type, Type>, "Invalid value type");
using container_type = std::vector<typename alloc_traits::pointer, typename alloc_traits::template rebind_alloc<typename alloc_traits::pointer>>;
using container_type = stl::vector<typename alloc_traits::pointer, typename alloc_traits::template rebind_alloc<typename alloc_traits::pointer>>;
using underlying_type = basic_sparse_set<Entity, typename alloc_traits::template rebind_alloc<Entity>>;
using underlying_iterator = underlying_type::basic_iterator;
using traits_type = component_traits<Type, Entity>;
+1
View File
@@ -69,4 +69,5 @@ namespace entt {}
#include "stl/functional.hpp"
#include "stl/iterator.hpp"
#include "stl/memory.hpp"
#include "stl/vector.hpp"
// IWYU pragma: end_exports
+2 -2
View File
@@ -7,9 +7,9 @@
#include <memory>
#include <type_traits>
#include <utility>
#include <vector>
#include "../config/config.h"
#include "../core/iterator.hpp"
#include "../stl/vector.hpp"
#include "fwd.hpp"
namespace entt {
@@ -88,7 +88,7 @@ template<std::derived_from<directed_tag> Category, typename Allocator>
class adjacency_matrix {
using alloc_traits = std::allocator_traits<Allocator>;
static_assert(std::is_same_v<typename alloc_traits::value_type, std::size_t>, "Invalid value type");
using container_type = std::vector<std::size_t, typename alloc_traits::template rebind_alloc<std::size_t>>;
using container_type = stl::vector<std::size_t, typename alloc_traits::template rebind_alloc<std::size_t>>;
public:
/*! @brief Allocator type. */
+2 -2
View File
@@ -9,7 +9,6 @@
#include <memory>
#include <type_traits>
#include <utility>
#include <vector>
#include "../config/config.h"
#include "../container/dense_map.hpp"
#include "../container/dense_set.hpp"
@@ -18,6 +17,7 @@
#include "../core/iterator.hpp"
#include "../stl/functional.hpp"
#include "../stl/iterator.hpp"
#include "../stl/vector.hpp"
#include "adjacency_matrix.hpp"
#include "fwd.hpp"
@@ -32,7 +32,7 @@ class basic_flow {
using alloc_traits = std::allocator_traits<Allocator>;
static_assert(std::is_same_v<typename alloc_traits::value_type, id_type>, "Invalid value type");
using task_container_type = dense_set<id_type, stl::identity, std::equal_to<>, typename alloc_traits::template rebind_alloc<id_type>>;
using ro_rw_container_type = std::vector<std::pair<std::size_t, bool>, typename alloc_traits::template rebind_alloc<std::pair<std::size_t, bool>>>;
using ro_rw_container_type = stl::vector<std::pair<std::size_t, bool>, typename alloc_traits::template rebind_alloc<std::pair<std::size_t, bool>>>;
using deps_container_type = dense_map<id_type, ro_rw_container_type, stl::identity, std::equal_to<>, typename alloc_traits::template rebind_alloc<std::pair<const id_type, ro_rw_container_type>>>;
using adjacency_matrix_type = adjacency_matrix<directed_tag, typename alloc_traits::template rebind_alloc<std::size_t>>;
+1 -1
View File
@@ -1822,7 +1822,7 @@ inline bool meta_sequence_container::reserve(const size_type sz) {
* @return A possibly invalid iterator to the inserted element.
*/
inline meta_sequence_container::iterator meta_sequence_container::insert(const iterator &it, meta_any value) {
// this abomination is necessary because only on macos value_type and const_reference are different types for std::vector<bool>
// this abomination is necessary because only on macos value_type and const_reference are different types for stl::vector<bool>
if(const auto &vtype = value_type_node(internal::meta_context::from(*ctx)); !const_only && (value.allow_cast({*ctx, vtype}) || value.allow_cast({*ctx, const_reference_node(internal::meta_context::from(*ctx))}))) {
const bool is_value_type = (value.type().info() == *vtype.info);
return insert_fn(*ctx, const_cast<void *>(data), is_value_type ? value.base().data() : nullptr, is_value_type ? nullptr : value.base().data(), it);
+6 -6
View File
@@ -7,7 +7,6 @@
#include <memory>
#include <type_traits>
#include <utility>
#include <vector>
#include "../config/config.h"
#include "../core/bit.hpp"
#include "../core/concepts.hpp"
@@ -16,6 +15,7 @@
#include "../core/type_info.hpp"
#include "../core/type_traits.hpp"
#include "../core/utility.hpp"
#include "../stl/vector.hpp"
#include "context.hpp"
#include "fwd.hpp"
#include "type_traits.hpp"
@@ -123,11 +123,11 @@ struct meta_template_node {
};
struct meta_type_descriptor {
std::vector<meta_ctor_node> ctor{};
std::vector<meta_base_node> base{};
std::vector<meta_conv_node> conv{};
std::vector<meta_data_node> data{};
std::vector<meta_func_node> func{};
stl::vector<meta_ctor_node> ctor{};
stl::vector<meta_base_node> base{};
stl::vector<meta_conv_node> conv{};
stl::vector<meta_data_node> data{};
stl::vector<meta_func_node> func{};
};
struct meta_type_node {
+2 -2
View File
@@ -5,9 +5,9 @@
#include <memory>
#include <type_traits>
#include <utility>
#include <vector>
#include "../config/config.h"
#include "../core/compressed_pair.hpp"
#include "../stl/vector.hpp"
#include "fwd.hpp"
#include "process.hpp"
@@ -37,7 +37,7 @@ class basic_scheduler {
using base_type = basic_process<Delta, Allocator>;
using alloc_traits = std::allocator_traits<Allocator>;
using container_allocator = alloc_traits::template rebind_alloc<std::shared_ptr<base_type>>;
using container_type = std::vector<std::shared_ptr<base_type>, container_allocator>;
using container_type = stl::vector<std::shared_ptr<base_type>, container_allocator>;
public:
/*! @brief Process type. */
+2 -2
View File
@@ -6,13 +6,13 @@
#include <memory>
#include <type_traits>
#include <utility>
#include <vector>
#include "../container/dense_map.hpp"
#include "../core/compressed_pair.hpp"
#include "../core/concepts.hpp"
#include "../core/fwd.hpp"
#include "../core/type_info.hpp"
#include "../stl/functional.hpp"
#include "../stl/vector.hpp"
#include "fwd.hpp"
#include "sigh.hpp"
@@ -33,7 +33,7 @@ template<cvref_unqualified Type, typename Allocator>
class dispatcher_handler final: public basic_dispatcher_handler {
using alloc_traits = std::allocator_traits<Allocator>;
using signal_type = sigh<void(Type &), Allocator>;
using container_type = std::vector<Type, typename alloc_traits::template rebind_alloc<Type>>;
using container_type = stl::vector<Type, typename alloc_traits::template rebind_alloc<Type>>;
public:
using allocator_type = Allocator;
+2 -2
View File
@@ -5,7 +5,7 @@
#include <memory>
#include <type_traits>
#include <utility>
#include <vector>
#include "../stl/vector.hpp"
#include "delegate.hpp"
#include "fwd.hpp"
@@ -56,7 +56,7 @@ class sigh<Ret(Args...), Allocator> {
using alloc_traits = std::allocator_traits<Allocator>;
using delegate_type = delegate<Ret(Args...)>;
using container_type = std::vector<delegate_type, typename alloc_traits::template rebind_alloc<delegate_type>>;
using container_type = stl::vector<delegate_type, typename alloc_traits::template rebind_alloc<delegate_type>>;
public:
/*! @brief Allocator type. */
+16
View File
@@ -0,0 +1,16 @@
#ifndef ENTT_STL_VECTOR_HPP
#define ENTT_STL_VECTOR_HPP
#include "../config/config.h"
#include <vector>
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::vector;
} // namespace entt::stl
/*! @endcond */
#endif