Compare commits

..

161 Commits
main ... wip

Author SHA1 Message Date
skypjack
5c6ed1a7c0 test: prepare stl_ext files with the right includes 2026-05-01 15:44:49 +02:00
skypjack
bd689292e9 test: setup stl_ext tests 2026-05-01 15:41:48 +02:00
skypjack
60ada2efb7 test: internal changes 2026-05-01 15:39:35 +02:00
skypjack
bcbd39db35 test: cleanup 2026-05-01 15:34:58 +02:00
skypjack
4bfd609f69 test: prepare for stl injection tests 2026-05-01 15:15:07 +02:00
skypjack
8e313cf099 updated TODO 2026-05-01 15:07:01 +02:00
skypjack
c37cc47dc8 compressed_pair: internal changes 2026-04-30 12:13:25 +02:00
skypjack
8c2cbe88e5 stl: fix the last things with guarded specializations that are std:: only 2026-04-30 12:11:16 +02:00
skypjack
2d69562088 stl: cleanup 2026-04-29 17:20:48 +02:00
skypjack
74947434d7 stl: cleanup 2026-04-29 13:33:16 +02:00
skypjack
5fa956395a stl: drop version.hpp - some things do not fit custom implementations, that's all 2026-04-29 13:25:51 +02:00
skypjack
c11e6be645 test: cleanup 2026-04-29 11:10:39 +02:00
skypjack
a931a83870 stl: drop ranges.hpp - some things do not fit custom implementations, that's all 2026-04-29 11:10:29 +02:00
skypjack
4c47abaca7 stl: cannot specialize variables across namespaces 2026-04-28 16:17:26 +02:00
skypjack
7d527e2633 stl: undef internal macros 2026-04-28 15:17:26 +02:00
skypjack
938be3d9c5 stl: get rid of ENTT_HAS_RANGES 2026-04-28 15:08:46 +02:00
skypjack
377dde3e24 stl: drop ENTT_HAS_VERSION 2026-04-28 15:04:37 +02:00
skypjack
a0c7b53e67 stl: std::hash 2026-04-27 08:26:17 +02:00
skypjack
165c6df6a2 stl: <ranges> & co. 2026-04-24 15:22:55 +02:00
skypjack
9055a66364 stl: std::swap 2026-04-24 15:22:37 +02:00
skypjack
625622c8ad flow: cleanup 2026-04-24 11:35:09 +02:00
skypjack
0a62b17fce stl: std::uses_allocator_v 2026-04-24 09:11:39 +02:00
skypjack
7a42ec61b3 stl: std::stringstream 2026-04-24 09:09:12 +02:00
skypjack
682184ba08 stl: std::boolalpha 2026-04-24 09:08:28 +02:00
skypjack
dda9428140 stl: <ios> 2026-04-24 09:07:23 +02:00
skypjack
e9bbcb6cea stl: <sstream> 2026-04-24 09:05:12 +02:00
skypjack
0c3db25cf4 stl: std::ostream 2026-04-22 10:16:35 +02:00
skypjack
04b9bcc563 stl: added <ostream> 2026-04-21 17:25:52 +02:00
skypjack
18f8a103a8 stl: std::pointer_traits 2026-04-21 15:04:53 +02:00
skypjack
576baa5c57 std: stl::destroy 2026-04-21 14:59:49 +02:00
skypjack
514521888c stl: std::default_delete 2026-04-21 14:58:45 +02:00
skypjack
f0a306aa6f stl: std::integral 2026-04-21 08:18:27 +02:00
skypjack
749411c1a9 stl: std::enable_shared_from_this 2026-04-21 08:17:04 +02:00
skypjack
de04de17b9 stl: std::less 2026-04-21 08:15:17 +02:00
skypjack
4104c7db7b doc: minor changes 2026-04-20 18:40:44 +02:00
skypjack
490bf05f3e stl: stl::nullptr_t 2026-04-20 18:40:33 +02:00
skypjack
c0c5b81993 stl: std::uninitialized_fill 2026-04-20 18:35:58 +02:00
skypjack
18477eb65b stl: std::advance 2026-04-20 18:33:30 +02:00
skypjack
8a1940c0fa stl: std::allocate_shared 2026-04-20 18:31:05 +02:00
skypjack
ea6b70f263 stl: std::invoke 2026-04-20 16:46:50 +02:00
skypjack
780da3c78b stl: std::find_if 2026-04-20 16:44:19 +02:00
skypjack
882cbd2251 stl: std::any_of 2026-04-20 16:42:27 +02:00
skypjack
2975d14352 stl: std::all_of 2026-04-20 15:45:24 +02:00
skypjack
b88c1903a0 stl: std::none_of 2026-04-20 15:44:47 +02:00
skypjack
f7bf2d1245 stl: std::byte 2026-04-20 15:43:22 +02:00
skypjack
200f35130f stl: std::ceil 2026-04-20 15:42:17 +02:00
skypjack
793d4a9738 stl: std::popcount 2026-04-17 11:29:10 +02:00
skypjack
adff45e6a3 stl: std::default_initializable 2026-04-17 11:27:11 +02:00
skypjack
7d5b8c9a0e stl: std::has_single_bit 2026-04-17 11:24:00 +02:00
skypjack
0a1b4f9adc stl: std::unsigned_integral 2026-04-17 10:14:45 +02:00
skypjack
c6b343ae7d stl: std::invocable 2026-04-17 10:11:26 +02:00
skypjack
b451c43058 stl: std::make_shared 2026-04-17 09:15:13 +02:00
skypjack
750b450cd2 stl: std::derived_from 2026-04-17 09:13:18 +02:00
skypjack
080966ad8f doc: minor changes 2026-04-17 09:12:27 +02:00
skypjack
b5cd97f915 stl: std::constructible_from 2026-04-17 09:11:48 +02:00
skypjack
398a8c70a5 stl: std::same_as 2026-04-17 09:10:46 +02:00
skypjack
0ebf92f015 stl: concepts.hpp 2026-04-17 09:09:46 +02:00
skypjack
92a03e184d stl: std::static_pointer_cast 2026-04-16 15:40:18 +02:00
skypjack
be026136db stl: std::addressof 2026-04-16 15:38:50 +02:00
skypjack
1dff52db92 stl: std::is_member_function_pointer_v 2026-04-16 11:35:49 +02:00
skypjack
685d6c643f stl: std::allocator 2026-04-16 11:34:21 +02:00
skypjack
20c21bbfd6 stl: std::equal_to 2026-04-16 11:08:54 +02:00
skypjack
431556c069 stl: replace <functional> everywhere 2026-04-16 11:01:08 +02:00
skypjack
3b9304480a stl: refine functional.hpp + std::function 2026-04-16 10:58:25 +02:00
skypjack
fee356c7f9 stl: std::is_base_of_v 2026-04-15 14:30:57 +02:00
skypjack
d700f800aa stl: std::is_class_v 2026-04-15 14:28:46 +02:00
skypjack
e27826abc5 stl: std::is_signed_v 2026-04-15 14:27:53 +02:00
skypjack
2f7fc36e9e stl: std::is_integral_v 2026-04-15 14:27:22 +02:00
skypjack
d4cfc844a9 stl: std::is_arithmetic_v 2026-04-15 14:26:09 +02:00
skypjack
75f95b367c doc: minor changes 2026-04-15 14:23:42 +02:00
skypjack
64a71a4e8d stl: std::allocator_arg[_t] 2026-04-15 14:22:26 +02:00
skypjack
5623d2f9dc stl: std::allocator_traits 2026-04-15 14:20:49 +02:00
skypjack
a039eed54e stl: std::shared_ptr 2026-04-15 09:23:31 +02:00
skypjack
ddeea943f2 stl: std::unique_ptr 2026-04-15 09:21:56 +02:00
skypjack
6b7513eb1a stl: std::make_unique 2026-04-15 09:20:39 +02:00
skypjack
d200d8b3dc stl: prepare to move all <memory> stuff 2026-04-15 09:19:17 +02:00
skypjack
2b09786326 stl: version.hpp and ENTT_HAS_VERSION macro 2026-04-15 09:15:30 +02:00
skypjack
8ed97c2d98 stl: move only to memory.hpp 2026-04-14 14:12:05 +02:00
skypjack
04dda74792 stl: std::is_move_constructible_v 2026-04-14 14:07:41 +02:00
skypjack
71f3780ba7 stl: missed std::make_from_tuple 2026-04-14 14:06:38 +02:00
skypjack
3281239bed stl: std::get 2026-04-14 14:04:55 +02:00
skypjack
a5c0595896 stl: add string_view.hpp and replace std::string_view 2026-04-14 08:38:52 +02:00
skypjack
dfb94864db stl: add string.hpp and replace std::string 2026-04-14 08:35:42 +02:00
skypjack
879a7a301a stl: include cmath.hpp 2026-04-13 09:24:42 +02:00
skypjack
dcf5f8fdcc stl: std::bit_ceil 2026-04-13 09:09:36 +02:00
skypjack
43dcf712b7 stl: include bit.hpp 2026-04-13 09:08:27 +02:00
skypjack
94898f6083 stl: std::numeric_limits 2026-04-13 09:05:36 +02:00
skypjack
7674036b67 stl: include limits.hpp 2026-04-13 08:50:35 +02:00
skypjack
e2418206da stl: std::is_reference_v 2026-04-10 16:09:19 +02:00
skypjack
c2db759653 stl: std::is_member_pointer_v 2026-04-10 12:03:03 +02:00
skypjack
f16ff7071b stl: std::make_index_sequence 2026-04-10 12:02:21 +02:00
skypjack
402f040f16 stl: std::index_sequence 2026-04-10 12:00:30 +02:00
skypjack
9a5ad4235d updated TODO 2026-04-10 11:58:19 +02:00
skypjack
3bffa25af2 stl: std::ptrdiff_t 2026-04-10 11:13:01 +02:00
skypjack
80ad8de444 stl: std::index_sequence_for 2026-04-10 10:15:57 +02:00
skypjack
5f6b0c2fa1 stl: std::integral_constant 2026-04-10 10:13:51 +02:00
skypjack
e929304ed4 stl: std::uint8/16/32/64_t 2026-04-10 10:12:16 +02:00
skypjack
6b9f69d0e5 stl: std::size_t 2026-04-10 10:05:59 +02:00
skypjack
5cc2397069 stl: add cstdint.hpp 2026-04-09 10:28:05 +02:00
skypjack
0cd14686dd stl: add cstddef.hpp 2026-04-09 10:22:44 +02:00
skypjack
b75a7191f8 stl: std::std::is_final_v 2026-04-08 09:50:09 +02:00
skypjack
a75a608d0c stl: std::is_empty_v 2026-04-08 09:49:42 +02:00
skypjack
2690c8af2b stl: std::in_place* 2026-04-08 09:48:29 +02:00
skypjack
61a2aaa0c9 stl: std::is_enum_v 2026-04-08 09:45:30 +02:00
skypjack
5d823e6853 stl: std::piecewise_construct[_t] 2026-04-08 09:45:04 +02:00
skypjack
0c5ca42180 stl: std::sort 2026-04-08 09:42:46 +02:00
skypjack
213ddb74d5 stl: add algorithm.hpp 2026-04-07 18:15:49 +02:00
skypjack
0d3cecbff1 stl: std::conditional_t 2026-04-07 11:38:36 +02:00
skypjack
4d91f8cc5a stl: std::is_convertible_v 2026-04-07 11:35:04 +02:00
skypjack
d596ba854f stl: std::common_type_t 2026-04-07 11:33:42 +02:00
skypjack
03299cedad stl: std::is_constructible_v 2026-04-07 11:31:49 +02:00
skypjack
68e8b36684 stl: std::is_nothrow_* 2026-04-07 11:23:21 +02:00
skypjack
9bd285bfa8 stl: std::is_invocable* 2026-04-07 11:19:44 +02:00
skypjack
2d4324d7cb stl: std::is_nothrow_constructible_v 2026-04-07 09:13:29 +02:00
skypjack
61ecf3906d stl: std::extent_v 2026-04-07 09:11:54 +02:00
skypjack
9f0d0d9aeb stl: std::array 2026-04-02 17:29:23 +02:00
skypjack
a8fe00242a stl: array header 2026-04-02 17:27:53 +02:00
skypjack
486f02dcb0 enum: fixed stl scope 2026-04-02 10:10:31 +02:00
skypjack
c60e076f80 stl: std::underlying_type_t 2026-04-02 10:09:36 +02:00
skypjack
8f411924b4 stl: std::bool_constant 2026-04-02 10:07:58 +02:00
skypjack
15f4e28205 stl: std::is_array_v 2026-04-02 10:03:36 +02:00
skypjack
4ac884dfd1 stl: std::is_copy_constructible_v 2026-04-02 10:02:38 +02:00
skypjack
ed026bbc7e stl: std::is_function_v 2026-04-02 10:02:05 +02:00
skypjack
10bfb24bf1 stl: std::is_move_assignable_v 2026-04-02 10:00:44 +02:00
skypjack
50346a4cf8 stl: std::is_copy_assignable_v 2026-04-02 10:00:09 +02:00
skypjack
69331f4796 stl: std::is_const_v 2026-04-02 09:58:39 +02:00
skypjack
573d982c1c stl: std::is_default_constructible_v 2026-04-02 09:44:56 +02:00
skypjack
257117ce8f stl: std::is_aggregate_v 2026-04-02 09:44:20 +02:00
skypjack
c3a52a4f27 stl: std::decay_t 2026-04-02 09:44:11 +02:00
skypjack
35435d3d82 stl: std::is_nothrow_move_constructible_v 2026-04-02 09:41:22 +02:00
skypjack
7a672f6a1e stl: std::remove_const_t 2026-04-02 09:41:10 +02:00
skypjack
cf7199e83e stl: std::is_trivially_destructible_v 2026-04-02 09:38:52 +02:00
skypjack
272b93c8fb stl: std::remove_reference_t 2026-04-02 09:38:41 +02:00
skypjack
9efe86621d stl: std::is_lvalue_reference_v 2026-04-02 09:34:38 +02:00
skypjack
86e2235b83 stl: std::is_pointer_v 2026-04-02 09:34:29 +02:00
skypjack
98604629c7 stl: std::is_void_v 2026-04-02 09:32:12 +02:00
skypjack
990eff8e73 stl: std::true_type/std::false_type 2026-04-02 09:32:02 +02:00
skypjack
1763f8b192 stl: std::invoke_result_t 2026-04-01 16:57:12 +02:00
skypjack
06cd683d31 stl: std::remove_pointer_t 2026-04-01 16:57:00 +02:00
skypjack
bfe84b59d0 stl: std::pair/std::make_pair 2026-04-01 16:50:07 +02:00
skypjack
80fdab4f21 stl: std::as_const 2026-04-01 16:49:39 +02:00
skypjack
b32ec7f656 stl: std::move 2026-04-01 09:34:50 +02:00
skypjack
9aeffebc7b stl: std::forward 2026-04-01 09:34:28 +02:00
skypjack
4f1897e864 stl: std::declval 2026-04-01 09:31:13 +02:00
skypjack
8f67d4fa06 stl: std::exchange 2026-04-01 09:30:47 +02:00
skypjack
8c8949a312 stl: introduce utility.hpp 2026-04-01 09:29:27 +02:00
skypjack
17953cb28a stl: moved some type traits here and there 2026-04-01 09:27:17 +02:00
skypjack
6054e22df2 stl: introduce type_traits.hpp 2026-04-01 09:20:25 +02:00
skypjack
f2d89c93c9 stl: cleanup 2026-03-31 10:32:42 +02:00
skypjack
8f3f5b99c1 stl: iterator_traits 2026-03-31 10:32:22 +02:00
skypjack
8396a8c884 stl: std::reverse_iterator 2026-03-31 08:57:07 +02:00
skypjack
fc9eb2a9f2 stl: std::distance 2026-03-31 08:56:56 +02:00
skypjack
be840ee569 stl: iterator tags 2026-03-31 08:54:09 +02:00
skypjack
fc7ca524f2 stl: more on iterator 2026-03-31 08:52:27 +02:00
skypjack
a2a72bcce6 stl: atomic header 2026-03-31 08:20:12 +02:00
skypjack
e7be9a94e8 stl: minor changes 2026-03-30 20:00:51 +02:00
skypjack
3652d47932 stl: tuple header 2026-03-30 18:59:56 +02:00
skypjack
898b50a39c build: update ENTT_INCLUDE_HEADERS list 2026-03-30 18:58:32 +02:00
skypjack
68f1bb1872 entt: add doc for entt::stl 2026-03-30 18:57:43 +02:00
skypjack
c7556f9245 stl: vector 2026-03-30 18:57:01 +02:00
skypjack
008dd6987c cleanup headers 2026-03-27 17:12:04 +01:00
119 changed files with 2570 additions and 2063 deletions

View File

@@ -195,9 +195,27 @@ if(ENTT_INCLUDE_HEADERS)
signal/emitter.hpp
signal/fwd.hpp
signal/sigh.hpp
stl/algorithm.hpp
stl/array.hpp
stl/atomic.hpp
stl/bit.hpp
stl/cmath.hpp
stl/concepts.hpp
stl/cstddef.hpp
stl/cstdint.hpp
stl/functional.hpp
stl/ios.hpp
stl/iterator.hpp
stl/limits.hpp
stl/memory.hpp
stl/ostream.hpp
stl/sstream.hpp
stl/string.hpp
stl/string_view.hpp
stl/tuple.hpp
stl/type_traits.hpp
stl/utility.hpp
stl/vector.hpp
tools/davey.hpp
entt.hpp
fwd.hpp

5
TODO
View File

@@ -10,14 +10,12 @@ DOC:
* bump entities, reserved bits on identifiers
TODO:
* review all NOLINT
* bring nested groups back in place (see bd34e7f)
* work stealing job system (see #100) + mt scheduler based on const awareness for types
* combine version-mask-vs-version-bits tricks with reserved bits to allow things like enabling/disabling
* self contained entity traits to avoid explicit specializations (ie enum constants)
* auto type info data from types if present
* storage entity: fast range-push from above
* table: pop back to support swap and pop, single column access, empty type optimization
* suppress -Wself-move on CI with g++13
* runtime types support for meta for types that aren't backed by C++ types
* built-in no-pagination storage - no_pagination page size as limits::max
@@ -31,8 +29,9 @@ TODO:
* finish the imgui viewer/editor!
* archetype-like a-là EnTT support (see my own notes)
* organizer: view/storage only based model, no registry
* introduce a way to inject stl from outside too
* redesign snapshot as a whole
* explore "runtime" mode for hashed string where the source is copied internally
* storage: shrink_to_fit does not work with reentrant destructor?
* make meta_any buffer size configurable (propagate to any)
* test trivially_destructible optimization
* document stl and injections support

View File

@@ -5,6 +5,7 @@
# include <entt/ext/config.h>
#endif
#include <version>
#include "version.h"
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
@@ -23,30 +24,24 @@
# define ENTT_CATCH if(false)
#endif
#if __has_include(<version>)
# include <version>
#
# if defined(__cpp_consteval)
# define ENTT_CONSTEVAL consteval
# endif
#endif
#ifndef ENTT_CONSTEVAL
#if defined(__cpp_consteval)
# define ENTT_CONSTEVAL consteval
#else
# define ENTT_CONSTEVAL constexpr
#endif
#ifdef ENTT_USE_ATOMIC
# include <atomic>
# define ENTT_MAYBE_ATOMIC(Type) std::atomic<Type>
# include "../stl/atomic.hpp"
# define ENTT_MAYBE_ATOMIC(Type) stl::atomic<Type>
#else
# define ENTT_MAYBE_ATOMIC(Type) Type
#endif
#ifndef ENTT_ID_TYPE
# include <cstdint>
# define ENTT_ID_TYPE std::uint32_t
# include "../stl/cstdint.hpp"
# define ENTT_ID_TYPE stl::uint32_t
#else
# include <cstdint> // provides coverage for types in the std namespace
# include "../stl/cstdint.hpp" // provides coverage for types in the std namespace
#endif
#ifndef ENTT_SPARSE_PAGE

View File

@@ -1,26 +1,25 @@
#ifndef ENTT_CONTAINER_DENSE_MAP_HPP
#define ENTT_CONTAINER_DENSE_MAP_HPP
#include <bit>
#include <cmath>
#include <compare>
#include <concepts>
#include <cstddef>
#include <functional>
#include <iterator>
#include <limits>
#include <memory>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>
#include "../config/config.h"
#include "../core/bit.hpp"
#include "../core/compressed_pair.hpp"
#include "../core/iterator.hpp"
#include "../core/memory.hpp"
#include "../core/type_traits.hpp"
#include "../stl/bit.hpp"
#include "../stl/cmath.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/functional.hpp"
#include "../stl/iterator.hpp"
#include "../stl/limits.hpp"
#include "../stl/memory.hpp"
#include "../stl/tuple.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "../stl/vector.hpp"
#include "fwd.hpp"
namespace entt {
@@ -28,31 +27,31 @@ namespace entt {
/*! @cond ENTT_INTERNAL */
namespace internal {
static constexpr std::size_t dense_map_placeholder_position = (std::numeric_limits<std::size_t>::max)();
static constexpr stl::size_t dense_map_placeholder_position = (stl::numeric_limits<stl::size_t>::max)();
template<typename Key, typename Type>
struct dense_map_node final {
using value_type = std::pair<Key, Type>;
using value_type = stl::pair<Key, Type>;
template<typename... Args>
dense_map_node(const std::size_t pos, Args &&...args)
dense_map_node(const stl::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)
dense_map_node(stl::allocator_arg_t, const auto &allocator, const stl::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)
dense_map_node(stl::allocator_arg_t, const auto &allocator, const dense_map_node &other)
: next{other.next},
element{entt::make_obj_using_allocator<value_type>(allocator, other.element)} {}
dense_map_node(std::allocator_arg_t, const auto &allocator, dense_map_node &&other)
dense_map_node(stl::allocator_arg_t, const auto &allocator, dense_map_node &&other)
: next{other.next},
element{entt::make_obj_using_allocator<value_type>(allocator, std::move(other.element))} {}
element{entt::make_obj_using_allocator<value_type>(allocator, stl::move(other.element))} {}
std::size_t next;
stl::size_t next;
value_type element;
};
@@ -61,17 +60,17 @@ class dense_map_iterator final {
template<typename>
friend class dense_map_iterator;
static_assert(std::is_pointer_v<It>, "Not a pointer type");
using first_type = decltype(std::as_const(std::declval<It>()->element.first));
using second_type = decltype((std::declval<It>()->element.second));
static_assert(stl::is_pointer_v<It>, "Not a pointer type");
using first_type = decltype(stl::as_const(stl::declval<It>()->element.first));
using second_type = decltype((stl::declval<It>()->element.second));
public:
using value_type = std::pair<first_type, second_type>;
using value_type = stl::pair<first_type, second_type>;
using pointer = input_iterator_pointer<value_type>;
using reference = value_type;
using difference_type = std::ptrdiff_t;
using iterator_category = std::input_iterator_tag;
using iterator_concept = std::random_access_iterator_tag;
using difference_type = stl::ptrdiff_t;
using iterator_category = stl::input_iterator_tag;
using iterator_concept = stl::random_access_iterator_tag;
constexpr dense_map_iterator() noexcept
: it{} {}
@@ -80,7 +79,7 @@ public:
: it{iter} {}
template<typename Other>
requires (!std::same_as<It, Other> && std::constructible_from<It, Other>)
requires (!stl::same_as<It, Other> && stl::constructible_from<It, Other>)
constexpr dense_map_iterator(const dense_map_iterator<Other> &other) noexcept
: it{other.it} {}
@@ -133,7 +132,7 @@ public:
}
template<typename Other>
[[nodiscard]] constexpr std::ptrdiff_t operator-(const dense_map_iterator<Other> &other) const noexcept {
[[nodiscard]] constexpr stl::ptrdiff_t operator-(const dense_map_iterator<Other> &other) const noexcept {
return it - other.it;
}
@@ -156,26 +155,26 @@ class dense_map_local_iterator final {
template<typename>
friend class dense_map_local_iterator;
static_assert(std::is_pointer_v<It>, "Not a pointer type");
using first_type = decltype(std::as_const(std::declval<It>()->element.first));
using second_type = decltype((std::declval<It>()->element.second));
static_assert(stl::is_pointer_v<It>, "Not a pointer type");
using first_type = decltype(stl::as_const(stl::declval<It>()->element.first));
using second_type = decltype((stl::declval<It>()->element.second));
public:
using value_type = std::pair<first_type, second_type>;
using value_type = stl::pair<first_type, second_type>;
using pointer = input_iterator_pointer<value_type>;
using reference = value_type;
using difference_type = std::ptrdiff_t;
using iterator_category = std::input_iterator_tag;
using iterator_concept = std::forward_iterator_tag;
using difference_type = stl::ptrdiff_t;
using iterator_category = stl::input_iterator_tag;
using iterator_concept = stl::forward_iterator_tag;
constexpr dense_map_local_iterator() noexcept = default;
constexpr dense_map_local_iterator(It iter, const std::size_t pos) noexcept
constexpr dense_map_local_iterator(It iter, const stl::size_t pos) noexcept
: it{iter},
offset{pos} {}
template<typename Other>
requires (!std::same_as<It, Other> && std::constructible_from<It, Other>)
requires (!stl::same_as<It, Other> && stl::constructible_from<It, Other>)
constexpr dense_map_local_iterator(const dense_map_local_iterator<Other> &other) noexcept
: it{other.it},
offset{other.offset} {}
@@ -203,13 +202,13 @@ public:
return offset == other.offset;
}
[[nodiscard]] constexpr std::size_t index() const noexcept {
[[nodiscard]] constexpr stl::size_t index() const noexcept {
return offset;
}
private:
It it{};
std::size_t offset{dense_map_placeholder_position};
stl::size_t offset{dense_map_placeholder_position};
};
} // namespace internal
@@ -231,21 +230,21 @@ private:
template<typename Key, typename Type, typename Hash, typename KeyEqual, typename Allocator>
class dense_map {
static constexpr float default_threshold = 0.875f;
static constexpr std::size_t minimum_capacity = 8u;
static constexpr std::size_t placeholder_position = internal::dense_map_placeholder_position;
static constexpr stl::size_t minimum_capacity = 8u;
static constexpr stl::size_t placeholder_position = internal::dense_map_placeholder_position;
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 alloc_traits = stl::allocator_traits<Allocator>;
static_assert(stl::is_same_v<typename alloc_traits::value_type, stl::pair<const Key, Type>>, "Invalid value type");
using sparse_container_type = stl::vector<stl::size_t, typename alloc_traits::template rebind_alloc<stl::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 {
[[nodiscard]] stl::size_t key_to_bucket(const auto &key) const noexcept {
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
return fast_mod(static_cast<size_type>(sparse.second()(key)), bucket_count());
}
[[nodiscard]] auto constrained_find(const auto &key, const std::size_t bucket) {
[[nodiscard]] auto constrained_find(const auto &key, const stl::size_t bucket) {
for(auto offset = sparse.first()[bucket]; offset != placeholder_position; offset = packed.first()[offset].next) {
if(packed.second()(packed.first()[offset].element.first, key)) {
return begin() + static_cast<iterator::difference_type>(offset);
@@ -255,7 +254,7 @@ class dense_map {
return end();
}
[[nodiscard]] auto constrained_find(const auto &key, const std::size_t bucket) const {
[[nodiscard]] auto constrained_find(const auto &key, const stl::size_t bucket) const {
for(auto offset = sparse.first()[bucket]; offset != placeholder_position; offset = packed.first()[offset].next) {
if(packed.second()(packed.first()[offset].element.first, key)) {
return cbegin() + static_cast<const_iterator::difference_type>(offset);
@@ -270,14 +269,14 @@ class dense_map {
const auto index = key_to_bucket(key);
if(auto it = constrained_find(key, index); it != end()) {
return std::make_pair(it, false);
return stl::make_pair(it, false);
}
packed.first().emplace_back(sparse.first()[index], std::piecewise_construct, std::forward_as_tuple(std::forward<Other>(key)), std::forward_as_tuple(std::forward<Args>(args)...));
packed.first().emplace_back(sparse.first()[index], stl::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();
return std::make_pair(--end(), true);
return stl::make_pair(--end(), true);
}
template<typename Other, typename Arg>
@@ -285,21 +284,21 @@ 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);
return std::make_pair(it, false);
it->second = stl::forward<Arg>(value);
return stl::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();
return std::make_pair(--end(), true);
return stl::make_pair(--end(), true);
}
void move_and_pop(const std::size_t pos) {
void move_and_pop(const stl::size_t pos) {
if(const auto last = size() - 1u; pos != last) {
size_type *curr = &sparse.first()[key_to_bucket(packed.first().back().element.first)];
packed.first()[pos] = std::move(packed.first().back());
packed.first()[pos] = stl::move(packed.first().back());
for(; *curr != last; curr = &packed.first()[*curr].next) {}
*curr = pos;
}
@@ -321,11 +320,11 @@ public:
/*! @brief Mapped type of the container. */
using mapped_type = Type;
/*! @brief Key-value type of the container. */
using value_type = std::pair<const Key, Type>;
using value_type = stl::pair<const Key, Type>;
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Signed integer type. */
using difference_type = std::ptrdiff_t;
using difference_type = stl::ptrdiff_t;
/*! @brief Type of function to use to hash the keys. */
using hasher = Hash;
/*! @brief Type of function to use to compare the keys for equality. */
@@ -392,8 +391,8 @@ public:
* @param allocator The allocator to use.
*/
dense_map(const dense_map &other, const allocator_type &allocator)
: sparse{std::piecewise_construct, std::forward_as_tuple(other.sparse.first(), allocator), std::forward_as_tuple(other.sparse.second())},
packed{std::piecewise_construct, std::forward_as_tuple(other.packed.first(), allocator), std::forward_as_tuple(other.packed.second())},
: sparse{stl::piecewise_construct, stl::forward_as_tuple(other.sparse.first(), allocator), stl::forward_as_tuple(other.sparse.second())},
packed{stl::piecewise_construct, stl::forward_as_tuple(other.packed.first(), allocator), stl::forward_as_tuple(other.packed.second())},
threshold{other.threshold} {}
/*! @brief Default move constructor. */
@@ -405,8 +404,8 @@ public:
* @param allocator The allocator to use.
*/
dense_map(dense_map &&other, const allocator_type &allocator)
: sparse{std::piecewise_construct, std::forward_as_tuple(std::move(other.sparse.first()), allocator), std::forward_as_tuple(std::move(other.sparse.second()))},
packed{std::piecewise_construct, std::forward_as_tuple(std::move(other.packed.first()), allocator), std::forward_as_tuple(std::move(other.packed.second()))},
: sparse{stl::piecewise_construct, stl::forward_as_tuple(stl::move(other.sparse.first()), allocator), stl::forward_as_tuple(stl::move(other.sparse.second()))},
packed{stl::piecewise_construct, stl::forward_as_tuple(stl::move(other.packed.first()), allocator), stl::forward_as_tuple(stl::move(other.packed.second()))},
threshold{other.threshold} {}
/*! @brief Default destructor. */
@@ -429,7 +428,7 @@ public:
* @param other Container to exchange the content with.
*/
void swap(dense_map &other) noexcept {
using std::swap;
using stl::swap;
swap(sparse, other.sparse);
swap(packed, other.packed);
swap(threshold, other.threshold);
@@ -521,13 +520,13 @@ public:
* the element that prevented the insertion) and a bool denoting whether the
* insertion took place.
*/
std::pair<iterator, bool> insert(const value_type &value) {
stl::pair<iterator, bool> insert(const value_type &value) {
return insert_or_do_nothing(value.first, value.second);
}
/*! @copydoc insert */
std::pair<iterator, bool> insert(value_type &&value) {
return insert_or_do_nothing(std::move(value.first), std::move(value.second));
stl::pair<iterator, bool> insert(value_type &&value) {
return insert_or_do_nothing(stl::move(value.first), stl::move(value.second));
}
/**
@@ -535,9 +534,9 @@ public:
* @tparam Arg Type of the key-value pair to insert into the container.
*/
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);
requires stl::constructible_from<value_type, Arg &&>
stl::pair<iterator, bool> insert(Arg &&value) {
return insert_or_do_nothing(stl::forward<Arg>(value).first, stl::forward<Arg>(value).second);
}
/**
@@ -561,14 +560,14 @@ public:
* denoting whether the insertion took place.
*/
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));
stl::pair<iterator, bool> insert_or_assign(const key_type &key, 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));
stl::pair<iterator, bool> insert_or_assign(key_type &&key, Arg &&value) {
return insert_or_overwrite(stl::move(key), stl::forward<Arg>(value));
}
/**
@@ -585,26 +584,26 @@ public:
* insertion took place.
*/
template<typename... Args>
std::pair<iterator, bool> emplace([[maybe_unused]] Args &&...args) {
stl::pair<iterator, bool> emplace([[maybe_unused]] Args &&...args) {
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()) {
packed.first().pop_back();
return std::make_pair(it, false);
return stl::make_pair(it, false);
}
std::swap(node.next, sparse.first()[index]);
stl::swap(node.next, sparse.first()[index]);
rehash_if_required();
return std::make_pair(--end(), true);
return stl::make_pair(--end(), true);
}
}
@@ -620,14 +619,14 @@ public:
* insertion took place.
*/
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)...);
stl::pair<iterator, bool> try_emplace(const key_type &key, 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)...);
stl::pair<iterator, bool> try_emplace(key_type &&key, Args &&...args) {
return insert_or_do_nothing(stl::move(key), stl::forward<Args>(args)...);
}
/**
@@ -728,7 +727,7 @@ public:
* @return A reference to the mapped value of the requested element.
*/
[[nodiscard]] mapped_type &operator[](key_type &&key) {
return insert_or_do_nothing(std::move(key)).first->second;
return insert_or_do_nothing(stl::move(key)).first->second;
}
/**
@@ -789,13 +788,13 @@ public:
* @return A pair of iterators pointing to the first element and past the
* last element of the range.
*/
[[nodiscard]] std::pair<iterator, iterator> equal_range(const key_type &key) {
[[nodiscard]] stl::pair<iterator, iterator> equal_range(const key_type &key) {
const auto it = find(key);
return {it, it + !(it == end())};
}
/*! @copydoc equal_range */
[[nodiscard]] std::pair<const_iterator, const_iterator> equal_range(const key_type &key) const {
[[nodiscard]] stl::pair<const_iterator, const_iterator> equal_range(const key_type &key) const {
const auto it = find(key);
return {it, it + !(it == cend())};
}
@@ -807,14 +806,14 @@ public:
* @return A pair of iterators pointing to the first element and past the
* last element of the range.
*/
[[nodiscard]] std::pair<iterator, iterator> equal_range(const auto &key)
[[nodiscard]] stl::pair<iterator, iterator> equal_range(const auto &key)
requires is_transparent_v<hasher> && is_transparent_v<key_equal> {
const auto it = find(key);
return {it, it + !(it == end())};
}
/*! @copydoc equal_range */
[[nodiscard]] std::pair<const_iterator, const_iterator> equal_range(const auto &key) const
[[nodiscard]] stl::pair<const_iterator, const_iterator> equal_range(const auto &key) const
requires is_transparent_v<hasher> && is_transparent_v<key_equal> {
const auto it = find(key);
return {it, it + !(it == cend())};
@@ -916,7 +915,7 @@ public:
* @return The number of elements in the given bucket.
*/
[[nodiscard]] size_type bucket_size(const size_type index) const {
return static_cast<size_type>(std::distance(begin(index), end(index)));
return static_cast<size_type>(stl::distance(begin(index), end(index)));
}
/**
@@ -964,7 +963,7 @@ public:
const auto cap = static_cast<size_type>(static_cast<float>(size()) / max_load_factor());
value = value > cap ? value : cap;
if(const auto sz = std::bit_ceil(value); sz != bucket_count()) {
if(const auto sz = stl::bit_ceil(value); sz != bucket_count()) {
sparse.first().resize(sz);
for(auto &&elem: sparse.first()) {
@@ -973,7 +972,7 @@ public:
for(size_type pos{}, last = size(); pos < last; ++pos) {
const auto index = key_to_bucket(packed.first()[pos].element.first);
packed.first()[pos].next = std::exchange(sparse.first()[index], pos);
packed.first()[pos].next = stl::exchange(sparse.first()[index], pos);
}
}
}
@@ -985,7 +984,7 @@ public:
*/
void reserve(const size_type cnt) {
packed.first().reserve(cnt);
rehash(static_cast<size_type>(std::ceil(static_cast<float>(cnt) / max_load_factor())));
rehash(static_cast<size_type>(stl::ceil(static_cast<float>(cnt) / max_load_factor())));
}
/**
@@ -1013,11 +1012,13 @@ private:
} // namespace entt
/*! @cond ENTT_INTERNAL */
#include <utility>
namespace std {
template<typename Key, typename Value, typename Allocator>
struct uses_allocator<entt::internal::dense_map_node<Key, Value>, Allocator>
: std::true_type {};
: entt::stl::true_type {};
} // namespace std
/*! @endcond */

View File

@@ -1,24 +1,23 @@
#ifndef ENTT_CONTAINER_DENSE_SET_HPP
#define ENTT_CONTAINER_DENSE_SET_HPP
#include <bit>
#include <cmath>
#include <compare>
#include <concepts>
#include <cstddef>
#include <functional>
#include <iterator>
#include <limits>
#include <memory>
#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/bit.hpp"
#include "../stl/cmath.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/functional.hpp"
#include "../stl/iterator.hpp"
#include "../stl/limits.hpp"
#include "../stl/memory.hpp"
#include "../stl/tuple.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "../stl/vector.hpp"
#include "fwd.hpp"
namespace entt {
@@ -26,21 +25,21 @@ namespace entt {
/*! @cond ENTT_INTERNAL */
namespace internal {
static constexpr std::size_t dense_set_placeholder_position = (std::numeric_limits<std::size_t>::max)();
static constexpr stl::size_t dense_set_placeholder_position = (stl::numeric_limits<stl::size_t>::max)();
template<typename It>
class dense_set_iterator final {
template<typename>
friend class dense_set_iterator;
static_assert(std::is_pointer_v<It>, "Not a pointer type");
static_assert(stl::is_pointer_v<It>, "Not a pointer type");
public:
using value_type = std::remove_const_t<std::remove_pointer_t<It>>::second_type;
using value_type = stl::remove_const_t<stl::remove_pointer_t<It>>::second_type;
using pointer = const value_type *;
using reference = const value_type &;
using difference_type = std::ptrdiff_t;
using iterator_category = std::random_access_iterator_tag;
using difference_type = stl::ptrdiff_t;
using iterator_category = stl::random_access_iterator_tag;
constexpr dense_set_iterator() noexcept
: it{} {}
@@ -49,7 +48,7 @@ public:
: it{iter} {}
template<typename Other>
requires (!std::same_as<It, Other> && std::constructible_from<It, Other>)
requires (!stl::same_as<It, Other> && stl::constructible_from<It, Other>)
constexpr dense_set_iterator(const dense_set_iterator<Other> &other) noexcept
: it{other.it} {}
@@ -94,7 +93,7 @@ public:
}
[[nodiscard]] constexpr pointer operator->() const noexcept {
return std::addressof(operator[](0));
return stl::addressof(operator[](0));
}
[[nodiscard]] constexpr reference operator*() const noexcept {
@@ -102,7 +101,7 @@ public:
}
template<typename Other>
[[nodiscard]] constexpr std::ptrdiff_t operator-(const dense_set_iterator<Other> &other) const noexcept {
[[nodiscard]] constexpr stl::ptrdiff_t operator-(const dense_set_iterator<Other> &other) const noexcept {
return it - other.it;
}
@@ -125,23 +124,23 @@ class dense_set_local_iterator final {
template<typename>
friend class dense_set_local_iterator;
static_assert(std::is_pointer_v<It>, "Not a pointer type");
static_assert(stl::is_pointer_v<It>, "Not a pointer type");
public:
using value_type = std::remove_const_t<std::remove_pointer_t<It>>::second_type;
using value_type = stl::remove_const_t<stl::remove_pointer_t<It>>::second_type;
using pointer = const value_type *;
using reference = const value_type &;
using difference_type = std::ptrdiff_t;
using iterator_category = std::forward_iterator_tag;
using difference_type = stl::ptrdiff_t;
using iterator_category = stl::forward_iterator_tag;
constexpr dense_set_local_iterator() noexcept = default;
constexpr dense_set_local_iterator(It iter, const std::size_t pos) noexcept
constexpr dense_set_local_iterator(It iter, const stl::size_t pos) noexcept
: it{iter},
offset{pos} {}
template<typename Other>
requires (!std::same_as<It, Other> && std::constructible_from<It, Other>)
requires (!stl::same_as<It, Other> && stl::constructible_from<It, Other>)
constexpr dense_set_local_iterator(const dense_set_local_iterator<Other> &other) noexcept
: it{other.it},
offset{other.offset} {}
@@ -156,7 +155,7 @@ public:
}
[[nodiscard]] constexpr pointer operator->() const noexcept {
return std::addressof(it[static_cast<difference_type>(offset)].second);
return stl::addressof(it[static_cast<difference_type>(offset)].second);
}
[[nodiscard]] constexpr reference operator*() const noexcept {
@@ -168,13 +167,13 @@ public:
return offset == other.offset;
}
[[nodiscard]] constexpr std::size_t index() const noexcept {
[[nodiscard]] constexpr stl::size_t index() const noexcept {
return offset;
}
private:
It it{};
std::size_t offset{dense_set_placeholder_position};
stl::size_t offset{dense_set_placeholder_position};
};
} // namespace internal
@@ -195,20 +194,20 @@ private:
template<typename Type, typename Hash, typename KeyEqual, typename Allocator>
class dense_set {
static constexpr float default_threshold = 0.875f;
static constexpr std::size_t minimum_capacity = 8u;
static constexpr std::size_t placeholder_position = internal::dense_set_placeholder_position;
static constexpr stl::size_t minimum_capacity = 8u;
static constexpr stl::size_t placeholder_position = internal::dense_set_placeholder_position;
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 node_type = stl::pair<stl::size_t, Type>;
using alloc_traits = stl::allocator_traits<Allocator>;
static_assert(stl::is_same_v<typename alloc_traits::value_type, Type>, "Invalid value type");
using sparse_container_type = stl::vector<stl::size_t, typename alloc_traits::template rebind_alloc<stl::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 {
[[nodiscard]] stl::size_t value_to_bucket(const auto &value) const noexcept {
return fast_mod(static_cast<size_type>(sparse.second()(value)), bucket_count());
}
[[nodiscard]] auto constrained_find(const auto &value, const std::size_t bucket) {
[[nodiscard]] auto constrained_find(const auto &value, const stl::size_t bucket) {
for(auto offset = sparse.first()[bucket]; offset != placeholder_position; offset = packed.first()[offset].first) {
if(packed.second()(packed.first()[offset].second, value)) {
return begin() + static_cast<iterator::difference_type>(offset);
@@ -218,7 +217,7 @@ class dense_set {
return end();
}
[[nodiscard]] auto constrained_find(const auto &value, const std::size_t bucket) const {
[[nodiscard]] auto constrained_find(const auto &value, const stl::size_t bucket) const {
for(auto offset = sparse.first()[bucket]; offset != placeholder_position; offset = packed.first()[offset].first) {
if(packed.second()(packed.first()[offset].second, value)) {
return cbegin() + static_cast<const_iterator::difference_type>(offset);
@@ -233,20 +232,20 @@ class dense_set {
const auto index = value_to_bucket(value);
if(auto it = constrained_find(value, index); it != end()) {
return std::make_pair(it, false);
return stl::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();
return std::make_pair(--end(), true);
return stl::make_pair(--end(), true);
}
void move_and_pop(const std::size_t pos) {
void move_and_pop(const stl::size_t pos) {
if(const auto last = size() - 1u; pos != last) {
size_type *curr = &sparse.first()[value_to_bucket(packed.first().back().second)];
packed.first()[pos] = std::move(packed.first().back());
packed.first()[pos] = stl::move(packed.first().back());
for(; *curr != last; curr = &packed.first()[*curr].first) {}
*curr = pos;
}
@@ -268,9 +267,9 @@ public:
/*! @brief Value type of the container. */
using value_type = Type;
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Signed integer type. */
using difference_type = std::ptrdiff_t;
using difference_type = stl::ptrdiff_t;
/*! @brief Type of function to use to hash the elements. */
using hasher = Hash;
/*! @brief Type of function to use to compare the elements for equality. */
@@ -280,9 +279,9 @@ public:
/*! @brief Constant random access iterator type. */
using const_iterator = internal::dense_set_iterator<typename packed_container_type::const_pointer>;
/*! @brief Reverse iterator type. */
using reverse_iterator = std::reverse_iterator<iterator>;
using reverse_iterator = stl::reverse_iterator<iterator>;
/*! @brief Constant reverse iterator type. */
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
using const_reverse_iterator = stl::reverse_iterator<const_iterator>;
/*! @brief Forward iterator type. */
using local_iterator = internal::dense_set_local_iterator<typename packed_container_type::pointer>;
/*! @brief Constant forward iterator type. */
@@ -341,8 +340,8 @@ public:
* @param allocator The allocator to use.
*/
dense_set(const dense_set &other, const allocator_type &allocator)
: sparse{std::piecewise_construct, std::forward_as_tuple(other.sparse.first(), allocator), std::forward_as_tuple(other.sparse.second())},
packed{std::piecewise_construct, std::forward_as_tuple(other.packed.first(), allocator), std::forward_as_tuple(other.packed.second())},
: sparse{stl::piecewise_construct, stl::forward_as_tuple(other.sparse.first(), allocator), stl::forward_as_tuple(other.sparse.second())},
packed{stl::piecewise_construct, stl::forward_as_tuple(other.packed.first(), allocator), stl::forward_as_tuple(other.packed.second())},
threshold{other.threshold} {}
/*! @brief Default move constructor. */
@@ -354,8 +353,8 @@ public:
* @param allocator The allocator to use.
*/
dense_set(dense_set &&other, const allocator_type &allocator)
: sparse{std::piecewise_construct, std::forward_as_tuple(std::move(other.sparse.first()), allocator), std::forward_as_tuple(std::move(other.sparse.second()))},
packed{std::piecewise_construct, std::forward_as_tuple(std::move(other.packed.first()), allocator), std::forward_as_tuple(std::move(other.packed.second()))},
: sparse{stl::piecewise_construct, stl::forward_as_tuple(stl::move(other.sparse.first()), allocator), stl::forward_as_tuple(stl::move(other.sparse.second()))},
packed{stl::piecewise_construct, stl::forward_as_tuple(stl::move(other.packed.first()), allocator), stl::forward_as_tuple(stl::move(other.packed.second()))},
threshold{other.threshold} {}
/*! @brief Default destructor. */
@@ -378,7 +377,7 @@ public:
* @param other Container to exchange the content with.
*/
void swap(dense_set &other) noexcept {
using std::swap;
using stl::swap;
swap(sparse, other.sparse);
swap(packed, other.packed);
swap(threshold, other.threshold);
@@ -440,7 +439,7 @@ public:
* @return An iterator to the first instance of the reversed internal array.
*/
[[nodiscard]] const_reverse_iterator crbegin() const noexcept {
return std::make_reverse_iterator(cend());
return stl::make_reverse_iterator(cend());
}
/*! @copydoc crbegin */
@@ -450,7 +449,7 @@ public:
/*! @copydoc rbegin */
[[nodiscard]] reverse_iterator rbegin() noexcept {
return std::make_reverse_iterator(end());
return stl::make_reverse_iterator(end());
}
/**
@@ -459,7 +458,7 @@ public:
* reversed internal array.
*/
[[nodiscard]] const_reverse_iterator crend() const noexcept {
return std::make_reverse_iterator(cbegin());
return stl::make_reverse_iterator(cbegin());
}
/*! @copydoc crend */
@@ -469,7 +468,7 @@ public:
/*! @copydoc rend */
[[nodiscard]] reverse_iterator rend() noexcept {
return std::make_reverse_iterator(begin());
return stl::make_reverse_iterator(begin());
}
/**
@@ -510,13 +509,13 @@ public:
* the element that prevented the insertion) and a bool denoting whether the
* insertion took place.
*/
std::pair<iterator, bool> insert(const value_type &value) {
stl::pair<iterator, bool> insert(const value_type &value) {
return insert_or_do_nothing(value);
}
/*! @copydoc insert */
std::pair<iterator, bool> insert(value_type &&value) {
return insert_or_do_nothing(std::move(value));
stl::pair<iterator, bool> insert(value_type &&value) {
return insert_or_do_nothing(stl::move(value));
}
/**
@@ -544,22 +543,22 @@ public:
* insertion took place.
*/
template<typename... Args>
std::pair<iterator, bool> emplace(Args &&...args) {
if constexpr(((sizeof...(Args) == 1u) && ... && std::is_same_v<std::decay_t<Args>, value_type>)) {
return insert_or_do_nothing(std::forward<Args>(args)...);
stl::pair<iterator, bool> emplace(Args &&...args) {
if constexpr(((sizeof...(Args) == 1u) && ... && stl::is_same_v<stl::decay_t<Args>, value_type>)) {
return insert_or_do_nothing(stl::forward<Args>(args)...);
} else {
auto &node = packed.first().emplace_back(std::piecewise_construct, std::make_tuple(packed.first().size()), std::forward_as_tuple(std::forward<Args>(args)...));
auto &node = packed.first().emplace_back(stl::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()) {
packed.first().pop_back();
return std::make_pair(it, false);
return stl::make_pair(it, false);
}
std::swap(node.first, sparse.first()[index]);
stl::swap(node.first, sparse.first()[index]);
rehash_if_required();
return std::make_pair(--end(), true);
return stl::make_pair(--end(), true);
}
}
@@ -665,13 +664,13 @@ public:
* @return A pair of iterators pointing to the first element and past the
* last element of the range.
*/
[[nodiscard]] std::pair<iterator, iterator> equal_range(const value_type &value) {
[[nodiscard]] stl::pair<iterator, iterator> equal_range(const value_type &value) {
const auto it = find(value);
return {it, it + !(it == end())};
}
/*! @copydoc equal_range */
[[nodiscard]] std::pair<const_iterator, const_iterator> equal_range(const value_type &value) const {
[[nodiscard]] stl::pair<const_iterator, const_iterator> equal_range(const value_type &value) const {
const auto it = find(value);
return {it, it + !(it == cend())};
}
@@ -683,14 +682,14 @@ public:
* @return A pair of iterators pointing to the first element and past the
* last element of the range.
*/
[[nodiscard]] std::pair<iterator, iterator> equal_range(const auto &value)
[[nodiscard]] stl::pair<iterator, iterator> equal_range(const auto &value)
requires is_transparent_v<hasher> && is_transparent_v<key_equal> {
const auto it = find(value);
return {it, it + !(it == end())};
}
/*! @copydoc equal_range */
[[nodiscard]] std::pair<const_iterator, const_iterator> equal_range(const auto &value) const
[[nodiscard]] stl::pair<const_iterator, const_iterator> equal_range(const auto &value) const
requires is_transparent_v<hasher> && is_transparent_v<key_equal> {
const auto it = find(value);
return {it, it + !(it == cend())};
@@ -792,7 +791,7 @@ public:
* @return The number of elements in the given bucket.
*/
[[nodiscard]] size_type bucket_size(const size_type index) const {
return static_cast<size_type>(std::distance(begin(index), end(index)));
return static_cast<size_type>(stl::distance(begin(index), end(index)));
}
/**
@@ -840,7 +839,7 @@ public:
const auto cap = static_cast<size_type>(static_cast<float>(size()) / max_load_factor());
value = value > cap ? value : cap;
if(const auto sz = std::bit_ceil(value); sz != bucket_count()) {
if(const auto sz = stl::bit_ceil(value); sz != bucket_count()) {
sparse.first().resize(sz);
for(auto &&elem: sparse.first()) {
@@ -849,7 +848,7 @@ public:
for(size_type pos{}, last = size(); pos < last; ++pos) {
const auto index = value_to_bucket(packed.first()[pos].second);
packed.first()[pos].first = std::exchange(sparse.first()[index], pos);
packed.first()[pos].first = stl::exchange(sparse.first()[index], pos);
}
}
}
@@ -861,7 +860,7 @@ public:
*/
void reserve(const size_type cnt) {
packed.first().reserve(cnt);
rehash(static_cast<size_type>(std::ceil(static_cast<float>(cnt) / max_load_factor())));
rehash(static_cast<size_type>(stl::ceil(static_cast<float>(cnt) / max_load_factor())));
}
/**

View File

@@ -1,26 +1,26 @@
#ifndef ENTT_CONTAINER_FWD_HPP
#define ENTT_CONTAINER_FWD_HPP
#include <functional>
#include <memory>
#include <utility>
#include <vector>
#include "../stl/functional.hpp"
#include "../stl/memory.hpp"
#include "../stl/utility.hpp"
#include "../stl/vector.hpp"
namespace entt {
template<
typename Key,
typename Type,
typename = std::hash<Key>,
typename = std::equal_to<>,
typename = std::allocator<std::pair<const Key, Type>>>
typename = stl::hash<Key>,
typename = stl::equal_to<>,
typename = stl::allocator<stl::pair<const Key, Type>>>
class dense_map;
template<
typename Type,
typename = std::hash<Type>,
typename = std::equal_to<>,
typename = std::allocator<Type>>
typename = stl::hash<Type>,
typename = stl::equal_to<>,
typename = stl::allocator<Type>>
class dense_set;
template<typename...>
@@ -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

View File

@@ -1,13 +1,13 @@
#ifndef ENTT_CONTAINER_TABLE_HPP
#define ENTT_CONTAINER_TABLE_HPP
#include <concepts>
#include <cstddef>
#include <iterator>
#include <tuple>
#include <utility>
#include "../config/config.h"
#include "../core/iterator.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/iterator.hpp"
#include "../stl/tuple.hpp"
#include "../stl/utility.hpp"
#include "fwd.hpp"
namespace entt {
@@ -21,12 +21,12 @@ class table_iterator {
friend class table_iterator;
public:
using value_type = decltype(std::forward_as_tuple(*std::declval<It>()...));
using value_type = decltype(stl::forward_as_tuple(*stl::declval<It>()...));
using pointer = input_iterator_pointer<value_type>;
using reference = value_type;
using difference_type = std::ptrdiff_t;
using iterator_category = std::input_iterator_tag;
using iterator_concept = std::random_access_iterator_tag;
using difference_type = stl::ptrdiff_t;
using iterator_category = stl::input_iterator_tag;
using iterator_concept = stl::random_access_iterator_tag;
constexpr table_iterator() noexcept
: it{} {}
@@ -35,12 +35,12 @@ public:
: it{from...} {}
template<typename... Other>
requires (std::constructible_from<It, Other> && ...)
requires (stl::constructible_from<It, Other> && ...)
constexpr table_iterator(const table_iterator<Other...> &other) noexcept
: table_iterator{std::get<Other>(other.it)...} {}
: table_iterator{stl::get<Other>(other.it)...} {}
constexpr table_iterator &operator++() noexcept {
return (++std::get<It>(it), ...), *this;
return (++stl::get<It>(it), ...), *this;
}
constexpr table_iterator operator++(int) noexcept {
@@ -49,7 +49,7 @@ public:
}
constexpr table_iterator &operator--() noexcept {
return (--std::get<It>(it), ...), *this;
return (--stl::get<It>(it), ...), *this;
}
constexpr table_iterator operator--(int) noexcept {
@@ -58,7 +58,7 @@ public:
}
constexpr table_iterator &operator+=(const difference_type value) noexcept {
return ((std::get<It>(it) += value), ...), *this;
return ((stl::get<It>(it) += value), ...), *this;
}
constexpr table_iterator operator+(const difference_type value) const noexcept {
@@ -75,7 +75,7 @@ public:
}
[[nodiscard]] constexpr reference operator[](const difference_type value) const noexcept {
return std::forward_as_tuple(std::get<It>(it)[value]...);
return stl::forward_as_tuple(stl::get<It>(it)[value]...);
}
[[nodiscard]] constexpr pointer operator->() const noexcept {
@@ -87,22 +87,22 @@ public:
}
template<typename... Other>
[[nodiscard]] constexpr std::ptrdiff_t operator-(const table_iterator<Other...> &other) const noexcept {
return std::get<0>(it) - std::get<0>(other.it);
[[nodiscard]] constexpr stl::ptrdiff_t operator-(const table_iterator<Other...> &other) const noexcept {
return stl::get<0>(it) - stl::get<0>(other.it);
}
template<typename... Other>
[[nodiscard]] constexpr bool operator==(const table_iterator<Other...> &other) const noexcept {
return std::get<0>(it) == std::get<0>(other.it);
return stl::get<0>(it) == stl::get<0>(other.it);
}
template<typename... Other>
[[nodiscard]] constexpr auto operator<=>(const table_iterator<Other...> &other) const noexcept {
return std::get<0>(it) <=> std::get<0>(other.it);
return stl::get<0>(it) <=> stl::get<0>(other.it);
}
private:
std::tuple<It...> it;
stl::tuple<It...> it;
};
} // namespace internal
@@ -119,13 +119,13 @@ private:
*/
template<typename... Container>
class basic_table {
using container_type = std::tuple<Container...>;
using container_type = stl::tuple<Container...>;
public:
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Signed integer type. */
using difference_type = std::ptrdiff_t;
using difference_type = stl::ptrdiff_t;
/*! @brief Input iterator type. */
using iterator = internal::table_iterator<typename Container::iterator...>;
/*! @brief Constant input iterator type. */
@@ -146,7 +146,7 @@ public:
*/
explicit basic_table(const Container &...container) noexcept
: payload{container...} {
ENTT_ASSERT((((std::get<Container>(payload).size() * sizeof...(Container)) == (std::get<Container>(payload).size() + ...)) && ...), "Unexpected container size");
ENTT_ASSERT((((stl::get<Container>(payload).size() * sizeof...(Container)) == (stl::get<Container>(payload).size() + ...)) && ...), "Unexpected container size");
}
/**
@@ -154,8 +154,8 @@ public:
* @param container The containers to move from.
*/
explicit basic_table(Container &&...container) noexcept
: payload{std::move(container)...} {
ENTT_ASSERT((((std::get<Container>(payload).size() * sizeof...(Container)) == (std::get<Container>(payload).size() + ...)) && ...), "Unexpected container size");
: payload{stl::move(container)...} {
ENTT_ASSERT((((stl::get<Container>(payload).size() * sizeof...(Container)) == (stl::get<Container>(payload).size() + ...)) && ...), "Unexpected container size");
}
/*! @brief Default copy constructor, deleted on purpose. */
@@ -166,7 +166,7 @@ public:
* @param other The instance to move from.
*/
basic_table(basic_table &&other) noexcept
: payload{std::move(other.payload)} {}
: payload{stl::move(other.payload)} {}
/**
* @brief Constructs the underlying containers using a given allocator.
@@ -184,7 +184,7 @@ public:
template<class Allocator>
basic_table(const Container &...container, const Allocator &allocator) noexcept
: payload{Container{container, allocator}...} {
ENTT_ASSERT((((std::get<Container>(payload).size() * sizeof...(Container)) == (std::get<Container>(payload).size() + ...)) && ...), "Unexpected container size");
ENTT_ASSERT((((stl::get<Container>(payload).size() * sizeof...(Container)) == (stl::get<Container>(payload).size() + ...)) && ...), "Unexpected container size");
}
/**
@@ -195,8 +195,8 @@ public:
*/
template<class Allocator>
basic_table(Container &&...container, const Allocator &allocator) noexcept
: payload{Container{std::move(container), allocator}...} {
ENTT_ASSERT((((std::get<Container>(payload).size() * sizeof...(Container)) == (std::get<Container>(payload).size() + ...)) && ...), "Unexpected container size");
: payload{Container{stl::move(container), allocator}...} {
ENTT_ASSERT((((stl::get<Container>(payload).size() * sizeof...(Container)) == (stl::get<Container>(payload).size() + ...)) && ...), "Unexpected container size");
}
/**
@@ -207,7 +207,7 @@ public:
*/
template<class Allocator>
basic_table(basic_table &&other, const Allocator &allocator)
: payload{Container{std::move(std::get<Container>(other.payload)), allocator}...} {}
: payload{Container{stl::move(stl::get<Container>(other.payload)), allocator}...} {}
/*! @brief Default destructor. */
~basic_table() = default;
@@ -233,7 +233,7 @@ public:
* @param other Table to exchange the content with.
*/
void swap(basic_table &other) noexcept {
using std::swap;
using stl::swap;
swap(payload, other.payload);
}
@@ -246,7 +246,7 @@ public:
* @param cap Desired capacity.
*/
void reserve(const size_type cap) {
(std::get<Container>(payload).reserve(cap), ...);
(stl::get<Container>(payload).reserve(cap), ...);
}
/**
@@ -255,12 +255,12 @@ public:
* @return Capacity of the table.
*/
[[nodiscard]] size_type capacity() const noexcept {
return std::get<0>(payload).capacity();
return stl::get<0>(payload).capacity();
}
/*! @brief Requests the removal of unused capacity. */
void shrink_to_fit() {
(std::get<Container>(payload).shrink_to_fit(), ...);
(stl::get<Container>(payload).shrink_to_fit(), ...);
}
/**
@@ -268,7 +268,7 @@ public:
* @return Number of rows.
*/
[[nodiscard]] size_type size() const noexcept {
return std::get<0>(payload).size();
return stl::get<0>(payload).size();
}
/**
@@ -276,7 +276,7 @@ public:
* @return True if the table is empty, false otherwise.
*/
[[nodiscard]] bool empty() const noexcept {
return std::get<0>(payload).empty();
return stl::get<0>(payload).empty();
}
/**
@@ -287,7 +287,7 @@ public:
* @return An iterator to the first row of the table.
*/
[[nodiscard]] const_iterator cbegin() const noexcept {
return {std::get<Container>(payload).cbegin()...};
return {stl::get<Container>(payload).cbegin()...};
}
/*! @copydoc cbegin */
@@ -297,7 +297,7 @@ public:
/*! @copydoc begin */
[[nodiscard]] iterator begin() noexcept {
return {std::get<Container>(payload).begin()...};
return {stl::get<Container>(payload).begin()...};
}
/**
@@ -305,7 +305,7 @@ public:
* @return An iterator to the element following the last row of the table.
*/
[[nodiscard]] const_iterator cend() const noexcept {
return {std::get<Container>(payload).cend()...};
return {stl::get<Container>(payload).cend()...};
}
/*! @copydoc cend */
@@ -315,7 +315,7 @@ public:
/*! @copydoc end */
[[nodiscard]] iterator end() noexcept {
return {std::get<Container>(payload).end()...};
return {stl::get<Container>(payload).end()...};
}
/**
@@ -326,7 +326,7 @@ public:
* @return An iterator to the first row of the reversed table.
*/
[[nodiscard]] const_reverse_iterator crbegin() const noexcept {
return {std::get<Container>(payload).crbegin()...};
return {stl::get<Container>(payload).crbegin()...};
}
/*! @copydoc crbegin */
@@ -336,7 +336,7 @@ public:
/*! @copydoc rbegin */
[[nodiscard]] reverse_iterator rbegin() noexcept {
return {std::get<Container>(payload).rbegin()...};
return {stl::get<Container>(payload).rbegin()...};
}
/**
@@ -345,7 +345,7 @@ public:
* table.
*/
[[nodiscard]] const_reverse_iterator crend() const noexcept {
return {std::get<Container>(payload).crend()...};
return {stl::get<Container>(payload).crend()...};
}
/*! @copydoc crend */
@@ -355,7 +355,7 @@ public:
/*! @copydoc rend */
[[nodiscard]] reverse_iterator rend() noexcept {
return {std::get<Container>(payload).rend()...};
return {stl::get<Container>(payload).rend()...};
}
/**
@@ -365,11 +365,11 @@ public:
* @return A reference to the newly created row data.
*/
template<typename... Args>
std::tuple<typename Container::value_type &...> emplace(Args &&...args) {
stl::tuple<typename Container::value_type &...> emplace(Args &&...args) {
if constexpr(sizeof...(Args) == 0u) {
return std::forward_as_tuple(std::get<Container>(payload).emplace_back()...);
return stl::forward_as_tuple(stl::get<Container>(payload).emplace_back()...);
} else {
return std::forward_as_tuple(std::get<Container>(payload).emplace_back(std::forward<Args>(args))...);
return stl::forward_as_tuple(stl::get<Container>(payload).emplace_back(stl::forward<Args>(args))...);
}
}
@@ -380,7 +380,7 @@ public:
*/
iterator erase(const_iterator pos) {
const auto diff = pos - begin();
return {std::get<Container>(payload).erase(std::get<Container>(payload).begin() + diff)...};
return {stl::get<Container>(payload).erase(stl::get<Container>(payload).begin() + diff)...};
}
/**
@@ -397,20 +397,20 @@ public:
* @param pos The row for which to return the data.
* @return The row data at specified location.
*/
[[nodiscard]] std::tuple<const typename Container::value_type &...> operator[](const size_type pos) const {
[[nodiscard]] stl::tuple<const typename Container::value_type &...> operator[](const size_type pos) const {
ENTT_ASSERT(pos < size(), "Index out of bounds");
return std::forward_as_tuple(std::get<Container>(payload)[pos]...);
return stl::forward_as_tuple(stl::get<Container>(payload)[pos]...);
}
/*! @copydoc operator[] */
[[nodiscard]] std::tuple<typename Container::value_type &...> operator[](const size_type pos) {
[[nodiscard]] stl::tuple<typename Container::value_type &...> operator[](const size_type pos) {
ENTT_ASSERT(pos < size(), "Index out of bounds");
return std::forward_as_tuple(std::get<Container>(payload)[pos]...);
return stl::forward_as_tuple(stl::get<Container>(payload)[pos]...);
}
/*! @brief Clears a table. */
void clear() {
(std::get<Container>(payload).clear(), ...);
(stl::get<Container>(payload).clear(), ...);
}
private:
@@ -420,11 +420,13 @@ private:
} // namespace entt
/*! @cond ENTT_INTERNAL */
#include <utility>
namespace std {
template<typename... Container, typename Allocator>
struct uses_allocator<entt::basic_table<Container...>, Allocator>
: std::bool_constant<(std::uses_allocator_v<Container, Allocator> && ...)> {};
: entt::stl::bool_constant<(entt::stl::uses_allocator_v<Container, Allocator> && ...)> {};
} // namespace std
/*! @endcond */

View File

@@ -1,23 +1,22 @@
#ifndef ENTT_CORE_ALGORITHM_HPP
#define ENTT_CORE_ALGORITHM_HPP
#include <algorithm>
#include <concepts>
#include <functional>
#include <iterator>
#include <utility>
#include <vector>
#include "../stl/algorithm.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/functional.hpp"
#include "../stl/iterator.hpp"
#include "../stl/utility.hpp"
#include "../stl/vector.hpp"
namespace entt {
/**
* @brief Function object to wrap `std::sort` in a class type.
* @brief Function object to wrap `stl::sort` in a class type.
*
* Unfortunately, `std::sort` cannot be passed as template argument to a class
* Unfortunately, `stl::sort` cannot be passed as template argument to a class
* template or a function template.<br/>
* This class fills the gap by wrapping some flavors of `std::sort` in a
* This class fills the gap by wrapping some flavors of `stl::sort` in a
* function object.
*/
struct std_sort {
@@ -33,9 +32,9 @@ struct std_sort {
* @param compare A valid comparison function object.
* @param args Arguments to forward to the sort function, if any.
*/
template<typename Compare = std::less<>, typename... Args>
template<typename Compare = stl::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));
stl::sort(stl::forward<Args>(args)..., stl::move(first), stl::move(last), stl::move(compare));
}
};
@@ -51,20 +50,20 @@ struct insertion_sort {
* @param last An iterator past the last element of the range to sort.
* @param compare A valid comparison function object.
*/
template<typename Compare = std::less<>>
template<typename Compare = stl::less<>>
void operator()(stl::random_access_iterator auto first, stl::random_access_iterator auto last, Compare compare = Compare{}) const {
if(first < last) {
for(auto it = first + 1; it < last; ++it) {
auto value = std::move(*it);
auto value = stl::move(*it);
auto pre = it;
// NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic)
for(; pre > first && compare(value, *(pre - 1)); --pre) {
*pre = std::move(*(pre - 1));
*pre = stl::move(*(pre - 1));
}
// NOLINTEND(cppcoreguidelines-pro-bounds-pointer-arithmetic)
*pre = std::move(value);
*pre = stl::move(value);
}
}
}
@@ -75,7 +74,7 @@ struct insertion_sort {
* @tparam Bit Number of bits processed per pass.
* @tparam N Maximum number of bits to sort.
*/
template<std::size_t Bit, std::size_t N>
template<stl::size_t Bit, stl::size_t N>
requires ((N % Bit) == 0) // The maximum number of bits to sort must be a multiple of the number of bits processed per pass
struct radix_sort {
/**
@@ -98,42 +97,42 @@ struct radix_sort {
if(first < last) {
constexpr auto passes = N / Bit;
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)));
using value_type = stl::iterator_traits<It>::value_type;
using difference_type = stl::iterator_traits<It>::difference_type;
stl::vector<value_type> aux(static_cast<stl::size_t>(stl::distance(first, last)));
auto part = [getter = std::move(getter)](auto from, auto to, auto out, auto start) {
auto part = [getter = stl::move(getter)](auto from, auto to, auto out, auto start) {
constexpr auto mask = (1 << Bit) - 1;
constexpr auto buckets = 1 << Bit;
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays, misc-const-correctness)
std::size_t count[buckets]{};
stl::size_t count[buckets]{};
for(auto it = from; it != to; ++it) {
++count[(getter(*it) >> start) & mask];
}
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
std::size_t index[buckets]{};
stl::size_t index[buckets]{};
for(std::size_t pos{}, end = buckets - 1u; pos < end; ++pos) {
for(stl::size_t pos{}, end = buckets - 1u; pos < end; ++pos) {
index[pos + 1u] = index[pos] + count[pos];
}
for(auto it = from; it != to; ++it) {
const auto pos = index[(getter(*it) >> start) & mask]++;
out[static_cast<difference_type>(pos)] = std::move(*it);
out[static_cast<difference_type>(pos)] = stl::move(*it);
}
};
for(std::size_t pass = 0; pass < (passes & ~1u); pass += 2) {
for(stl::size_t pass = 0; pass < (passes & ~1u); pass += 2) {
part(first, last, aux.begin(), pass * Bit);
part(aux.begin(), aux.end(), first, (pass + 1) * Bit);
}
if constexpr(passes & 1) {
part(first, last, aux.begin(), (passes - 1) * Bit);
std::move(aux.begin(), aux.end(), first);
stl::move(aux.begin(), aux.end(), first);
}
}
}

View File

@@ -1,13 +1,14 @@
#ifndef ENTT_CORE_ANY_HPP
#define ENTT_CORE_ANY_HPP
#include <concepts>
#include <cstddef>
#include <memory>
#include <type_traits>
#include <utility>
#include "../config/config.h"
#include "../core/concepts.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/cstdint.hpp"
#include "../stl/memory.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "fwd.hpp"
#include "type_info.hpp"
#include "type_traits.hpp"
@@ -18,7 +19,7 @@ namespace entt {
/*! @cond ENTT_INTERNAL */
namespace internal {
enum class any_request : std::uint8_t {
enum class any_request : stl::uint8_t {
info,
transfer,
assign,
@@ -27,28 +28,28 @@ enum class any_request : std::uint8_t {
move
};
template<std::size_t Len, std::size_t Align>
template<stl::size_t Len, stl::size_t Align>
struct basic_any_storage {
static constexpr bool has_buffer = true;
union {
const void *instance{};
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
alignas(Align) std::byte buffer[Len];
alignas(Align) stl::byte buffer[Len];
};
};
template<std::size_t Align>
template<stl::size_t Align>
struct basic_any_storage<0u, Align> {
static constexpr bool has_buffer = false;
const void *instance{};
};
template<typename Type, std::size_t Len, std::size_t Align>
template<typename Type, stl::size_t Len, stl::size_t Align>
// NOLINTNEXTLINE(bugprone-sizeof-expression)
struct in_situ: std::bool_constant<(Len != 0u) && alignof(Type) <= Align && sizeof(Type) <= Len && std::is_nothrow_move_constructible_v<Type>> {};
struct in_situ: stl::bool_constant<(Len != 0u) && alignof(Type) <= Align && sizeof(Type) <= Len && stl::is_nothrow_move_constructible_v<Type>> {};
template<std::size_t Len, std::size_t Align>
struct in_situ<void, Len, Align>: std::false_type {};
template<stl::size_t Len, stl::size_t Align>
struct in_situ<void, Len, Align>: stl::false_type {};
} // namespace internal
/*! @endcond */
@@ -58,7 +59,7 @@ struct in_situ<void, Len, Align>: std::false_type {};
* @tparam Len Size of the buffer reserved for the small buffer optimization.
* @tparam Align Optional alignment requirement.
*/
template<std::size_t Len, std::size_t Align>
template<stl::size_t Len, stl::size_t Align>
class basic_any: private internal::basic_any_storage<Len, Align> {
using request = internal::any_request;
using base_type = internal::basic_any_storage<Len, Align>;
@@ -75,26 +76,26 @@ class basic_any: private internal::basic_any_storage<Len, Align> {
case info:
return &type_id<Type>();
case transfer:
if constexpr(std::is_move_assignable_v<Type>) {
if constexpr(stl::is_move_assignable_v<Type>) {
// NOLINTNEXTLINE(bugprone-casting-through-void)
*const_cast<Type *>(elem) = std::move(*static_cast<Type *>(const_cast<void *>(other)));
*const_cast<Type *>(elem) = stl::move(*static_cast<Type *>(const_cast<void *>(other)));
return other;
}
[[fallthrough]];
case assign:
if constexpr(std::is_copy_assignable_v<Type>) {
if constexpr(stl::is_copy_assignable_v<Type>) {
*const_cast<Type *>(elem) = *static_cast<const Type *>(other);
return other;
}
break;
case compare:
if constexpr(!std::is_function_v<Type> && !std::is_array_v<Type> && is_equality_comparable_v<Type>) {
if constexpr(!stl::is_function_v<Type> && !stl::is_array_v<Type> && is_equality_comparable_v<Type>) {
return (*elem == *static_cast<const Type *>(other)) ? other : nullptr;
} else {
return (elem == other) ? other : nullptr;
}
case copy:
if constexpr(std::is_copy_constructible_v<Type>) {
if constexpr(stl::is_copy_constructible_v<Type>) {
// NOLINTNEXTLINE(bugprone-casting-through-void)
static_cast<basic_any *>(const_cast<void *>(other))->initialize<Type>(*elem);
}
@@ -103,7 +104,7 @@ class basic_any: private internal::basic_any_storage<Len, Align> {
ENTT_ASSERT(value.mode == any_policy::embedded, "Unexpected policy");
if constexpr(in_situ_v<Type>) {
// NOLINTNEXTLINE(bugprone-casting-through-void, bugprone-multi-level-implicit-pointer-conversion)
return ::new(&static_cast<basic_any *>(const_cast<void *>(other))->buffer) Type{std::move(*const_cast<Type *>(elem))};
return ::new(&static_cast<basic_any *>(const_cast<void *>(other))->buffer) Type{stl::move(*const_cast<Type *>(elem))};
}
}
@@ -112,13 +113,13 @@ class basic_any: private internal::basic_any_storage<Len, Align> {
template<cvref_unqualified Type>
static void basic_deleter(const basic_any &value) {
ENTT_ASSERT((value.mode == any_policy::dynamic) || ((value.mode == any_policy::embedded) && !std::is_trivially_destructible_v<Type>), "Unexpected policy");
ENTT_ASSERT((value.mode == any_policy::dynamic) || ((value.mode == any_policy::embedded) && !stl::is_trivially_destructible_v<Type>), "Unexpected policy");
const auto *elem = static_cast<const Type *>(value.data());
if constexpr(in_situ_v<Type>) {
(value.mode == any_policy::embedded) ? elem->~Type() : (delete elem);
} else if constexpr(std::is_array_v<Type>) {
} else if constexpr(stl::is_array_v<Type>) {
delete[] elem;
} else {
delete elem;
@@ -127,23 +128,23 @@ class basic_any: private internal::basic_any_storage<Len, Align> {
template<typename Type, typename... Args>
void initialize([[maybe_unused]] Args &&...args) {
using plain_type = std::remove_cvref_t<Type>;
using plain_type = stl::remove_cvref_t<Type>;
vtable = basic_vtable<plain_type>;
underlying_type = type_hash<plain_type>::value();
if constexpr(std::is_void_v<Type>) {
if constexpr(stl::is_void_v<Type>) {
deleter = nullptr;
mode = any_policy::empty;
this->instance = nullptr;
} else if constexpr(std::is_lvalue_reference_v<Type>) {
} else if constexpr(stl::is_lvalue_reference_v<Type>) {
deleter = nullptr;
mode = std::is_const_v<std::remove_reference_t<Type>> ? any_policy::cref : any_policy::ref;
static_assert((std::is_lvalue_reference_v<Args> && ...) && (sizeof...(Args) == 1u), "Invalid arguments");
mode = stl::is_const_v<stl::remove_reference_t<Type>> ? any_policy::cref : any_policy::ref;
static_assert((stl::is_lvalue_reference_v<Args> && ...) && (sizeof...(Args) == 1u), "Invalid arguments");
// NOLINTNEXTLINE(bugprone-multi-level-implicit-pointer-conversion)
this->instance = (std::addressof(args), ...);
this->instance = (stl::addressof(args), ...);
} else if constexpr(in_situ_v<plain_type>) {
if constexpr(std::is_trivially_destructible_v<plain_type>) {
if constexpr(stl::is_trivially_destructible_v<plain_type>) {
deleter = nullptr;
} else {
deleter = &basic_deleter<plain_type>;
@@ -151,23 +152,23 @@ 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)...};
if constexpr(stl::is_aggregate_v<plain_type> && (sizeof...(Args) != 0u || !stl::is_default_constructible_v<plain_type>)) {
::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)...};
} else if constexpr(std::is_array_v<plain_type>) {
if constexpr(stl::is_aggregate_v<plain_type> && (sizeof...(Args) != 0u || !stl::is_default_constructible_v<plain_type>)) {
this->instance = new plain_type{stl::forward<Args>(args)...};
} else if constexpr(stl::is_array_v<plain_type>) {
static_assert(sizeof...(Args) == 0u, "Invalid arguments");
this->instance = new plain_type[std::extent_v<plain_type>]();
this->instance = new plain_type[stl::extent_v<plain_type>]();
} else {
this->instance = new plain_type(std::forward<Args>(args)...);
this->instance = new plain_type(stl::forward<Args>(args)...);
}
}
}
@@ -186,7 +187,7 @@ public:
/*! @brief Default constructor. */
constexpr basic_any() noexcept
: basic_any{std::in_place_type<void>} {}
: basic_any{stl::in_place_type<void>} {}
/**
* @brief Constructs a wrapper by directly initializing the new object.
@@ -195,9 +196,9 @@ public:
* @param args Parameters to use to construct the instance.
*/
template<typename Type, typename... Args>
explicit basic_any(std::in_place_type_t<Type>, Args &&...args)
explicit basic_any(stl::in_place_type_t<Type>, Args &&...args)
: base_type{} {
initialize<Type>(std::forward<Args>(args)...);
initialize<Type>(stl::forward<Args>(args)...);
}
/**
@@ -206,8 +207,8 @@ public:
* @param value A pointer to an object to take ownership of.
*/
template<typename Type>
requires (!std::is_const_v<Type> && !std::is_void_v<Type>)
explicit basic_any(std::in_place_t, Type *value)
requires (!stl::is_const_v<Type> && !stl::is_void_v<Type>)
explicit basic_any(stl::in_place_t, Type *value)
: base_type{} {
if(value == nullptr) {
initialize<void>();
@@ -224,9 +225,9 @@ public:
* @param value An instance of an object to use to initialize the wrapper.
*/
template<typename Type>
requires (!std::same_as<std::remove_cvref_t<Type>, basic_any>)
requires (!stl::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{stl::in_place_type<stl::decay_t<Type>>, stl::forward<Type>(value)} {}
/**
* @brief Copy constructor.
@@ -250,7 +251,7 @@ public:
if(other.mode == any_policy::embedded) {
other.vtable(request::move, other, this);
} else if(other.mode != any_policy::empty) {
this->instance = std::exchange(other.instance, nullptr);
this->instance = stl::exchange(other.instance, nullptr);
}
}
@@ -290,7 +291,7 @@ public:
if(other.mode == any_policy::embedded) {
other.vtable(request::move, other, this);
} else if(other.mode != any_policy::empty) {
this->instance = std::exchange(other.instance, nullptr);
this->instance = stl::exchange(other.instance, nullptr);
}
vtable = other.vtable;
@@ -309,9 +310,9 @@ public:
* @return This any object.
*/
template<typename Type>
requires (!std::same_as<std::remove_cvref_t<Type>, basic_any>)
requires (!stl::same_as<stl::remove_cvref_t<Type>, basic_any>)
basic_any &operator=(Type &&value) {
emplace<std::decay_t<Type>>(std::forward<Type>(value));
emplace<stl::decay_t<Type>>(stl::forward<Type>(value));
return *this;
}
@@ -382,7 +383,7 @@ public:
*/
template<typename Type>
[[nodiscard]] const Type *data() const noexcept {
return has_value<std::remove_const_t<Type>>() ? static_cast<const Type *>(data()) : nullptr;
return has_value<stl::remove_const_t<Type>>() ? static_cast<const Type *>(data()) : nullptr;
}
/**
@@ -390,7 +391,7 @@ public:
* @return An opaque pointer the contained instance, if any.
*/
[[nodiscard]] void *data() noexcept {
return (mode == any_policy::cref) ? nullptr : const_cast<void *>(std::as_const(*this).data());
return (mode == any_policy::cref) ? nullptr : const_cast<void *>(stl::as_const(*this).data());
}
/**
@@ -399,7 +400,7 @@ public:
* @return An opaque pointer the contained instance, if any.
*/
[[nodiscard]] void *data(const type_info &req) noexcept {
return (mode == any_policy::cref) ? nullptr : const_cast<void *>(std::as_const(*this).data(req));
return (mode == any_policy::cref) ? nullptr : const_cast<void *>(stl::as_const(*this).data(req));
}
/**
@@ -409,10 +410,10 @@ public:
*/
template<typename Type>
[[nodiscard]] Type *data() noexcept {
if constexpr(std::is_const_v<Type>) {
return std::as_const(*this).template data<std::remove_const_t<Type>>();
if constexpr(stl::is_const_v<Type>) {
return stl::as_const(*this).template data<stl::remove_const_t<Type>>();
} else {
return (mode == any_policy::cref) ? nullptr : const_cast<Type *>(std::as_const(*this).template data<std::remove_const_t<Type>>());
return (mode == any_policy::cref) ? nullptr : const_cast<Type *>(stl::as_const(*this).template data<stl::remove_const_t<Type>>());
}
}
@@ -425,7 +426,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)...);
}
/**
@@ -445,7 +446,7 @@ public:
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
bool assign(basic_any &&other) {
if(other && (mode != any_policy::cref) && (underlying_type == other.underlying_type)) {
return (other.mode == any_policy::cref) ? (vtable(request::assign, *this, std::as_const(other).data()) != nullptr) : (vtable(request::transfer, *this, other.data()) != nullptr);
return (other.mode == any_policy::cref) ? (vtable(request::assign, *this, stl::as_const(other).data()) != nullptr) : (vtable(request::transfer, *this, other.data()) != nullptr);
}
return false;
@@ -483,7 +484,7 @@ public:
* @return A wrapper that shares a reference to an unmanaged object.
*/
[[nodiscard]] basic_any as_ref() noexcept {
basic_any other = std::as_const(*this).as_ref();
basic_any other = stl::as_const(*this).as_ref();
switch(mode) {
using enum any_policy;
@@ -540,51 +541,51 @@ private:
* @param data Target any object.
* @return The element converted to the requested type.
*/
template<typename Type, std::size_t Len, std::size_t Align>
[[nodiscard]] std::remove_const_t<Type> any_cast(const basic_any<Len, Align> &data) noexcept {
const auto *const instance = any_cast<std::remove_reference_t<Type>>(&data);
template<typename Type, stl::size_t Len, stl::size_t Align>
[[nodiscard]] stl::remove_const_t<Type> any_cast(const basic_any<Len, Align> &data) noexcept {
const auto *const instance = any_cast<stl::remove_reference_t<Type>>(&data);
ENTT_ASSERT(instance, "Invalid instance");
return static_cast<Type>(*instance);
}
/*! @copydoc any_cast */
template<typename Type, std::size_t Len, std::size_t Align>
[[nodiscard]] std::remove_const_t<Type> any_cast(basic_any<Len, Align> &data) noexcept {
template<typename Type, stl::size_t Len, stl::size_t Align>
[[nodiscard]] stl::remove_const_t<Type> any_cast(basic_any<Len, Align> &data) noexcept {
// forces const on non-reference types to make them work also with wrappers for const references
auto *const instance = any_cast<std::remove_reference_t<const Type>>(&data);
auto *const instance = any_cast<stl::remove_reference_t<const Type>>(&data);
ENTT_ASSERT(instance, "Invalid instance");
return static_cast<Type>(*instance);
}
/*! @copydoc any_cast */
template<typename Type, std::size_t Len, std::size_t Align>
template<typename Type, stl::size_t Len, stl::size_t Align>
// NOLINTNEXTLINE(cppcoreguidelines-rvalue-reference-param-not-moved)
[[nodiscard]] std::remove_const_t<Type> any_cast(basic_any<Len, Align> &&data) noexcept {
if constexpr(std::is_copy_constructible_v<std::remove_cvref_t<Type>>) {
if(auto *const instance = any_cast<std::remove_reference_t<Type>>(&data); instance) {
return static_cast<Type>(std::move(*instance));
[[nodiscard]] stl::remove_const_t<Type> any_cast(basic_any<Len, Align> &&data) noexcept {
if constexpr(stl::is_copy_constructible_v<stl::remove_cvref_t<Type>>) {
if(auto *const instance = any_cast<stl::remove_reference_t<Type>>(&data); instance) {
return static_cast<Type>(stl::move(*instance));
}
return any_cast<Type>(data);
} else {
auto *const instance = any_cast<std::remove_reference_t<Type>>(&data);
auto *const instance = any_cast<stl::remove_reference_t<Type>>(&data);
ENTT_ASSERT(instance, "Invalid instance");
return static_cast<Type>(std::move(*instance));
return static_cast<Type>(stl::move(*instance));
}
}
/*! @copydoc any_cast */
template<typename Type, std::size_t Len, std::size_t Align>
template<typename Type, stl::size_t Len, stl::size_t Align>
[[nodiscard]] const Type *any_cast(const basic_any<Len, Align> *data) noexcept {
return data->template data<std::remove_const_t<Type>>();
return data->template data<stl::remove_const_t<Type>>();
}
/*! @copydoc any_cast */
template<typename Type, std::size_t Len, std::size_t Align>
template<typename Type, stl::size_t Len, stl::size_t Align>
[[nodiscard]] Type *any_cast(basic_any<Len, Align> *data) noexcept {
if constexpr(std::is_const_v<Type>) {
if constexpr(stl::is_const_v<Type>) {
// last attempt to make wrappers for const references return their values
return any_cast<Type>(&std::as_const(*data));
return any_cast<Type>(&stl::as_const(*data));
} else {
return data->template data<Type>();
}
@@ -599,9 +600,9 @@ template<typename Type, std::size_t Len, std::size_t Align>
* @param args Parameters to use to construct the instance.
* @return A properly initialized wrapper for an object of the given type.
*/
template<typename Type, std::size_t Len = basic_any<>::length, std::size_t Align = basic_any<Len>::alignment, typename... Args>
template<typename Type, stl::size_t Len = basic_any<>::length, stl::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>{stl::in_place_type<Type>, stl::forward<Args>(args)...};
}
/**
@@ -612,9 +613,9 @@ template<typename Type, std::size_t Len = basic_any<>::length, std::size_t Align
* @param value Parameter to use to construct the instance.
* @return A properly initialized and not necessarily owning wrapper.
*/
template<std::size_t Len = basic_any<>::length, std::size_t Align = basic_any<Len>::alignment, typename Type>
template<stl::size_t Len = basic_any<>::length, stl::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>{stl::in_place_type<Type &&>, stl::forward<Type>(value)};
}
} // namespace entt

View File

@@ -1,10 +1,10 @@
#ifndef ENTT_CORE_BIT_HPP
#define ENTT_CORE_BIT_HPP
#include <bit>
#include <concepts>
#include <cstddef>
#include "../config/config.h"
#include "../stl/bit.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
namespace entt {
@@ -15,9 +15,9 @@ namespace entt {
* @param mod _Modulus_, it must be a power of two.
* @return The common remainder.
*/
template<std::unsigned_integral Type>
[[nodiscard]] constexpr Type fast_mod(const Type value, const std::size_t mod) noexcept {
ENTT_ASSERT_CONSTEXPR(std::has_single_bit(mod), "Value must be a power of two");
template<stl::unsigned_integral Type>
[[nodiscard]] constexpr Type fast_mod(const Type value, const stl::size_t mod) noexcept {
ENTT_ASSERT_CONSTEXPR(stl::has_single_bit(mod), "Value must be a power of two");
return static_cast<Type>(value & (mod - 1u));
}

View File

@@ -1,11 +1,11 @@
#ifndef ENTT_CORE_COMPRESSED_PAIR_HPP
#define ENTT_CORE_COMPRESSED_PAIR_HPP
#include <concepts>
#include <cstddef>
#include <tuple>
#include <type_traits>
#include <utility>
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/tuple.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "fwd.hpp"
#include "type_traits.hpp"
@@ -14,23 +14,23 @@ namespace entt {
/*! @cond ENTT_INTERNAL */
namespace internal {
template<typename Type, std::size_t>
template<typename Type, stl::size_t>
struct compressed_pair_element {
using reference = Type &;
using const_reference = const Type &;
// NOLINTNEXTLINE(modernize-use-equals-default)
constexpr compressed_pair_element() noexcept(std::is_nothrow_default_constructible_v<Type>)
requires std::default_initializable<Type> {}
constexpr compressed_pair_element() noexcept(stl::is_nothrow_default_constructible_v<Type>)
requires stl::default_initializable<Type> {}
template<typename Arg>
constexpr compressed_pair_element(Arg &&arg) noexcept(std::is_nothrow_constructible_v<Type, Arg>)
requires (!std::same_as<std::remove_cvref_t<Arg>, compressed_pair_element>)
: value{std::forward<Arg>(arg)} {}
constexpr compressed_pair_element(Arg &&arg) noexcept(stl::is_nothrow_constructible_v<Type, Arg>)
requires (!stl::same_as<stl::remove_cvref_t<Arg>, compressed_pair_element>)
: value{stl::forward<Arg>(arg)} {}
template<typename... Args, std::size_t... Index>
constexpr compressed_pair_element(std::tuple<Args...> args, std::index_sequence<Index...>) noexcept(std::is_nothrow_constructible_v<Type, Args...>)
: value{std::forward<Args>(std::get<Index>(args))...} {}
template<typename... Args, stl::size_t... Index>
constexpr compressed_pair_element(stl::tuple<Args...> args, stl::index_sequence<Index...>) noexcept(stl::is_nothrow_constructible_v<Type, Args...>)
: value{stl::forward<Args>(stl::get<Index>(args))...} {}
[[nodiscard]] constexpr reference get() noexcept {
return value;
@@ -44,25 +44,25 @@ private:
Type value{};
};
template<typename Type, std::size_t Tag>
template<typename Type, stl::size_t Tag>
requires is_ebco_eligible_v<Type>
struct compressed_pair_element<Type, Tag>: Type {
using reference = Type &;
using const_reference = const Type &;
using base_type = Type;
constexpr compressed_pair_element() noexcept(std::is_nothrow_default_constructible_v<base_type>)
requires std::default_initializable<Type>
constexpr compressed_pair_element() noexcept(stl::is_nothrow_default_constructible_v<base_type>)
requires stl::default_initializable<Type>
: base_type{} {}
template<typename Arg>
constexpr compressed_pair_element(Arg &&arg) noexcept(std::is_nothrow_constructible_v<base_type, Arg>)
requires (!std::same_as<std::remove_cvref_t<Arg>, compressed_pair_element>)
: base_type{std::forward<Arg>(arg)} {}
constexpr compressed_pair_element(Arg &&arg) noexcept(stl::is_nothrow_constructible_v<base_type, Arg>)
requires (!stl::same_as<stl::remove_cvref_t<Arg>, compressed_pair_element>)
: base_type{stl::forward<Arg>(arg)} {}
template<typename... Args, std::size_t... Index>
constexpr compressed_pair_element(std::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))...} {}
template<typename... Args, stl::size_t... Index>
constexpr compressed_pair_element(stl::tuple<Args...> args, stl::index_sequence<Index...>) noexcept(stl::is_nothrow_constructible_v<base_type, Args...>)
: base_type{stl::forward<Args>(stl::get<Index>(args))...} {}
[[nodiscard]] constexpr reference get() noexcept {
return *this;
@@ -104,8 +104,8 @@ public:
* This constructor is only available when the types that the pair stores
* are both at least default constructible.
*/
constexpr compressed_pair() noexcept(std::is_nothrow_default_constructible_v<first_base> && std::is_nothrow_default_constructible_v<second_base>)
requires std::default_initializable<first_type> && std::default_initializable<second_type>
constexpr compressed_pair() noexcept(stl::is_nothrow_default_constructible_v<first_base> && stl::is_nothrow_default_constructible_v<second_base>)
requires stl::default_initializable<first_type> && stl::default_initializable<second_type>
: first_base{},
second_base{} {}
@@ -129,9 +129,9 @@ public:
* @param other Value to use to initialize the second element.
*/
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)} {}
constexpr compressed_pair(Arg &&arg, Other &&other) noexcept(stl::is_nothrow_constructible_v<first_base, Arg> && stl::is_nothrow_constructible_v<second_base, Other>)
: first_base{stl::forward<Arg>(arg)},
second_base{stl::forward<Other>(other)} {}
/**
* @brief Constructs a pair by forwarding the arguments to its parts.
@@ -141,9 +141,9 @@ public:
* @param other Arguments to use to initialize the second element.
*/
template<typename... Args, typename... Other>
constexpr compressed_pair(std::piecewise_construct_t, std::tuple<Args...> args, std::tuple<Other...> other) noexcept(std::is_nothrow_constructible_v<first_base, Args...> && std::is_nothrow_constructible_v<second_base, Other...>)
: first_base{std::move(args), std::index_sequence_for<Args...>{}},
second_base{std::move(other), std::index_sequence_for<Other...>{}} {}
constexpr compressed_pair(stl::piecewise_construct_t, stl::tuple<Args...> args, stl::tuple<Other...> other) noexcept(stl::is_nothrow_constructible_v<first_base, Args...> && stl::is_nothrow_constructible_v<second_base, Other...>)
: first_base{stl::move(args), stl::index_sequence_for<Args...>{}},
second_base{stl::move(other), stl::index_sequence_for<Other...>{}} {}
/*! @brief Default destructor. */
~compressed_pair() = default;
@@ -193,7 +193,7 @@ public:
* @param other The compressed pair to swap with.
*/
constexpr void swap(compressed_pair &other) noexcept {
using std::swap;
using stl::swap;
swap(first(), other.first());
swap(second(), other.second());
}
@@ -204,7 +204,7 @@ public:
* @return Returns a reference to the first element if `Index` is 0 and a
* reference to the second element if `Index` is 1.
*/
template<std::size_t Index>
template<stl::size_t Index>
requires (Index <= 1u)
[[nodiscard]] constexpr decltype(auto) get() noexcept {
if constexpr(Index == 0u) {
@@ -215,7 +215,7 @@ public:
}
/*! @copydoc get */
template<std::size_t Index>
template<stl::size_t Index>
requires (Index <= 1u)
[[nodiscard]] constexpr decltype(auto) get() const noexcept {
if constexpr(Index == 0u) {
@@ -232,7 +232,7 @@ public:
* @tparam Other Type of value to use to initialize the second element.
*/
template<typename Type, typename Other>
compressed_pair(Type &&, Other &&) -> compressed_pair<std::decay_t<Type>, std::decay_t<Other>>;
compressed_pair(Type &&, Other &&) -> compressed_pair<stl::decay_t<Type>, stl::decay_t<Other>>;
/**
* @brief Swaps two compressed pair objects.
@@ -248,26 +248,19 @@ constexpr void swap(compressed_pair<First, Second> &lhs, compressed_pair<First,
} // namespace entt
/*! @cond ENTT_INTERNAL */
#include <utility>
namespace std {
/**
* @brief `std::tuple_size` specialization for `compressed_pair`s.
* @tparam First The type of the first element that the pair stores.
* @tparam Second The type of the second element that the pair stores.
*/
template<typename First, typename Second>
struct tuple_size<entt::compressed_pair<First, Second>>: integral_constant<size_t, 2u> {};
struct tuple_size<entt::compressed_pair<First, Second>>: integral_constant<entt::stl::size_t, 2u> {};
/**
* @brief `std::tuple_element` specialization for `compressed_pair`s.
* @tparam Index The index of the type to return.
* @tparam First The type of the first element that the pair stores.
* @tparam Second The type of the second element that the pair stores.
*/
template<size_t Index, typename First, typename Second>
template<entt::stl::size_t Index, typename First, typename Second>
requires (Index <= 1u)
struct tuple_element<Index, entt::compressed_pair<First, Second>>: conditional<Index == 0u, First, Second> {};
} // namespace std
/*! @endcond */
#endif

View File

@@ -1,7 +1,7 @@
#ifndef ENTT_CORE_CONCEPTS_HPP
#define ENTT_CORE_CONCEPTS_HPP
#include <type_traits>
#include "../stl/type_traits.hpp"
namespace entt {
@@ -10,7 +10,7 @@ namespace entt {
* @tparam Type Type to check.
*/
template<typename Type>
concept cvref_unqualified = std::is_same_v<std::remove_cvref_t<Type>, Type>;
concept cvref_unqualified = stl::is_same_v<stl::remove_cvref_t<Type>, Type>;
} // namespace entt

View File

@@ -1,8 +1,8 @@
#ifndef ENTT_CORE_ENUM_HPP
#define ENTT_CORE_ENUM_HPP
#include <concepts>
#include <type_traits>
#include "../stl/concepts.hpp"
#include "../stl/type_traits.hpp"
namespace entt {
@@ -11,15 +11,15 @@ namespace entt {
* @tparam Type The enum type for which to enable bitmask support.
*/
template<typename Type>
struct enum_as_bitmask: std::false_type {};
struct enum_as_bitmask: stl::false_type {};
/*! @copydoc enum_as_bitmask */
template<typename Type>
requires requires {
requires std::is_enum_v<Type>;
{ Type::_entt_enum_as_bitmask } -> std::same_as<Type>;
requires stl::is_enum_v<Type>;
{ Type::_entt_enum_as_bitmask } -> stl::same_as<Type>;
}
struct enum_as_bitmask<Type>: std::true_type {};
struct enum_as_bitmask<Type>: stl::true_type {};
/**
* @brief Helper variable template.
@@ -34,7 +34,7 @@ inline constexpr bool enum_as_bitmask_v = enum_as_bitmask<Type>::value;
*/
template<typename Type>
// check again that it is an enum to deal with incorrect specializations
concept enum_bitmask = std::is_enum_v<Type> && enum_as_bitmask_v<Type>;
concept enum_bitmask = stl::is_enum_v<Type> && enum_as_bitmask_v<Type>;
} // namespace entt
@@ -48,19 +48,19 @@ concept enum_bitmask = std::is_enum_v<Type> && enum_as_bitmask_v<Type>;
*/
template<entt::enum_bitmask Type>
[[nodiscard]] constexpr Type operator|(const Type lhs, const Type rhs) noexcept {
return static_cast<Type>(static_cast<std::underlying_type_t<Type>>(lhs) | static_cast<std::underlying_type_t<Type>>(rhs));
return static_cast<Type>(static_cast<entt::stl::underlying_type_t<Type>>(lhs) | static_cast<entt::stl::underlying_type_t<Type>>(rhs));
}
/*! @copydoc operator| */
template<entt::enum_bitmask Type>
[[nodiscard]] constexpr Type operator&(const Type lhs, const Type rhs) noexcept {
return static_cast<Type>(static_cast<std::underlying_type_t<Type>>(lhs) & static_cast<std::underlying_type_t<Type>>(rhs));
return static_cast<Type>(static_cast<entt::stl::underlying_type_t<Type>>(lhs) & static_cast<entt::stl::underlying_type_t<Type>>(rhs));
}
/*! @copydoc operator| */
template<entt::enum_bitmask Type>
[[nodiscard]] constexpr Type operator^(const Type lhs, const Type rhs) noexcept {
return static_cast<Type>(static_cast<std::underlying_type_t<Type>>(lhs) ^ static_cast<std::underlying_type_t<Type>>(rhs));
return static_cast<Type>(static_cast<entt::stl::underlying_type_t<Type>>(lhs) ^ static_cast<entt::stl::underlying_type_t<Type>>(rhs));
}
/**
@@ -72,13 +72,13 @@ template<entt::enum_bitmask Type>
*/
template<entt::enum_bitmask Type>
[[nodiscard]] constexpr Type operator~(const Type value) noexcept {
return static_cast<Type>(~static_cast<std::underlying_type_t<Type>>(value));
return static_cast<Type>(~static_cast<entt::stl::underlying_type_t<Type>>(value));
}
/*! @copydoc operator~ */
template<entt::enum_bitmask Type>
[[nodiscard]] constexpr bool operator!(const Type value) noexcept {
return !static_cast<std::underlying_type_t<Type>>(value);
return !static_cast<entt::stl::underlying_type_t<Type>>(value);
}
/*! @copydoc operator| */

View File

@@ -1,14 +1,14 @@
#ifndef ENTT_CORE_FWD_HPP
#define ENTT_CORE_FWD_HPP
#include <cstddef>
#include <cstdint>
#include "../config/config.h"
#include "../stl/cstddef.hpp"
#include "../stl/cstdint.hpp"
namespace entt {
/*! @brief Possible modes of an any object. */
enum class any_policy : std::uint8_t {
enum class any_policy : stl::uint8_t {
/*! @brief Default mode, no element available. */
empty,
/*! @brief Owning mode, dynamically allocated element. */
@@ -22,7 +22,7 @@ enum class any_policy : std::uint8_t {
};
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
template<std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
template<stl::size_t Len = sizeof(double[2]), stl::size_t = alignof(double[2])>
class basic_any;
/*! @brief Alias declaration for type identifiers. */

View File

@@ -1,8 +1,8 @@
#ifndef ENTT_CORE_HASHED_STRING_HPP
#define ENTT_CORE_HASHED_STRING_HPP
#include <cstddef>
#include <cstdint>
#include "../stl/cstddef.hpp"
#include "../stl/cstdint.hpp"
#include "fwd.hpp"
namespace entt {
@@ -14,13 +14,13 @@ template<typename = id_type>
struct fnv_1a_params;
template<>
struct fnv_1a_params<std::uint32_t> {
struct fnv_1a_params<stl::uint32_t> {
static constexpr auto offset = 2166136261;
static constexpr auto prime = 16777619;
};
template<>
struct fnv_1a_params<std::uint64_t> {
struct fnv_1a_params<stl::uint64_t> {
static constexpr auto offset = 14695981039346656037ull;
static constexpr auto prime = 1099511628211ull;
};
@@ -28,7 +28,7 @@ struct fnv_1a_params<std::uint64_t> {
template<typename Char>
struct basic_hashed_string {
using value_type = Char;
using size_type = std::size_t;
using size_type = stl::size_t;
using hash_type = id_type;
const value_type *repr{};
@@ -91,7 +91,7 @@ public:
* @param str Human-readable identifier.
* @return The numeric representation of the string.
*/
template<std::size_t N>
template<stl::size_t N>
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
[[nodiscard]] static ENTT_CONSTEVAL hash_type value(const value_type (&str)[N]) noexcept {
return basic_hashed_string{str};
@@ -130,7 +130,7 @@ public:
* @tparam N Number of characters of the identifier.
* @param str Human-readable identifier.
*/
template<std::size_t N>
template<stl::size_t N>
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
ENTT_CONSTEVAL basic_hashed_string(const value_type (&str)[N]) noexcept
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-array-to-pointer-decay)
@@ -221,7 +221,7 @@ public:
* @param len Length of the string to hash.
*/
template<typename Char>
basic_hashed_string(const Char *str, std::size_t len) -> basic_hashed_string<Char>;
basic_hashed_string(const Char *str, stl::size_t len) -> basic_hashed_string<Char>;
/**
* @brief Deduction guide.
@@ -229,7 +229,7 @@ basic_hashed_string(const Char *str, std::size_t len) -> basic_hashed_string<Cha
* @tparam N Number of characters of the identifier.
* @param str Human-readable identifier.
*/
template<typename Char, std::size_t N>
template<typename Char, stl::size_t N>
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
basic_hashed_string(const Char (&str)[N]) -> basic_hashed_string<Char>;
@@ -240,7 +240,7 @@ inline namespace literals {
* @param str The literal without its suffix.
* @return A properly initialized hashed string.
*/
[[nodiscard]] ENTT_CONSTEVAL hashed_string operator""_hs(const char *str, std::size_t) noexcept {
[[nodiscard]] ENTT_CONSTEVAL hashed_string operator""_hs(const char *str, stl::size_t) noexcept {
return hashed_string{str};
}
@@ -249,7 +249,7 @@ inline namespace literals {
* @param str The literal without its suffix.
* @return A properly initialized hashed wstring.
*/
[[nodiscard]] ENTT_CONSTEVAL hashed_wstring operator""_hws(const wchar_t *str, std::size_t) noexcept {
[[nodiscard]] ENTT_CONSTEVAL hashed_wstring operator""_hws(const wchar_t *str, stl::size_t) noexcept {
return hashed_wstring{str};
}

View File

@@ -1,9 +1,9 @@
#ifndef ENTT_CORE_IDENT_HPP
#define ENTT_CORE_IDENT_HPP
#include <cstddef>
#include <type_traits>
#include <utility>
#include "../stl/cstddef.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "fwd.hpp"
#include "type_traits.hpp"
@@ -15,9 +15,9 @@ namespace entt {
*/
template<typename... Type>
class ident {
template<typename Curr, std::size_t... Index>
[[nodiscard]] static ENTT_CONSTEVAL id_type get(std::index_sequence<Index...>) noexcept {
return (0 + ... + (std::is_same_v<Curr, type_list_element_t<Index, type_list<std::decay_t<Type>...>>> ? id_type{Index} : id_type{}));
template<typename Curr, stl::size_t... Index>
[[nodiscard]] static ENTT_CONSTEVAL id_type get(stl::index_sequence<Index...>) noexcept {
return (0 + ... + (stl::is_same_v<Curr, type_list_element_t<Index, type_list<stl::decay_t<Type>...>>> ? id_type{Index} : id_type{}));
}
public:
@@ -26,8 +26,8 @@ public:
/*! @brief Statically generated unique identifier for the given type. */
template<typename Curr>
requires (std::is_same_v<std::remove_cvref_t<Curr>, Type> || ...)
static constexpr value_type value = get<std::remove_cvref_t<Curr>>(std::index_sequence_for<Type...>{});
requires (stl::is_same_v<stl::remove_cvref_t<Curr>, Type> || ...)
static constexpr value_type value = get<stl::remove_cvref_t<Curr>>(stl::index_sequence_for<Type...>{});
};
} // namespace entt

View File

@@ -1,12 +1,12 @@
#ifndef ENTT_CORE_ITERATOR_HPP
#define ENTT_CORE_ITERATOR_HPP
#include <concepts>
#include <iterator>
#include <memory>
#include <type_traits>
#include <utility>
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/iterator.hpp"
#include "../stl/memory.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
namespace entt {
@@ -27,15 +27,15 @@ struct input_iterator_pointer final {
* @brief Constructs a proxy object by move.
* @param val Value to use to initialize the proxy object.
*/
constexpr input_iterator_pointer(value_type &&val) noexcept(std::is_nothrow_move_constructible_v<value_type>)
: value{std::move(val)} {}
constexpr input_iterator_pointer(value_type &&val) noexcept(stl::is_nothrow_move_constructible_v<value_type>)
: value{stl::move(val)} {}
/**
* @brief Access operator for accessing wrapped values.
* @return A pointer to the wrapped value.
*/
[[nodiscard]] constexpr pointer operator->() noexcept {
return std::addressof(value);
return stl::addressof(value);
}
/**
@@ -54,7 +54,7 @@ private:
* @brief Plain iota iterator (waiting for C++20).
* @tparam Type Value type.
*/
template<std::integral Type>
template<stl::integral Type>
struct iota_iterator final {
/*! @brief Value type, likely an integral one. */
using value_type = Type;
@@ -63,9 +63,9 @@ struct iota_iterator final {
/*! @brief Non-reference type, same as value type. */
using reference = value_type;
/*! @brief Difference type. */
using difference_type = std::ptrdiff_t;
using difference_type = stl::ptrdiff_t;
/*! @brief Iterator category. */
using iterator_category = std::input_iterator_tag;
using iterator_category = stl::input_iterator_tag;
/*! @brief Default constructor. */
constexpr iota_iterator() noexcept
@@ -124,14 +124,14 @@ private:
template<stl::input_or_output_iterator It, stl::sentinel_for<It> Sentinel = It>
struct iterable_adaptor final {
/*! @brief Value type. */
using value_type = std::iterator_traits<It>::value_type;
using value_type = stl::iterator_traits<It>::value_type;
/*! @brief Iterator type. */
using iterator = It;
/*! @brief Sentinel type. */
using sentinel = Sentinel;
/*! @brief Default constructor. */
constexpr iterable_adaptor() noexcept(std::is_nothrow_default_constructible_v<iterator> && std::is_nothrow_default_constructible_v<sentinel>)
constexpr iterable_adaptor() noexcept(stl::is_nothrow_default_constructible_v<iterator> && stl::is_nothrow_default_constructible_v<sentinel>)
: first{},
last{} {}
@@ -140,9 +140,9 @@ struct iterable_adaptor final {
* @param from Begin iterator.
* @param to End iterator.
*/
constexpr iterable_adaptor(iterator from, sentinel to) noexcept(std::is_nothrow_move_constructible_v<iterator> && std::is_nothrow_move_constructible_v<sentinel>)
: first{std::move(from)},
last{std::move(to)} {}
constexpr iterable_adaptor(iterator from, sentinel to) noexcept(stl::is_nothrow_move_constructible_v<iterator> && stl::is_nothrow_move_constructible_v<sentinel>)
: first{stl::move(from)},
last{stl::move(to)} {}
/**
* @brief Returns an iterator to the beginning.

View File

@@ -1,13 +1,12 @@
#ifndef ENTT_CORE_MEMORY_HPP
#define ENTT_CORE_MEMORY_HPP
#include <cstddef>
#include <memory>
#include <tuple>
#include <type_traits>
#include <utility>
#include "../config/config.h"
#include "../stl/cstddef.hpp"
#include "../stl/memory.hpp"
#include "../stl/tuple.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
namespace entt {
@@ -19,7 +18,7 @@ namespace entt {
*/
template<typename Allocator>
constexpr void propagate_on_container_copy_assignment([[maybe_unused]] Allocator &lhs, [[maybe_unused]] Allocator &rhs) noexcept {
if constexpr(std::allocator_traits<Allocator>::propagate_on_container_copy_assignment::value) {
if constexpr(stl::allocator_traits<Allocator>::propagate_on_container_copy_assignment::value) {
lhs = rhs;
}
}
@@ -32,8 +31,8 @@ constexpr void propagate_on_container_copy_assignment([[maybe_unused]] Allocator
*/
template<typename Allocator>
constexpr void propagate_on_container_move_assignment([[maybe_unused]] Allocator &lhs, [[maybe_unused]] Allocator &rhs) noexcept {
if constexpr(std::allocator_traits<Allocator>::propagate_on_container_move_assignment::value) {
lhs = std::move(rhs);
if constexpr(stl::allocator_traits<Allocator>::propagate_on_container_move_assignment::value) {
lhs = stl::move(rhs);
}
}
@@ -45,8 +44,8 @@ constexpr void propagate_on_container_move_assignment([[maybe_unused]] Allocator
*/
template<typename Allocator>
constexpr void propagate_on_container_swap([[maybe_unused]] Allocator &lhs, [[maybe_unused]] Allocator &rhs) noexcept {
if constexpr(std::allocator_traits<Allocator>::propagate_on_container_swap::value) {
using std::swap;
if constexpr(stl::allocator_traits<Allocator>::propagate_on_container_swap::value) {
using stl::swap;
swap(lhs, rhs);
} else {
ENTT_ASSERT_CONSTEXPR(lhs == rhs, "Cannot swap the containers");
@@ -62,28 +61,28 @@ struct allocation_deleter: private Allocator {
/*! @brief Allocator type. */
using allocator_type = Allocator;
/*! @brief Pointer type. */
using pointer = std::allocator_traits<Allocator>::pointer;
using pointer = stl::allocator_traits<Allocator>::pointer;
/**
* @brief Inherited constructors.
* @param alloc The allocator to use.
*/
constexpr allocation_deleter(const allocator_type &alloc) noexcept(std::is_nothrow_copy_constructible_v<allocator_type>)
constexpr allocation_deleter(const allocator_type &alloc) noexcept(stl::is_nothrow_copy_constructible_v<allocator_type>)
: Allocator{alloc} {}
/**
* @brief Destroys the pointed object and deallocates its memory.
* @param ptr A valid pointer to an object of the given type.
*/
constexpr void operator()(pointer ptr) noexcept(std::is_nothrow_destructible_v<typename allocator_type::value_type>) {
using alloc_traits = std::allocator_traits<Allocator>;
constexpr void operator()(pointer ptr) noexcept(stl::is_nothrow_destructible_v<typename allocator_type::value_type>) {
using alloc_traits = stl::allocator_traits<Allocator>;
alloc_traits::destroy(*this, stl::to_address(ptr));
alloc_traits::deallocate(*this, ptr, 1u);
}
};
/**
* @brief Allows `std::unique_ptr` to use allocators (waiting for C++20).
* @brief Allows `stl::unique_ptr` to use allocators (waiting for C++20).
* @tparam Type Type of object to allocate for and to construct.
* @tparam Allocator Type of allocator used to manage memory and elements.
* @tparam Args Types of arguments to use to construct the object.
@@ -93,23 +92,23 @@ struct allocation_deleter: private Allocator {
*/
template<typename Type, typename Allocator, typename... Args>
constexpr auto allocate_unique(Allocator &allocator, Args &&...args) {
static_assert(!std::is_array_v<Type>, "Array types are not supported");
static_assert(!stl::is_array_v<Type>, "Array types are not supported");
using alloc_traits = std::allocator_traits<Allocator>::template rebind_traits<Type>;
using alloc_traits = stl::allocator_traits<Allocator>::template rebind_traits<Type>;
using allocator_type = alloc_traits::allocator_type;
allocator_type alloc{allocator};
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);
ENTT_THROW;
}
return std::unique_ptr<Type, allocation_deleter<allocator_type>>{ptr, alloc};
return stl::unique_ptr<Type, allocation_deleter<allocator_type>>{ptr, alloc};
}
/*! @cond ENTT_INTERNAL */
@@ -119,50 +118,50 @@ template<typename Type>
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 std::forward_as_tuple(std::forward<Params>(params)...);
if constexpr(!stl::uses_allocator_v<Type, Allocator> && stl::is_constructible_v<Type, Params...>) {
return stl::forward_as_tuple(stl::forward<Params>(params)...);
} else {
static_assert(std::uses_allocator_v<Type, Allocator>, "Ill-formed request");
static_assert(stl::uses_allocator_v<Type, Allocator>, "Ill-formed request");
if constexpr(std::is_constructible_v<Type, std::allocator_arg_t, const Allocator &, Params...>) {
return std::tuple<std::allocator_arg_t, const Allocator &, Params &&...>{std::allocator_arg, allocator, std::forward<Params>(params)...};
if constexpr(stl::is_constructible_v<Type, stl::allocator_arg_t, const Allocator &, Params...>) {
return stl::tuple<stl::allocator_arg_t, const Allocator &, Params &&...>{stl::allocator_arg, allocator, stl::forward<Params>(params)...};
} else {
static_assert(std::is_constructible_v<Type, Params..., const Allocator &>, "Ill-formed request");
return std::forward_as_tuple(std::forward<Params>(params)..., allocator);
static_assert(stl::is_constructible_v<Type, Params..., const Allocator &>, "Ill-formed request");
return stl::forward_as_tuple(stl::forward<Params>(params)..., allocator);
}
}
}
};
template<typename Type, typename Other>
struct uses_allocator_construction<std::pair<Type, Other>> {
using type = std::pair<Type, Other>;
struct uses_allocator_construction<stl::pair<Type, Other>> {
using type = stl::pair<Type, Other>;
template<typename First, typename Second>
static constexpr auto args(const auto &allocator, std::piecewise_construct_t, First &&first, Second &&second) noexcept {
return std::make_tuple(
std::piecewise_construct,
std::apply([&allocator](auto &&...curr) { return uses_allocator_construction<Type>::args(allocator, std::forward<decltype(curr)>(curr)...); }, std::forward<First>(first)),
std::apply([&allocator](auto &&...curr) { return uses_allocator_construction<Other>::args(allocator, std::forward<decltype(curr)>(curr)...); }, std::forward<Second>(second)));
static constexpr auto args(const auto &allocator, stl::piecewise_construct_t, First &&first, Second &&second) noexcept {
return stl::make_tuple(
stl::piecewise_construct,
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 {
return uses_allocator_construction<type>::args(allocator, std::piecewise_construct, std::tuple<>{}, std::tuple<>{});
return uses_allocator_construction<type>::args(allocator, stl::piecewise_construct, stl::tuple<>{}, stl::tuple<>{});
}
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, std::forward_as_tuple(std::forward<First>(first)), std::forward_as_tuple(std::forward<Second>(second)));
return uses_allocator_construction<type>::args(allocator, stl::piecewise_construct, stl::forward_as_tuple(stl::forward<First>(first)), stl::forward_as_tuple(stl::forward<Second>(second)));
}
template<typename First, typename Second>
static constexpr auto args(const auto &allocator, const std::pair<First, Second> &value) noexcept {
return uses_allocator_construction<type>::args(allocator, std::piecewise_construct, std::forward_as_tuple(value.first), std::forward_as_tuple(value.second));
static constexpr auto args(const auto &allocator, const stl::pair<First, Second> &value) noexcept {
return uses_allocator_construction<type>::args(allocator, stl::piecewise_construct, stl::forward_as_tuple(value.first), stl::forward_as_tuple(value.second));
}
template<typename First, typename Second>
static constexpr auto args(const auto &allocator, std::pair<First, Second> &&value) noexcept {
return uses_allocator_construction<type>::args(allocator, std::piecewise_construct, std::forward_as_tuple(std::move(value.first)), std::forward_as_tuple(std::move(value.second)));
static constexpr auto args(const auto &allocator, stl::pair<First, Second> &&value) noexcept {
return uses_allocator_construction<type>::args(allocator, stl::piecewise_construct, stl::forward_as_tuple(stl::move(value.first)), stl::forward_as_tuple(stl::move(value.second)));
}
};
@@ -183,7 +182,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 +199,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 stl::make_from_tuple<Type>(internal::uses_allocator_construction<Type>::args(allocator, stl::forward<Args>(args)...));
}
/**
@@ -218,7 +217,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 std::apply([value](auto &&...curr) { return ::new(value) Type(std::forward<decltype(curr)>(curr)...); }, internal::uses_allocator_construction<Type>::args(allocator, std::forward<Args>(args)...));
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

View File

@@ -1,20 +1,22 @@
#ifndef ENTT_CORE_RANGES_HPP
#define ENTT_CORE_RANGES_HPP
#if __has_include(<version>)
# include <version>
#
# if defined(__cpp_lib_ranges)
# include <ranges>
# include "iterator.hpp"
#include <version>
#if defined(__cpp_lib_ranges)
# include <ranges>
# include "iterator.hpp"
namespace std::ranges {
template<class... Args>
inline constexpr bool std::ranges::enable_borrowed_range<entt::iterable_adaptor<Args...>>{true};
inline constexpr bool enable_borrowed_range<entt::iterable_adaptor<Args...>>{true};
template<class... Args>
inline constexpr bool std::ranges::enable_view<entt::iterable_adaptor<Args...>>{true};
inline constexpr bool enable_view<entt::iterable_adaptor<Args...>>{true};
} // namespace std::ranges
# endif
#endif
#endif
#endif

View File

@@ -1,9 +1,9 @@
#ifndef ENTT_CORE_TUPLE_HPP
#define ENTT_CORE_TUPLE_HPP
#include <tuple>
#include <type_traits>
#include <utility>
#include "../stl/tuple.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
namespace entt {
@@ -13,14 +13,14 @@ namespace entt {
* @tparam Type The type to test.
*/
template<typename Type>
struct is_tuple: std::false_type {};
struct is_tuple: stl::false_type {};
/**
* @copybrief is_tuple
* @tparam Args Tuple template arguments.
*/
template<typename... Args>
struct is_tuple<std::tuple<Args...>>: std::true_type {};
struct is_tuple<stl::tuple<Args...>>: stl::true_type {};
/**
* @brief Helper variable template.
@@ -38,10 +38,10 @@ inline constexpr bool is_tuple_v = is_tuple<Type>::value;
*/
template<typename Type>
constexpr decltype(auto) unwrap_tuple(Type &&value) noexcept {
if constexpr(std::tuple_size_v<std::remove_reference_t<Type>> == 1u) {
return std::get<0>(std::forward<Type>(value));
if constexpr(stl::tuple_size_v<stl::remove_reference_t<Type>> == 1u) {
return stl::get<0>(stl::forward<Type>(value));
} else {
return std::forward<Type>(value);
return stl::forward<Type>(value);
}
}
@@ -57,8 +57,8 @@ struct forward_apply: private Func {
* @param args Parameters to use to construct the instance.
*/
template<typename... Args>
constexpr forward_apply(Args &&...args) noexcept(std::is_nothrow_constructible_v<Func, Args...>)
: Func{std::forward<Args>(args)...} {}
constexpr forward_apply(Args &&...args) noexcept(stl::is_nothrow_constructible_v<Func, Args...>)
: Func{stl::forward<Args>(args)...} {}
/**
* @brief Forwards and applies the arguments with the underlying function.
@@ -67,14 +67,14 @@ struct forward_apply: private Func {
* @return Return value of the underlying function, if any.
*/
template<typename Type>
constexpr decltype(auto) operator()(Type &&args) noexcept(noexcept(std::apply(std::declval<Func &>(), args))) {
return std::apply(static_cast<Func &>(*this), std::forward<Type>(args));
constexpr decltype(auto) operator()(Type &&args) noexcept(noexcept(stl::apply(stl::declval<Func &>(), 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(std::apply(std::declval<const Func &>(), args))) {
return std::apply(static_cast<const Func &>(*this), std::forward<Type>(args));
constexpr decltype(auto) operator()(Type &&args) const noexcept(noexcept(stl::apply(stl::declval<const Func &>(), args))) {
return stl::apply(static_cast<const Func &>(*this), stl::forward<Type>(args));
}
};
@@ -83,7 +83,7 @@ struct forward_apply: private Func {
* @tparam Func Type of underlying invocable object.
*/
template<typename Func>
forward_apply(Func) -> forward_apply<std::remove_cvref_t<Func>>;
forward_apply(Func) -> forward_apply<stl::remove_cvref_t<Func>>;
} // namespace entt

View File

@@ -2,10 +2,10 @@
#define ENTT_CORE_TYPE_INFO_HPP
#include <compare>
#include <string_view>
#include <type_traits>
#include <utility>
#include "../config/config.h"
#include "../stl/string_view.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "fwd.hpp"
#include "hashed_string.hpp"
@@ -33,23 +33,23 @@ template<typename Type>
template<typename Type>
[[nodiscard]] constexpr auto stripped_type_name() noexcept {
#if defined ENTT_PRETTY_FUNCTION
const std::string_view full_name{pretty_function<Type>()};
const stl::string_view full_name{pretty_function<Type>()};
auto first = full_name.find_first_not_of(' ', full_name.find_first_of(ENTT_PRETTY_FUNCTION_PREFIX) + 1);
auto value = full_name.substr(first, full_name.find_last_of(ENTT_PRETTY_FUNCTION_SUFFIX) - first);
return value;
#else
return std::string_view{};
return stl::string_view{};
#endif
}
template<typename Type, auto = stripped_type_name<Type>().find_first_of('.')>
[[nodiscard]] ENTT_CONSTEVAL std::string_view type_name(int) noexcept {
[[nodiscard]] ENTT_CONSTEVAL stl::string_view type_name(int) noexcept {
constexpr auto value = stripped_type_name<Type>();
return value;
}
template<typename Type>
[[nodiscard]] std::string_view type_name(char) noexcept {
[[nodiscard]] stl::string_view type_name(char) noexcept {
static const auto value = stripped_type_name<Type>();
return value;
}
@@ -128,12 +128,12 @@ struct type_name final {
* @brief Returns the name of a given type.
* @return The name of the given type.
*/
[[nodiscard]] static constexpr std::string_view value() noexcept {
[[nodiscard]] static constexpr stl::string_view value() noexcept {
return internal::type_name<Type>(0);
}
/*! @copydoc value */
[[nodiscard]] constexpr operator std::string_view() const noexcept {
[[nodiscard]] constexpr operator stl::string_view() const noexcept {
return value();
}
};
@@ -146,10 +146,10 @@ struct type_info final {
*/
template<typename Type>
// NOLINTBEGIN(modernize-use-transparent-functors)
constexpr type_info(std::in_place_type_t<Type>) noexcept
: seq{type_index<std::remove_cvref_t<Type>>::value()},
identifier{type_hash<std::remove_cvref_t<Type>>::value()},
alias{type_name<std::remove_cvref_t<Type>>::value()} {}
constexpr type_info(stl::in_place_type_t<Type>) noexcept
: seq{type_index<stl::remove_cvref_t<Type>>::value()},
identifier{type_hash<stl::remove_cvref_t<Type>>::value()},
alias{type_name<stl::remove_cvref_t<Type>>::value()} {}
// NOLINTEND(modernize-use-transparent-functors)
/**
@@ -172,7 +172,7 @@ struct type_info final {
* @brief Type name.
* @return Type name.
*/
[[nodiscard]] constexpr std::string_view name() const noexcept {
[[nodiscard]] constexpr stl::string_view name() const noexcept {
return alias;
}
@@ -197,7 +197,7 @@ struct type_info final {
private:
id_type seq;
id_type identifier;
std::string_view alias;
stl::string_view alias;
};
/**
@@ -213,18 +213,18 @@ private:
*/
template<typename Type>
[[nodiscard]] const type_info &type_id() noexcept {
if constexpr(std::is_same_v<Type, std::remove_cvref_t<Type>>) {
static const type_info instance{std::in_place_type<Type>};
if constexpr(stl::is_same_v<Type, stl::remove_cvref_t<Type>>) {
static const type_info instance{stl::in_place_type<Type>};
return instance;
} else {
return type_id<std::remove_cvref_t<Type>>();
return type_id<stl::remove_cvref_t<Type>>();
}
}
/*! @copydoc type_id */
template<typename Type>
[[nodiscard]] const type_info &type_id(const Type &) noexcept {
return type_id<std::remove_cvref_t<Type>>();
return type_id<stl::remove_cvref_t<Type>>();
}
} // namespace entt

View File

@@ -1,13 +1,13 @@
#ifndef ENTT_CORE_TYPE_TRAITS_HPP
#define ENTT_CORE_TYPE_TRAITS_HPP
#include <concepts>
#include <cstddef>
#include <iterator>
#include <tuple>
#include <type_traits>
#include <utility>
#include "../config/config.h"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/iterator.hpp"
#include "../stl/tuple.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "fwd.hpp"
namespace entt {
@@ -16,7 +16,7 @@ namespace entt {
* @brief Utility class to disambiguate overloaded functions.
* @tparam N Number of choices available.
*/
template<std::size_t N>
template<stl::size_t N>
struct choice_t
// unfortunately, doxygen cannot parse such a construct
: /*! @cond ENTT_INTERNAL */ choice_t<N - 1> /*! @endcond */
@@ -30,7 +30,7 @@ struct choice_t<0> {};
* @brief Variable template for the choice trick.
* @tparam N Number of choices available.
*/
template<std::size_t N>
template<stl::size_t N>
inline constexpr choice_t<N> choice{};
/**
@@ -38,21 +38,21 @@ inline constexpr choice_t<N> choice{};
* @tparam Type The type of which to return the size.
*/
template<typename Type>
struct size_of: std::integral_constant<std::size_t, 0u> {};
struct size_of: stl::integral_constant<stl::size_t, 0u> {};
/*! @copydoc size_of */
template<typename Type>
requires requires { sizeof(Type); }
struct size_of<Type>
// NOLINTNEXTLINE(bugprone-sizeof-expression)
: std::integral_constant<std::size_t, sizeof(Type)> {};
: stl::integral_constant<stl::size_t, sizeof(Type)> {};
/**
* @brief Helper variable template.
* @tparam Type The type of which to return the size.
*/
template<typename Type>
inline constexpr std::size_t size_of_v = size_of<Type>::value;
inline constexpr stl::size_t size_of_v = size_of<Type>::value;
/**
* @brief Using declaration to be used to _repeat_ the same type a number of
@@ -75,7 +75,7 @@ inline constexpr auto unpack_as_value = Value;
* @tparam Value A static constant.
*/
template<auto Value>
using integral_constant = std::integral_constant<decltype(Value), Value>;
using integral_constant = stl::integral_constant<decltype(Value), Value>;
/**
* @brief Alias template to facilitate the creation of named values.
@@ -97,7 +97,7 @@ struct type_list {
};
/*! @brief Primary template isn't defined on purpose. */
template<std::size_t, typename>
template<stl::size_t, typename>
struct type_list_element;
/**
@@ -106,7 +106,7 @@ struct type_list_element;
* @tparam First First type provided by the type list.
* @tparam Other Other types provided by the type list.
*/
template<std::size_t Index, typename First, typename... Other>
template<stl::size_t Index, typename First, typename... Other>
struct type_list_element<Index, type_list<First, Other...>>
: type_list_element<Index - 1u, type_list<Other...>> {};
@@ -126,7 +126,7 @@ struct type_list_element<0u, type_list<First, Other...>> {
* @tparam Index Index of the type to return.
* @tparam List Type list to search into.
*/
template<std::size_t Index, typename List>
template<stl::size_t Index, typename List>
using type_list_element_t = type_list_element<Index, List>::type;
/*! @brief Primary template isn't defined on purpose. */
@@ -142,7 +142,7 @@ struct type_list_index;
template<typename Type, typename First, typename... Other>
struct type_list_index<Type, type_list<First, Other...>> {
/*! @brief Unsigned integer type. */
using value_type = std::size_t;
using value_type = stl::size_t;
/*! @brief Compile-time position of the given type in the sublist. */
static constexpr value_type value = 1u + type_list_index<Type, type_list<Other...>>::value;
};
@@ -156,7 +156,7 @@ template<typename Type, typename... Other>
struct type_list_index<Type, type_list<Type, Other...>> {
static_assert(type_list_index<Type, type_list<Other...>>::value == sizeof...(Other), "Non-unique type");
/*! @brief Unsigned integer type. */
using value_type = std::size_t;
using value_type = stl::size_t;
/*! @brief Compile-time position of the given type in the sublist. */
static constexpr value_type value = 0u;
};
@@ -168,7 +168,7 @@ struct type_list_index<Type, type_list<Type, Other...>> {
template<typename Type>
struct type_list_index<Type, type_list<>> {
/*! @brief Unsigned integer type. */
using value_type = std::size_t;
using value_type = stl::size_t;
/*! @brief Compile-time position of the given type in the sublist. */
static constexpr value_type value = 0u;
};
@@ -179,7 +179,7 @@ struct type_list_index<Type, type_list<>> {
* @tparam Type Type to look for and for which to return the index.
*/
template<typename Type, typename List>
inline constexpr std::size_t type_list_index_v = type_list_index<Type, List>::value;
inline constexpr stl::size_t type_list_index_v = type_list_index<Type, List>::value;
/**
* @brief Concatenates multiple type lists.
@@ -240,7 +240,7 @@ struct type_list_unique;
template<typename First, typename... Other, typename... Type>
struct type_list_unique<type_list<First, Other...>, Type...>
: std::conditional_t<(std::is_same_v<First, Type> || ...), type_list_unique<type_list<Other...>, Type...>, type_list_unique<type_list<Other...>, Type..., First>> {};
: stl::conditional_t<(stl::is_same_v<First, Type> || ...), type_list_unique<type_list<Other...>, Type...>, type_list_unique<type_list<Other...>, Type..., First>> {};
template<typename... Type>
struct type_list_unique<type_list<>, Type...> {
@@ -283,7 +283,7 @@ struct type_list_contains;
*/
template<typename... Type, typename Other>
struct type_list_contains<type_list<Type...>, Other>
: std::bool_constant<(std::is_same_v<Type, Other> || ...)> {};
: stl::bool_constant<(stl::is_same_v<Type, Other> || ...)> {};
/**
* @brief Helper variable template.
@@ -305,7 +305,7 @@ struct type_list_diff;
template<typename... Type, typename... Other>
struct type_list_diff<type_list<Type...>, type_list<Other...>> {
/*! @brief A type list that is the difference between the two type lists. */
using type = type_list_cat_t<std::conditional_t<type_list_contains_v<type_list<Other...>, Type>, type_list<>, type_list<Type>>...>;
using type = type_list_cat_t<stl::conditional_t<type_list_contains_v<type_list<Other...>, Type>, type_list<>, type_list<Type>>...>;
};
/**
@@ -352,7 +352,7 @@ struct value_list {
};
/*! @brief Primary template isn't defined on purpose. */
template<std::size_t, typename>
template<stl::size_t, typename>
struct value_list_element;
/**
@@ -361,7 +361,7 @@ struct value_list_element;
* @tparam Value First value provided by the value list.
* @tparam Other Other values provided by the value list.
*/
template<std::size_t Index, auto Value, auto... Other>
template<stl::size_t Index, auto Value, auto... Other>
struct value_list_element<Index, value_list<Value, Other...>>
: value_list_element<Index - 1u, value_list<Other...>> {};
@@ -383,7 +383,7 @@ struct value_list_element<0u, value_list<Value, Other...>> {
* @tparam Index Index of the type to return.
* @tparam List Value list to search into.
*/
template<std::size_t Index, typename List>
template<stl::size_t Index, typename List>
using value_list_element_t = value_list_element<Index, List>::type;
/**
@@ -391,7 +391,7 @@ using value_list_element_t = value_list_element<Index, List>::type;
* @tparam Index Index of the value to return.
* @tparam List Value list to search into.
*/
template<std::size_t Index, typename List>
template<stl::size_t Index, typename List>
inline constexpr auto value_list_element_v = value_list_element<Index, List>::value;
/*! @brief Primary template isn't defined on purpose. */
@@ -407,7 +407,7 @@ struct value_list_index;
template<auto Value, auto First, auto... Other>
struct value_list_index<Value, value_list<First, Other...>> {
/*! @brief Unsigned integer type. */
using value_type = std::size_t;
using value_type = stl::size_t;
/*! @brief Compile-time position of the given value in the sublist. */
static constexpr value_type value = 1u + value_list_index<Value, value_list<Other...>>::value;
};
@@ -421,7 +421,7 @@ template<auto Value, auto... Other>
struct value_list_index<Value, value_list<Value, Other...>> {
static_assert(value_list_index<Value, value_list<Other...>>::value == sizeof...(Other), "Non-unique type");
/*! @brief Unsigned integer type. */
using value_type = std::size_t;
using value_type = stl::size_t;
/*! @brief Compile-time position of the given value in the sublist. */
static constexpr value_type value = 0u;
};
@@ -433,7 +433,7 @@ struct value_list_index<Value, value_list<Value, Other...>> {
template<auto Value>
struct value_list_index<Value, value_list<>> {
/*! @brief Unsigned integer type. */
using value_type = std::size_t;
using value_type = stl::size_t;
/*! @brief Compile-time position of the given type in the sublist. */
static constexpr value_type value = 0u;
};
@@ -444,7 +444,7 @@ struct value_list_index<Value, value_list<>> {
* @tparam Value Value to look for and for which to return the index.
*/
template<auto Value, typename List>
inline constexpr std::size_t value_list_index_v = value_list_index<Value, List>::value;
inline constexpr stl::size_t value_list_index_v = value_list_index<Value, List>::value;
/**
* @brief Concatenates multiple value lists.
@@ -509,7 +509,7 @@ struct value_list_unique;
template<auto Value, auto... Other>
struct value_list_unique<value_list<Value, Other...>> {
/*! @brief A value list without duplicate types. */
using type = std::conditional_t<
using type = stl::conditional_t<
((Value == Other) || ...),
typename value_list_unique<value_list<Other...>>::type,
value_list_cat_t<value_list<Value>, typename value_list_unique<value_list<Other...>>::type>>;
@@ -545,7 +545,7 @@ struct value_list_contains;
*/
template<auto... Value, auto Other>
struct value_list_contains<value_list<Value...>, Other>
: std::bool_constant<((Value == Other) || ...)> {};
: stl::bool_constant<((Value == Other) || ...)> {};
/**
* @brief Helper variable template.
@@ -567,7 +567,7 @@ struct value_list_diff;
template<auto... Value, auto... Other>
struct value_list_diff<value_list<Value...>, value_list<Other...>> {
/*! @brief A value list that is the difference between the two value lists. */
using type = value_list_cat_t<std::conditional_t<value_list_contains_v<value_list<Other...>, Value>, value_list<>, value_list<Value>>...>;
using type = value_list_cat_t<stl::conditional_t<value_list_contains_v<value_list<Other...>, Value>, value_list<>, value_list<Value>>...>;
};
/**
@@ -577,9 +577,9 @@ struct value_list_diff<value_list<Value...>, value_list<Other...>> {
template<typename... List>
using value_list_diff_t = value_list_diff<List...>::type;
/*! @brief Same as std::is_invocable, but with tuples. */
/*! @brief Same as stl::is_invocable, but with tuples. */
template<typename, typename>
struct is_applicable: std::false_type {};
struct is_applicable: stl::false_type {};
/**
* @copybrief is_applicable
@@ -588,7 +588,7 @@ struct is_applicable: std::false_type {};
* @tparam Args The list of arguments to use to probe the function type.
*/
template<typename Func, template<typename...> class Tuple, typename... Args>
struct is_applicable<Func, Tuple<Args...>>: std::is_invocable<Func, Args...> {};
struct is_applicable<Func, Tuple<Args...>>: stl::is_invocable<Func, Args...> {};
/**
* @copybrief is_applicable
@@ -597,7 +597,7 @@ struct is_applicable<Func, Tuple<Args...>>: std::is_invocable<Func, Args...> {};
* @tparam Args The list of arguments to use to probe the function type.
*/
template<typename Func, template<typename...> class Tuple, typename... Args>
struct is_applicable<Func, const Tuple<Args...>>: std::is_invocable<Func, Args...> {};
struct is_applicable<Func, const Tuple<Args...>>: stl::is_invocable<Func, Args...> {};
/**
* @brief Helper variable template.
@@ -607,9 +607,9 @@ struct is_applicable<Func, const Tuple<Args...>>: std::is_invocable<Func, Args..
template<typename Func, typename Args>
inline constexpr bool is_applicable_v = is_applicable<Func, Args>::value;
/*! @brief Same as std::is_invocable_r, but with tuples for arguments. */
/*! @brief Same as stl::is_invocable_r, but with tuples for arguments. */
template<typename, typename, typename>
struct is_applicable_r: std::false_type {};
struct is_applicable_r: stl::false_type {};
/**
* @copybrief is_applicable_r
@@ -619,7 +619,7 @@ struct is_applicable_r: std::false_type {};
* @tparam Args The list of arguments to use to probe the function type.
*/
template<typename Ret, typename Func, typename... Args>
struct is_applicable_r<Ret, Func, std::tuple<Args...>>: std::is_invocable_r<Ret, Func, Args...> {};
struct is_applicable_r<Ret, Func, stl::tuple<Args...>>: stl::is_invocable_r<Ret, Func, Args...> {};
/**
* @brief Helper variable template.
@@ -637,12 +637,12 @@ inline constexpr bool is_applicable_r_v = is_applicable_r<Ret, Func, Args>::valu
* @tparam Type The type to test.
*/
template<typename Type>
struct is_complete: std::false_type {};
struct is_complete: stl::false_type {};
/*! @copydoc is_complete */
template<typename Type>
requires requires { sizeof(Type); }
struct is_complete<Type>: std::true_type {};
struct is_complete<Type>: stl::true_type {};
/**
* @brief Helper variable template.
@@ -657,24 +657,24 @@ inline constexpr bool is_complete_v = is_complete<Type>::value;
* @tparam Type The type to test.
*/
template<typename Type>
struct is_iterator: std::false_type {};
struct is_iterator: stl::false_type {};
/*! @cond ENTT_INTERNAL */
namespace internal {
template<typename>
struct has_iterator_category: std::false_type {};
struct has_iterator_category: stl::false_type {};
template<typename Type>
requires requires { typename std::iterator_traits<Type>::iterator_category; }
struct has_iterator_category<Type>: std::true_type {};
requires requires { typename stl::iterator_traits<Type>::iterator_category; }
struct has_iterator_category<Type>: stl::true_type {};
} // namespace internal
/*! @endcond */
/*! @copydoc is_iterator */
template<typename Type>
requires (!std::is_void_v<std::remove_const_t<std::remove_pointer_t<Type>>>)
requires (!stl::is_void_v<stl::remove_const_t<stl::remove_pointer_t<Type>>>)
struct is_iterator<Type>: internal::has_iterator_category<Type> {};
/**
@@ -690,7 +690,7 @@ inline constexpr bool is_iterator_v = is_iterator<Type>::value;
* @tparam Type The type to test
*/
template<typename Type>
struct is_ebco_eligible: std::bool_constant<std::is_empty_v<Type> && !std::is_final_v<Type>> {};
struct is_ebco_eligible: stl::bool_constant<stl::is_empty_v<Type> && !stl::is_final_v<Type>> {};
/**
* @brief Helper variable template.
@@ -705,12 +705,12 @@ inline constexpr bool is_ebco_eligible_v = is_ebco_eligible<Type>::value;
* @tparam Type The type to test.
*/
template<typename Type>
struct is_transparent: std::false_type {};
struct is_transparent: stl::false_type {};
/*! @copydoc is_transparent */
template<typename Type>
requires requires { typename Type::is_transparent; }
struct is_transparent<Type>: std::true_type {};
struct is_transparent<Type>: stl::true_type {};
/**
* @brief Helper variable template.
@@ -723,25 +723,25 @@ inline constexpr bool is_transparent_v = is_transparent<Type>::value;
namespace internal {
template<typename>
struct has_tuple_size_value: std::false_type {};
struct has_tuple_size_value: stl::false_type {};
template<typename Type>
requires is_complete_v<std::tuple_size<const Type>>
struct has_tuple_size_value<Type>: std::true_type {};
requires is_complete_v<stl::tuple_size<const Type>>
struct has_tuple_size_value<Type>: stl::true_type {};
template<typename>
struct has_value_type: std::false_type {};
struct has_value_type: stl::false_type {};
template<typename Type>
requires requires { typename Type::value_type; }
struct has_value_type<Type>: std::true_type {};
struct has_value_type<Type>: stl::true_type {};
template<typename>
[[nodiscard]] ENTT_CONSTEVAL bool dispatch_is_equality_comparable();
template<typename Type, std::size_t... Index>
[[nodiscard]] ENTT_CONSTEVAL bool unpack_maybe_equality_comparable(std::index_sequence<Index...>) {
return (dispatch_is_equality_comparable<std::tuple_element_t<Index, Type>>() && ...);
template<typename Type, stl::size_t... Index>
[[nodiscard]] ENTT_CONSTEVAL bool unpack_maybe_equality_comparable(stl::index_sequence<Index...>) {
return (dispatch_is_equality_comparable<stl::tuple_element_t<Index, Type>>() && ...);
}
template<typename>
@@ -750,23 +750,23 @@ template<typename>
}
template<typename Type>
[[nodiscard]] ENTT_CONSTEVAL auto maybe_equality_comparable(int) -> decltype(std::declval<Type>() == std::declval<Type>()) {
[[nodiscard]] ENTT_CONSTEVAL auto maybe_equality_comparable(int) -> decltype(stl::declval<Type>() == stl::declval<Type>()) {
return true;
}
template<typename Type>
[[nodiscard]] ENTT_CONSTEVAL bool dispatch_is_equality_comparable() {
// NOLINTBEGIN(modernize-use-transparent-functors)
if constexpr(std::is_array_v<Type>) {
if constexpr(stl::is_array_v<Type>) {
return false;
} else if constexpr(is_complete_v<std::tuple_size<std::remove_const_t<Type>>>) {
} else if constexpr(is_complete_v<stl::tuple_size<stl::remove_const_t<Type>>>) {
if constexpr(has_tuple_size_value<Type>::value) {
return maybe_equality_comparable<Type>(0) && unpack_maybe_equality_comparable<Type>(std::make_index_sequence<std::tuple_size<Type>::value>{});
return maybe_equality_comparable<Type>(0) && unpack_maybe_equality_comparable<Type>(stl::make_index_sequence<stl::tuple_size<Type>::value>{});
} else {
return maybe_equality_comparable<Type>(0);
}
} else if constexpr(has_value_type<Type>::value) {
if constexpr(is_iterator_v<Type> || std::is_same_v<typename Type::value_type, Type> || dispatch_is_equality_comparable<typename Type::value_type>()) {
if constexpr(is_iterator_v<Type> || stl::is_same_v<typename Type::value_type, Type> || dispatch_is_equality_comparable<typename Type::value_type>()) {
return maybe_equality_comparable<Type>(0);
} else {
return false;
@@ -786,7 +786,7 @@ template<typename Type>
* @tparam Type The type to test.
*/
template<typename Type>
struct is_equality_comparable: std::bool_constant<internal::dispatch_is_equality_comparable<Type>()> {};
struct is_equality_comparable: stl::bool_constant<internal::dispatch_is_equality_comparable<Type>()> {};
/*! @copydoc is_equality_comparable */
template<typename Type>
@@ -807,7 +807,7 @@ inline constexpr bool is_equality_comparable_v = is_equality_comparable<Type>::v
template<typename To, typename From>
struct constness_as {
/*! @brief The type resulting from the transcription of the constness. */
using type = std::remove_const_t<To>;
using type = stl::remove_const_t<To>;
};
/*! @copydoc constness_as */
@@ -831,7 +831,7 @@ using constness_as_t = constness_as<To, From>::type;
*/
template<typename Member>
class member_class {
static_assert(std::is_member_pointer_v<Member>, "Invalid pointer type to non-static member object or function");
static_assert(stl::is_member_pointer_v<Member>, "Invalid pointer type to non-static member object or function");
template<typename Class, typename Ret, typename... Args>
static Class *clazz(Ret (Class::*)(Args...));
@@ -844,7 +844,7 @@ class member_class {
public:
/*! @brief The class of the given non-static member object or function. */
using type = std::remove_pointer_t<decltype(clazz(std::declval<Member>()))>;
using type = stl::remove_pointer_t<decltype(clazz(stl::declval<Member>()))>;
};
/**
@@ -859,7 +859,7 @@ using member_class_t = member_class<Member>::type;
* @tparam Index The index of the argument to extract.
* @tparam Candidate A valid _callable_ type.
*/
template<std::size_t Index, typename Candidate>
template<stl::size_t Index, typename Candidate>
class nth_argument {
template<typename Ret, typename... Args>
static ENTT_CONSTEVAL type_list<Args...> pick_up(Ret (*)(Args...));
@@ -878,7 +878,7 @@ class nth_argument {
public:
/*! @brief N-th argument of the _callable_ type. */
using type = type_list_element_t<Index, decltype(pick_up(std::declval<Candidate>()))>;
using type = type_list_element_t<Index, decltype(pick_up(stl::declval<Candidate>()))>;
};
/**
@@ -886,21 +886,21 @@ public:
* @tparam Index The index of the argument to extract.
* @tparam Candidate A valid function, member function or data member type.
*/
template<std::size_t Index, typename Candidate>
template<stl::size_t Index, typename Candidate>
using nth_argument_t = nth_argument<Index, Candidate>::type;
} // namespace entt
template<typename... Type>
struct std::tuple_size<entt::type_list<Type...>>: std::integral_constant<std::size_t, entt::type_list<Type...>::size> {};
struct entt::stl::tuple_size<entt::type_list<Type...>>: entt::stl::integral_constant<entt::stl::size_t, entt::type_list<Type...>::size> {};
template<std::size_t Index, typename... Type>
struct std::tuple_element<Index, entt::type_list<Type...>>: entt::type_list_element<Index, entt::type_list<Type...>> {};
template<entt::stl::size_t Index, typename... Type>
struct entt::stl::tuple_element<Index, entt::type_list<Type...>>: entt::type_list_element<Index, entt::type_list<Type...>> {};
template<auto... Value>
struct std::tuple_size<entt::value_list<Value...>>: std::integral_constant<std::size_t, entt::value_list<Value...>::size> {};
struct entt::stl::tuple_size<entt::value_list<Value...>>: entt::stl::integral_constant<entt::stl::size_t, entt::value_list<Value...>::size> {};
template<std::size_t Index, auto... Value>
struct std::tuple_element<Index, entt::value_list<Value...>>: entt::value_list_element<Index, entt::value_list<Value...>> {};
template<entt::stl::size_t Index, auto... Value>
struct entt::stl::tuple_element<Index, entt::value_list<Value...>>: entt::value_list_element<Index, entt::value_list<Value...>> {};
#endif

View File

@@ -1,8 +1,8 @@
#ifndef ENTT_CORE_UTILITY_HPP
#define ENTT_CORE_UTILITY_HPP
#include <type_traits>
#include <utility>
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
namespace entt {
@@ -55,8 +55,8 @@ struct y_combinator {
* @brief Constructs a y-combinator from a given function.
* @param recursive A potentially recursive function.
*/
constexpr y_combinator(Func recursive) noexcept(std::is_nothrow_move_constructible_v<Func>)
: func{std::move(recursive)} {}
constexpr y_combinator(Func recursive) noexcept(stl::is_nothrow_move_constructible_v<Func>)
: func{stl::move(recursive)} {}
/**
* @brief Invokes a y-combinator and therefore its underlying function.
@@ -65,14 +65,14 @@ struct y_combinator {
* @return Return value of the underlying function, if any.
*/
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)...);
constexpr decltype(auto) operator()(Args &&...args) const noexcept(stl::is_nothrow_invocable_v<Func, const y_combinator &, 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)...);
constexpr decltype(auto) operator()(Args &&...args) noexcept(stl::is_nothrow_invocable_v<Func, y_combinator &, Args...>) {
return func(*this, stl::forward<Args>(args)...);
}
private:

View File

@@ -1,11 +1,11 @@
#ifndef ENTT_ENTITY_COMPONENT_HPP
#define ENTT_ENTITY_COMPONENT_HPP
#include <concepts>
#include <cstddef>
#include <type_traits>
#include "../config/config.h"
#include "../core/concepts.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/type_traits.hpp"
#include "fwd.hpp"
namespace entt {
@@ -14,24 +14,24 @@ namespace entt {
namespace internal {
template<typename Type>
struct in_place_delete: std::bool_constant<!(std::is_move_constructible_v<Type> && std::is_move_assignable_v<Type>)> {};
struct in_place_delete: stl::bool_constant<!(stl::is_move_constructible_v<Type> && stl::is_move_assignable_v<Type>)> {};
template<>
struct in_place_delete<void>: std::false_type {};
struct in_place_delete<void>: stl::false_type {};
template<typename Type>
requires Type::in_place_delete
struct in_place_delete<Type>: std::true_type {};
struct in_place_delete<Type>: stl::true_type {};
template<typename Type>
struct page_size: std::integral_constant<std::size_t, !std::is_empty_v<ENTT_ETO_TYPE(Type)> * ENTT_PACKED_PAGE> {};
struct page_size: stl::integral_constant<stl::size_t, !stl::is_empty_v<ENTT_ETO_TYPE(Type)> * ENTT_PACKED_PAGE> {};
template<>
struct page_size<void>: std::integral_constant<std::size_t, 0u> {};
struct page_size<void>: stl::integral_constant<stl::size_t, 0u> {};
template<typename Type>
requires std::is_convertible_v<decltype(Type::page_size), std::size_t>
struct page_size<Type>: std::integral_constant<std::size_t, Type::page_size> {};
requires stl::is_convertible_v<decltype(Type::page_size), stl::size_t>
struct page_size<Type>: stl::integral_constant<stl::size_t, Type::page_size> {};
} // namespace internal
/*! @endcond */
@@ -51,7 +51,7 @@ struct component_traits {
/*! @brief Pointer stability, default is `false`. */
static constexpr bool in_place_delete = internal::in_place_delete<Type>::value;
/*! @brief Page size, default is `ENTT_PACKED_PAGE` for non-empty types. */
static constexpr std::size_t page_size = internal::page_size<Type>::value;
static constexpr stl::size_t page_size = internal::page_size<Type>::value;
};
} // namespace entt

View File

@@ -1,13 +1,13 @@
#ifndef ENTT_ENTITY_ENTITY_HPP
#define ENTT_ENTITY_ENTITY_HPP
#include <bit>
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <type_traits>
#include "../config/config.h"
#include "../core/bit.hpp"
#include "../stl/bit.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/cstdint.hpp"
#include "../stl/type_traits.hpp"
#include "fwd.hpp"
namespace entt {
@@ -20,10 +20,10 @@ struct entt_traits;
template<typename Type>
requires requires {
requires std::is_enum_v<Type>;
typename internal::entt_traits<std::underlying_type_t<Type>>::value_type;
requires stl::is_enum_v<Type>;
typename internal::entt_traits<stl::underlying_type_t<Type>>::value_type;
}
struct entt_traits<Type>: entt_traits<std::underlying_type_t<Type>> {
struct entt_traits<Type>: entt_traits<stl::underlying_type_t<Type>> {
using value_type = Type;
};
@@ -35,22 +35,22 @@ struct entt_traits<Type>
};
template<>
struct entt_traits<std::uint32_t> {
using value_type = std::uint32_t;
struct entt_traits<stl::uint32_t> {
using value_type = stl::uint32_t;
using entity_type = std::uint32_t;
using version_type = std::uint16_t;
using entity_type = stl::uint32_t;
using version_type = stl::uint16_t;
static constexpr entity_type entity_mask = 0xFFFFF;
static constexpr entity_type version_mask = 0xFFF;
};
template<>
struct entt_traits<std::uint64_t> {
using value_type = std::uint64_t;
struct entt_traits<stl::uint64_t> {
using value_type = stl::uint64_t;
using entity_type = std::uint64_t;
using version_type = std::uint32_t;
using entity_type = stl::uint64_t;
using version_type = stl::uint32_t;
static constexpr entity_type entity_mask = 0xFFFFFFFF;
static constexpr entity_type version_mask = 0xFFFFFFFF;
@@ -74,7 +74,7 @@ concept entity_like = requires {
*/
template<typename Traits>
class basic_entt_traits {
static constexpr auto length = std::popcount(Traits::entity_mask);
static constexpr auto length = stl::popcount(Traits::entity_mask);
static_assert(Traits::entity_mask && ((Traits::entity_mask & (Traits::entity_mask + 1)) == 0), "Invalid entity mask");
static_assert((Traits::version_mask & (Traits::version_mask + 1)) == 0, "Invalid version mask");
@@ -179,7 +179,7 @@ struct entt_traits: basic_entt_traits<internal::entt_traits<Type>> {
/*! @brief Base type. */
using base_type = basic_entt_traits<internal::entt_traits<Type>>;
/*! @brief Page size, default is `ENTT_SPARSE_PAGE`. */
static constexpr std::size_t page_size = ENTT_SPARSE_PAGE;
static constexpr stl::size_t page_size = ENTT_SPARSE_PAGE;
};
/**

View File

@@ -1,13 +1,13 @@
#ifndef ENTT_ENTITY_FWD_HPP
#define ENTT_ENTITY_FWD_HPP
#include <cstdint>
#include <memory>
#include <type_traits>
#include "../config/config.h"
#include "../core/concepts.hpp"
#include "../core/fwd.hpp"
#include "../core/type_traits.hpp"
#include "../stl/cstdint.hpp"
#include "../stl/memory.hpp"
#include "../stl/type_traits.hpp"
namespace entt {
@@ -15,7 +15,7 @@ namespace entt {
enum class entity : id_type {};
/*! @brief Storage deletion policy. */
enum class deletion_policy : std::uint8_t {
enum class deletion_policy : stl::uint8_t {
/*! @brief Swap-and-pop deletion policy. */
swap_and_pop = 0u,
/*! @brief In-place deletion policy. */
@@ -29,10 +29,10 @@ enum class deletion_policy : std::uint8_t {
template<cvref_unqualified Type, typename Entity = entity>
struct component_traits;
template<typename Entity = entity, typename = std::allocator<Entity>>
template<typename Entity = entity, typename = stl::allocator<Entity>>
class basic_sparse_set;
template<typename Type, typename = entity, typename = std::allocator<Type>>
template<typename Type, typename = entity, typename = stl::allocator<Type>>
class basic_storage;
template<typename, typename>
@@ -41,13 +41,13 @@ class basic_sigh_mixin;
template<typename, typename>
class basic_reactive_mixin;
template<typename Entity = entity, typename = std::allocator<Entity>>
template<typename Entity = entity, typename = stl::allocator<Entity>>
class basic_registry;
template<typename, typename>
class basic_view;
template<typename Type, typename = std::allocator<Type *>>
template<typename Type, typename = stl::allocator<Type *>>
class basic_runtime_view;
template<typename, typename, typename>
@@ -223,7 +223,7 @@ struct type_list_transform<owned_t<Type...>, Op> {
* @tparam Entity A valid entity type.
* @tparam Allocator Type of allocator used to manage memory and elements.
*/
template<typename Type, typename Entity = entity, typename Allocator = std::allocator<Type>>
template<typename Type, typename Entity = entity, typename Allocator = stl::allocator<Type>>
struct storage_type {
/*! @brief Type-to-storage conversion result. */
using type = ENTT_STORAGE(sigh_mixin, basic_storage<Type, Entity, Allocator>);
@@ -256,10 +256,10 @@ using storage_type_t = storage_type<Args...>::type;
* @tparam Entity A valid entity type.
* @tparam Allocator Type of allocator used to manage memory and elements.
*/
template<typename Type, typename Entity = entity, typename Allocator = std::allocator<std::remove_const_t<Type>>>
template<typename Type, typename Entity = entity, typename Allocator = stl::allocator<stl::remove_const_t<Type>>>
struct storage_for {
/*! @brief Type-to-storage conversion result. */
using type = constness_as_t<storage_type_t<std::remove_const_t<Type>, Entity, Allocator>, Type>;
using type = constness_as_t<storage_type_t<stl::remove_const_t<Type>, Entity, Allocator>, Type>;
};
/**

View File

@@ -1,20 +1,19 @@
#ifndef ENTT_ENTITY_GROUP_HPP
#define ENTT_ENTITY_GROUP_HPP
#include <array>
#include <concepts>
#include <cstddef>
#include <iterator>
#include <tuple>
#include <type_traits>
#include <utility>
#include "../config/config.h"
#include "../core/algorithm.hpp"
#include "../core/fwd.hpp"
#include "../core/iterator.hpp"
#include "../core/type_info.hpp"
#include "../core/type_traits.hpp"
#include "../stl/array.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/iterator.hpp"
#include "../stl/tuple.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "entity.hpp"
#include "fwd.hpp"
@@ -30,29 +29,29 @@ template<typename It, typename... Owned, typename... Get>
class extended_group_iterator<It, owned_t<Owned...>, get_t<Get...>> {
template<typename Type>
[[nodiscard]] auto index_to_element([[maybe_unused]] Type &cpool) const {
if constexpr(std::is_void_v<typename Type::value_type>) {
return std::make_tuple();
if constexpr(stl::is_void_v<typename Type::value_type>) {
return stl::make_tuple();
} else {
return std::forward_as_tuple(cpool.rbegin()[it.index()]);
return stl::forward_as_tuple(cpool.rbegin()[it.index()]);
}
}
public:
using iterator_type = It;
using value_type = decltype(std::tuple_cat(std::make_tuple(*std::declval<It>()), std::declval<Owned>().get_as_tuple({})..., std::declval<Get>().get_as_tuple({})...));
using value_type = decltype(stl::tuple_cat(stl::make_tuple(*stl::declval<It>()), stl::declval<Owned>().get_as_tuple({})..., stl::declval<Get>().get_as_tuple({})...));
using pointer = input_iterator_pointer<value_type>;
using reference = value_type;
using difference_type = std::ptrdiff_t;
using iterator_category = std::input_iterator_tag;
using iterator_concept = std::forward_iterator_tag;
using difference_type = stl::ptrdiff_t;
using iterator_category = stl::input_iterator_tag;
using iterator_concept = stl::forward_iterator_tag;
constexpr extended_group_iterator()
: it{},
pools{} {}
extended_group_iterator(iterator_type from, std::tuple<Owned *..., Get *...> cpools)
extended_group_iterator(iterator_type from, stl::tuple<Owned *..., Get *...> cpools)
: it{from},
pools{std::move(cpools)} {}
pools{stl::move(cpools)} {}
extended_group_iterator &operator++() noexcept {
return ++it, *this;
@@ -64,7 +63,7 @@ public:
}
[[nodiscard]] reference operator*() const noexcept {
return std::tuple_cat(std::make_tuple(*it), index_to_element(*std::get<Owned *>(pools))..., std::get<Get *>(pools)->get_as_tuple(*it)...);
return stl::tuple_cat(stl::make_tuple(*it), index_to_element(*stl::get<Owned *>(pools))..., stl::get<Get *>(pools)->get_as_tuple(*it)...);
}
[[nodiscard]] pointer operator->() const noexcept {
@@ -82,37 +81,37 @@ public:
private:
It it;
std::tuple<Owned *..., Get *...> pools;
stl::tuple<Owned *..., Get *...> pools;
};
struct group_descriptor {
using size_type = std::size_t;
using size_type = stl::size_t;
virtual ~group_descriptor() = default;
[[nodiscard]] virtual bool owned(const id_type) const noexcept {
return false;
}
};
template<typename Type, std::size_t Owned, std::size_t Get, std::size_t Exclude>
template<typename Type, stl::size_t Owned, stl::size_t Get, stl::size_t Exclude>
class group_handler final: public group_descriptor {
using entity_type = Type::entity_type;
void swap_elements(const std::size_t pos, const entity_type entt) {
void swap_elements(const stl::size_t pos, const entity_type entt) {
for(size_type next{}; next < Owned; ++next) {
pools[next]->swap_elements((*pools[next])[pos], entt);
}
}
void push_on_construct(const entity_type entt) {
if(std::apply([entt, pos = len](auto *cpool, auto *...other) { return cpool->contains(entt) && !(cpool->index(entt) < pos) && (other->contains(entt) && ...); }, pools)
&& std::apply([entt](auto *...cpool) { return (!cpool->contains(entt) && ...); }, filter)) {
if(stl::apply([entt, pos = len](auto *cpool, auto *...other) { return cpool->contains(entt) && !(cpool->index(entt) < pos) && (other->contains(entt) && ...); }, pools)
&& stl::apply([entt](auto *...cpool) { return (!cpool->contains(entt) && ...); }, filter)) {
swap_elements(len++, entt);
}
}
void push_on_destroy(const entity_type entt) {
if(std::apply([entt, pos = len](auto *cpool, auto *...other) { return cpool->contains(entt) && !(cpool->index(entt) < pos) && (other->contains(entt) && ...); }, pools)
&& std::apply([entt](auto *...cpool) { return (0u + ... + cpool->contains(entt)) == 1u; }, filter)) {
if(stl::apply([entt, pos = len](auto *cpool, auto *...other) { return cpool->contains(entt) && !(cpool->index(entt) < pos) && (other->contains(entt) && ...); }, pools)
&& stl::apply([entt](auto *...cpool) { return (0u + ... + cpool->contains(entt)) == 1u; }, filter)) {
swap_elements(len++, entt);
}
}
@@ -135,11 +134,11 @@ public:
using size_type = Type::size_type;
template<typename... OGType, typename... EType>
group_handler(std::tuple<OGType &...> ogpool, std::tuple<EType &...> epool)
: pools{std::apply([](auto &&...cpool) { return std::array<common_type *, (Owned + Get)>{&cpool...}; }, ogpool)},
filter{std::apply([](auto &&...cpool) { return std::array<common_type *, Exclude>{&cpool...}; }, epool)} {
std::apply([this](auto &...cpool) { ((cpool.on_construct().template connect<&group_handler::push_on_construct>(*this), cpool.on_destroy().template connect<&group_handler::remove_if>(*this)), ...); }, ogpool);
std::apply([this](auto &...cpool) { ((cpool.on_construct().template connect<&group_handler::remove_if>(*this), cpool.on_destroy().template connect<&group_handler::push_on_destroy>(*this)), ...); }, epool);
group_handler(stl::tuple<OGType &...> ogpool, stl::tuple<EType &...> epool)
: pools{stl::apply([](auto &&...cpool) { return stl::array<common_type *, (Owned + Get)>{&cpool...}; }, ogpool)},
filter{stl::apply([](auto &&...cpool) { return stl::array<common_type *, Exclude>{&cpool...}; }, epool)} {
stl::apply([this](auto &...cpool) { ((cpool.on_construct().template connect<&group_handler::push_on_construct>(*this), cpool.on_destroy().template connect<&group_handler::remove_if>(*this)), ...); }, ogpool);
stl::apply([this](auto &...cpool) { ((cpool.on_construct().template connect<&group_handler::remove_if>(*this), cpool.on_destroy().template connect<&group_handler::push_on_destroy>(*this)), ...); }, epool);
common_setup();
}
@@ -157,7 +156,7 @@ public:
return len;
}
template<std::size_t Index>
template<stl::size_t Index>
[[nodiscard]] common_type *storage() const noexcept {
if constexpr(Index < (Owned + Get)) {
return pools[Index];
@@ -167,27 +166,27 @@ public:
}
private:
std::array<common_type *, (Owned + Get)> pools;
std::array<common_type *, Exclude> filter;
std::size_t len{};
stl::array<common_type *, (Owned + Get)> pools;
stl::array<common_type *, Exclude> filter;
stl::size_t len{};
};
template<typename Type, std::size_t Get, std::size_t Exclude>
template<typename Type, stl::size_t Get, stl::size_t Exclude>
class group_handler<Type, 0u, Get, Exclude> final: public group_descriptor {
using entity_type = Type::entity_type;
void push_on_construct(const entity_type entt) {
if(!elem.contains(entt)
&& std::apply([entt](auto *...cpool) { return (cpool->contains(entt) && ...); }, pools)
&& std::apply([entt](auto *...cpool) { return (!cpool->contains(entt) && ...); }, filter)) {
&& stl::apply([entt](auto *...cpool) { return (cpool->contains(entt) && ...); }, pools)
&& stl::apply([entt](auto *...cpool) { return (!cpool->contains(entt) && ...); }, filter)) {
elem.push(entt);
}
}
void push_on_destroy(const entity_type entt) {
if(!elem.contains(entt)
&& std::apply([entt](auto *...cpool) { return (cpool->contains(entt) && ...); }, pools)
&& std::apply([entt](auto *...cpool) { return (0u + ... + cpool->contains(entt)) == 1u; }, filter)) {
&& stl::apply([entt](auto *...cpool) { return (cpool->contains(entt) && ...); }, pools)
&& stl::apply([entt](auto *...cpool) { return (0u + ... + cpool->contains(entt)) == 1u; }, filter)) {
elem.push(entt);
}
}
@@ -206,12 +205,12 @@ public:
using common_type = Type;
template<typename Allocator, typename... GType, typename... EType>
group_handler(const Allocator &allocator, std::tuple<GType &...> gpool, std::tuple<EType &...> epool)
: pools{std::apply([](auto &&...cpool) { return std::array<common_type *, Get>{&cpool...}; }, gpool)},
filter{std::apply([](auto &&...cpool) { return std::array<common_type *, Exclude>{&cpool...}; }, epool)},
group_handler(const Allocator &allocator, stl::tuple<GType &...> gpool, stl::tuple<EType &...> epool)
: pools{stl::apply([](auto &&...cpool) { return stl::array<common_type *, Get>{&cpool...}; }, gpool)},
filter{stl::apply([](auto &&...cpool) { return stl::array<common_type *, Exclude>{&cpool...}; }, epool)},
elem{allocator} {
std::apply([this](auto &...cpool) { ((cpool.on_construct().template connect<&group_handler::push_on_construct>(*this), cpool.on_destroy().template connect<&group_handler::remove_if>(*this)), ...); }, gpool);
std::apply([this](auto &...cpool) { ((cpool.on_construct().template connect<&group_handler::remove_if>(*this), cpool.on_destroy().template connect<&group_handler::push_on_destroy>(*this)), ...); }, epool);
stl::apply([this](auto &...cpool) { ((cpool.on_construct().template connect<&group_handler::push_on_construct>(*this), cpool.on_destroy().template connect<&group_handler::remove_if>(*this)), ...); }, gpool);
stl::apply([this](auto &...cpool) { ((cpool.on_construct().template connect<&group_handler::remove_if>(*this), cpool.on_destroy().template connect<&group_handler::push_on_destroy>(*this)), ...); }, epool);
common_setup();
}
@@ -223,7 +222,7 @@ public:
return elem;
}
template<std::size_t Index>
template<stl::size_t Index>
[[nodiscard]] common_type *storage() const noexcept {
if constexpr(Index < Get) {
return pools[Index];
@@ -233,8 +232,8 @@ public:
}
private:
std::array<common_type *, Get> pools;
std::array<common_type *, Exclude> filter;
stl::array<common_type *, Get> pools;
stl::array<common_type *, Exclude> filter;
common_type elem;
};
@@ -274,15 +273,15 @@ class basic_group;
*/
template<typename... Get, typename... Exclude>
class basic_group<owned_t<>, get_t<Get...>, exclude_t<Exclude...>> {
using base_type = std::common_type_t<typename Get::base_type..., typename Exclude::base_type...>;
using base_type = stl::common_type_t<typename Get::base_type..., typename Exclude::base_type...>;
using underlying_type = base_type::entity_type;
template<typename Type>
static constexpr std::size_t index_of = type_list_index_v<std::remove_const_t<Type>, type_list<typename Get::element_type..., typename Exclude::element_type...>>;
static constexpr stl::size_t index_of = type_list_index_v<stl::remove_const_t<Type>, type_list<typename Get::element_type..., typename Exclude::element_type...>>;
template<std::size_t... Index>
[[nodiscard]] auto pools_for(std::index_sequence<Index...>) const noexcept {
using return_type = std::tuple<Get *...>;
template<stl::size_t... Index>
[[nodiscard]] auto pools_for(stl::index_sequence<Index...>) const noexcept {
using return_type = stl::tuple<Get *...>;
return descriptor ? return_type{static_cast<Get *>(descriptor->template storage<Index>())...} : return_type{};
}
@@ -290,9 +289,9 @@ public:
/*! @brief Underlying entity identifier. */
using entity_type = underlying_type;
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Signed integer type. */
using difference_type = std::ptrdiff_t;
using difference_type = stl::ptrdiff_t;
/*! @brief Common type among all storage types. */
using common_type = base_type;
/*! @brief Random access iterator type. */
@@ -309,7 +308,7 @@ public:
* @return Group opaque identifier.
*/
static id_type group_id() noexcept {
return type_hash<basic_group<owned_t<>, get_t<std::remove_const_t<Get>...>, exclude_t<std::remove_const_t<Exclude>...>>>::value();
return type_hash<basic_group<owned_t<>, get_t<stl::remove_const_t<Get>...>, exclude_t<stl::remove_const_t<Exclude>...>>>::value();
}
/*! @brief Default constructor to use to create empty, invalid groups. */
@@ -346,7 +345,7 @@ public:
* @tparam Index Index of the storage to return.
* @return The storage for the given index.
*/
template<std::size_t Index>
template<stl::size_t Index>
[[nodiscard]] auto *storage() const noexcept {
using type = type_list_element_t<Index, type_list<Get..., Exclude...>>;
return *this ? static_cast<type *>(descriptor->template storage<Index>()) : nullptr;
@@ -499,16 +498,16 @@ public:
* @param entt A valid identifier.
* @return The elements assigned to the entity.
*/
template<std::size_t... Index>
template<stl::size_t... Index>
[[nodiscard]] decltype(auto) get(const entity_type entt) const {
const auto cpools = pools_for(std::index_sequence_for<Get...>{});
const auto cpools = pools_for(stl::index_sequence_for<Get...>{});
if constexpr(sizeof...(Index) == 0) {
return std::apply([entt](auto *...curr) { return std::tuple_cat(curr->get_as_tuple(entt)...); }, cpools);
return stl::apply([entt](auto *...curr) { return stl::tuple_cat(curr->get_as_tuple(entt)...); }, cpools);
} else if constexpr(sizeof...(Index) == 1) {
return (std::get<Index>(cpools)->get(entt), ...);
return (stl::get<Index>(cpools)->get(entt), ...);
} else {
return std::tuple_cat(std::get<Index>(cpools)->get_as_tuple(entt)...);
return stl::tuple_cat(stl::get<Index>(cpools)->get_as_tuple(entt)...);
}
}
@@ -537,10 +536,10 @@ public:
template<typename Func>
void each(Func func) const {
for(const auto entt: *this) {
if constexpr(is_applicable_v<Func, decltype(std::tuple_cat(std::tuple<entity_type>{}, std::declval<basic_group>().get({})))>) {
std::apply(func, std::tuple_cat(std::make_tuple(entt), get(entt)));
if constexpr(is_applicable_v<Func, decltype(stl::tuple_cat(stl::tuple<entity_type>{}, stl::declval<basic_group>().get({})))>) {
stl::apply(func, stl::tuple_cat(stl::make_tuple(entt), get(entt)));
} else {
std::apply(func, get(entt));
stl::apply(func, get(entt));
}
}
}
@@ -559,7 +558,7 @@ public:
* @return An iterable object to use to _visit_ the group.
*/
[[nodiscard]] iterable each() const noexcept {
const auto cpools = pools_for(std::index_sequence_for<Get...>{});
const auto cpools = pools_for(stl::index_sequence_for<Get...>{});
return iterable{{begin(), cpools}, {end(), cpools}};
}
@@ -571,7 +570,7 @@ public:
* comparison function should be equivalent to one of the following:
*
* @code{.cpp}
* bool(std::tuple<Type &...>, std::tuple<Type &...>);
* bool(stl::tuple<Type &...>, stl::tuple<Type &...>);
* bool(const Type &..., const Type &...);
* bool(const Entity, const Entity);
* @endcode
@@ -598,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>...>(stl::move(compare), stl::move(algo), stl::forward<Args>(args)...);
}
/**
@@ -614,22 +613,22 @@ public:
* @param algo A valid sort function object.
* @param args Arguments to forward to the sort function object, if any.
*/
template<std::size_t... Index, typename Compare, typename Sort = std_sort, typename... Args>
template<stl::size_t... Index, typename Compare, typename Sort = std_sort, typename... Args>
void sort(Compare compare, Sort algo = Sort{}, Args &&...args) {
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)...);
static_assert(stl::is_invocable_v<Compare, const entity_type, const entity_type>, "Invalid comparison function");
descriptor->handle().sort(stl::move(compare), stl::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) {
auto comp = [&compare, cpools = pools_for(stl::index_sequence_for<Get...>{})](const entity_type lhs, const entity_type rhs) {
if constexpr(sizeof...(Index) == 1) {
return compare((std::get<Index>(cpools)->get(lhs), ...), (std::get<Index>(cpools)->get(rhs), ...));
return compare((stl::get<Index>(cpools)->get(lhs), ...), (stl::get<Index>(cpools)->get(rhs), ...));
} else {
return compare(std::forward_as_tuple(std::get<Index>(cpools)->get(lhs)...), std::forward_as_tuple(std::get<Index>(cpools)->get(rhs)...));
return compare(stl::forward_as_tuple(stl::get<Index>(cpools)->get(lhs)...), stl::forward_as_tuple(stl::get<Index>(cpools)->get(rhs)...));
}
};
descriptor->handle().sort(std::move(comp), std::move(algo), std::forward<Args>(args)...);
descriptor->handle().sort(stl::move(comp), stl::move(algo), stl::forward<Args>(args)...);
}
}
}
@@ -688,15 +687,15 @@ template<typename... Owned, typename... Get, typename... Exclude>
class basic_group<owned_t<Owned...>, get_t<Get...>, exclude_t<Exclude...>> {
static_assert(((Owned::storage_policy != deletion_policy::in_place) && ...), "Groups do not support in-place delete");
using base_type = std::common_type_t<typename Owned::base_type..., typename Get::base_type..., typename Exclude::base_type...>;
using base_type = stl::common_type_t<typename Owned::base_type..., typename Get::base_type..., typename Exclude::base_type...>;
using underlying_type = base_type::entity_type;
template<typename Type>
static constexpr std::size_t index_of = type_list_index_v<std::remove_const_t<Type>, type_list<typename Owned::element_type..., typename Get::element_type..., typename Exclude::element_type...>>;
static constexpr stl::size_t index_of = type_list_index_v<stl::remove_const_t<Type>, type_list<typename Owned::element_type..., typename Get::element_type..., typename Exclude::element_type...>>;
template<std::size_t... Index, std::size_t... Other>
[[nodiscard]] auto pools_for(std::index_sequence<Index...>, std::index_sequence<Other...>) const noexcept {
using return_type = std::tuple<Owned *..., Get *...>;
template<stl::size_t... Index, stl::size_t... Other>
[[nodiscard]] auto pools_for(stl::index_sequence<Index...>, stl::index_sequence<Other...>) const noexcept {
using return_type = stl::tuple<Owned *..., Get *...>;
return descriptor ? return_type{static_cast<Owned *>(descriptor->template storage<Index>())..., static_cast<Get *>(descriptor->template storage<sizeof...(Owned) + Other>())...} : return_type{};
}
@@ -704,9 +703,9 @@ public:
/*! @brief Underlying entity identifier. */
using entity_type = underlying_type;
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Signed integer type. */
using difference_type = std::ptrdiff_t;
using difference_type = stl::ptrdiff_t;
/*! @brief Common type among all storage types. */
using common_type = base_type;
/*! @brief Random access iterator type. */
@@ -723,7 +722,7 @@ public:
* @return Group opaque identifier.
*/
static id_type group_id() noexcept {
return type_hash<basic_group<owned_t<std::remove_const_t<Owned>...>, get_t<std::remove_const_t<Get>...>, exclude_t<std::remove_const_t<Exclude>...>>>::value();
return type_hash<basic_group<owned_t<stl::remove_const_t<Owned>...>, get_t<stl::remove_const_t<Get>...>, exclude_t<stl::remove_const_t<Exclude>...>>>::value();
}
/*! @brief Default constructor to use to create empty, invalid groups. */
@@ -760,7 +759,7 @@ public:
* @tparam Index Index of the storage to return.
* @return The storage for the given index.
*/
template<std::size_t Index>
template<stl::size_t Index>
[[nodiscard]] auto *storage() const noexcept {
using type = type_list_element_t<Index, type_list<Owned..., Get..., Exclude...>>;
return *this ? static_cast<type *>(descriptor->template storage<Index>()) : nullptr;
@@ -898,16 +897,16 @@ public:
* @param entt A valid identifier.
* @return The elements assigned to the entity.
*/
template<std::size_t... Index>
template<stl::size_t... Index>
[[nodiscard]] decltype(auto) get(const entity_type entt) const {
const auto cpools = pools_for(std::index_sequence_for<Owned...>{}, std::index_sequence_for<Get...>{});
const auto cpools = pools_for(stl::index_sequence_for<Owned...>{}, stl::index_sequence_for<Get...>{});
if constexpr(sizeof...(Index) == 0) {
return std::apply([entt](auto *...curr) { return std::tuple_cat(curr->get_as_tuple(entt)...); }, cpools);
return stl::apply([entt](auto *...curr) { return stl::tuple_cat(curr->get_as_tuple(entt)...); }, cpools);
} else if constexpr(sizeof...(Index) == 1) {
return (std::get<Index>(cpools)->get(entt), ...);
return (stl::get<Index>(cpools)->get(entt), ...);
} else {
return std::tuple_cat(std::get<Index>(cpools)->get_as_tuple(entt)...);
return stl::tuple_cat(stl::get<Index>(cpools)->get_as_tuple(entt)...);
}
}
@@ -936,10 +935,10 @@ public:
template<typename Func>
void each(Func func) const {
for(auto args: each()) {
if constexpr(is_applicable_v<Func, decltype(std::tuple_cat(std::tuple<entity_type>{}, std::declval<basic_group>().get({})))>) {
std::apply(func, args);
if constexpr(is_applicable_v<Func, decltype(stl::tuple_cat(stl::tuple<entity_type>{}, stl::declval<basic_group>().get({})))>) {
stl::apply(func, args);
} else {
std::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);
}
}
}
@@ -958,7 +957,7 @@ public:
* @return An iterable object to use to _visit_ the group.
*/
[[nodiscard]] iterable each() const noexcept {
const auto cpools = pools_for(std::index_sequence_for<Owned...>{}, std::index_sequence_for<Get...>{});
const auto cpools = pools_for(stl::index_sequence_for<Owned...>{}, stl::index_sequence_for<Get...>{});
return iterable{{begin(), cpools}, {end(), cpools}};
}
@@ -970,7 +969,7 @@ public:
* comparison function should be equivalent to one of the following:
*
* @code{.cpp}
* bool(std::tuple<Type &...>, std::tuple<Type &...>);
* bool(stl::tuple<Type &...>, stl::tuple<Type &...>);
* bool(const Type &, const Type &);
* bool(const Entity, const Entity);
* @endcode
@@ -998,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>...>(stl::move(compare), stl::move(algo), stl::forward<Args>(args)...);
}
/**
@@ -1014,23 +1013,23 @@ public:
* @param algo A valid sort function object.
* @param args Arguments to forward to the sort function object, if any.
*/
template<std::size_t... Index, typename Compare, typename Sort = std_sort, typename... Args>
template<stl::size_t... Index, typename Compare, typename Sort = std_sort, typename... Args>
void sort(Compare compare, Sort algo = Sort{}, Args &&...args) const {
const auto cpools = pools_for(std::index_sequence_for<Owned...>{}, std::index_sequence_for<Get...>{});
const auto cpools = pools_for(stl::index_sequence_for<Owned...>{}, stl::index_sequence_for<Get...>{});
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)...);
static_assert(stl::is_invocable_v<Compare, const entity_type, const entity_type>, "Invalid comparison function");
storage<0>()->sort_n(descriptor->length(), stl::move(compare), stl::move(algo), stl::forward<Args>(args)...);
} else {
auto comp = [&compare, &cpools](const entity_type lhs, const entity_type rhs) {
if constexpr(sizeof...(Index) == 1) {
return compare((std::get<Index>(cpools)->get(lhs), ...), (std::get<Index>(cpools)->get(rhs), ...));
return compare((stl::get<Index>(cpools)->get(lhs), ...), (stl::get<Index>(cpools)->get(rhs), ...));
} else {
return compare(std::forward_as_tuple(std::get<Index>(cpools)->get(lhs)...), std::forward_as_tuple(std::get<Index>(cpools)->get(rhs)...));
return compare(stl::forward_as_tuple(stl::get<Index>(cpools)->get(lhs)...), stl::forward_as_tuple(stl::get<Index>(cpools)->get(rhs)...));
}
};
storage<0>()->sort_n(descriptor->length(), std::move(comp), std::move(algo), std::forward<Args>(args)...);
storage<0>()->sort_n(descriptor->length(), stl::move(comp), stl::move(algo), stl::forward<Args>(args)...);
}
auto cb = [this](auto *head, auto *...other) {
@@ -1041,7 +1040,7 @@ public:
}
};
std::apply(cb, cpools);
stl::apply(cb, cpools);
}
private:

View File

@@ -1,13 +1,13 @@
#ifndef ENTT_ENTITY_HANDLE_HPP
#define ENTT_ENTITY_HANDLE_HPP
#include <iterator>
#include <tuple>
#include <type_traits>
#include <utility>
#include "../config/config.h"
#include "../core/iterator.hpp"
#include "../core/type_traits.hpp"
#include "../stl/iterator.hpp"
#include "../stl/tuple.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "entity.hpp"
#include "fwd.hpp"
@@ -21,16 +21,16 @@ class handle_storage_iterator final {
template<typename>
friend class handle_storage_iterator;
using underlying_type = std::remove_reference_t<typename It::value_type::second_type>;
using underlying_type = stl::remove_reference_t<typename It::value_type::second_type>;
using entity_type = underlying_type::entity_type;
public:
using value_type = std::iterator_traits<It>::value_type;
using value_type = stl::iterator_traits<It>::value_type;
using pointer = input_iterator_pointer<value_type>;
using reference = value_type;
using difference_type = std::ptrdiff_t;
using iterator_category = std::input_iterator_tag;
using iterator_concept = std::forward_iterator_tag;
using difference_type = stl::ptrdiff_t;
using iterator_category = stl::input_iterator_tag;
using iterator_concept = stl::forward_iterator_tag;
constexpr handle_storage_iterator() noexcept
: entt{null},
@@ -103,9 +103,9 @@ public:
/*! @brief Underlying version type. */
using version_type = traits_type::version_type;
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Iterable handle type. */
using iterable = iterable_adaptor<internal::handle_storage_iterator<typename decltype(std::declval<registry_type>().storage())::iterator>>;
using iterable = iterable_adaptor<internal::handle_storage_iterator<typename decltype(stl::declval<registry_type>().storage())::iterator>>;
/*! @brief Constructs an invalid handle. */
basic_handle() noexcept
@@ -173,7 +173,7 @@ public:
/*! @brief Destroys the entity associated with a handle. */
void destroy() {
owner_or_assert().destroy(std::exchange(entt, null));
owner_or_assert().destroy(stl::exchange(entt, null));
}
/**
@@ -181,7 +181,7 @@ public:
* @param version A desired version upon destruction.
*/
void destroy(const version_type version) {
owner_or_assert().destroy(std::exchange(entt, null), version);
owner_or_assert().destroy(stl::exchange(entt, null), version);
}
/**
@@ -194,8 +194,8 @@ public:
template<typename Type, typename... Args>
// NOLINTNEXTLINE(modernize-use-nodiscard)
decltype(auto) emplace(Args &&...args) const {
static_assert(((sizeof...(Scope) == 0) || ... || std::is_same_v<Type, Scope>), "Invalid type");
return owner_or_assert().template emplace<Type>(entt, std::forward<Args>(args)...);
static_assert(((sizeof...(Scope) == 0) || ... || stl::is_same_v<Type, Scope>), "Invalid type");
return owner_or_assert().template emplace<Type>(entt, stl::forward<Args>(args)...);
}
/**
@@ -207,8 +207,8 @@ public:
*/
template<typename Type, typename... Args>
decltype(auto) emplace_or_replace(Args &&...args) const {
static_assert(((sizeof...(Scope) == 0) || ... || std::is_same_v<Type, Scope>), "Invalid type");
return owner_or_assert().template emplace_or_replace<Type>(entt, std::forward<Args>(args)...);
static_assert(((sizeof...(Scope) == 0) || ... || stl::is_same_v<Type, Scope>), "Invalid type");
return owner_or_assert().template emplace_or_replace<Type>(entt, stl::forward<Args>(args)...);
}
/**
@@ -220,8 +220,8 @@ public:
*/
template<typename Type, typename... Func>
decltype(auto) patch(Func &&...func) const {
static_assert(((sizeof...(Scope) == 0) || ... || std::is_same_v<Type, Scope>), "Invalid type");
return owner_or_assert().template patch<Type>(entt, std::forward<Func>(func)...);
static_assert(((sizeof...(Scope) == 0) || ... || stl::is_same_v<Type, Scope>), "Invalid type");
return owner_or_assert().template patch<Type>(entt, stl::forward<Func>(func)...);
}
/**
@@ -233,8 +233,8 @@ public:
*/
template<typename Type, typename... Args>
decltype(auto) replace(Args &&...args) const {
static_assert(((sizeof...(Scope) == 0) || ... || std::is_same_v<Type, Scope>), "Invalid type");
return owner_or_assert().template replace<Type>(entt, std::forward<Args>(args)...);
static_assert(((sizeof...(Scope) == 0) || ... || stl::is_same_v<Type, Scope>), "Invalid type");
return owner_or_assert().template replace<Type>(entt, stl::forward<Args>(args)...);
}
/**
@@ -300,8 +300,8 @@ public:
*/
template<typename Type, typename... Args>
[[nodiscard]] decltype(auto) get_or_emplace(Args &&...args) const {
static_assert(((sizeof...(Scope) == 0) || ... || std::is_same_v<Type, Scope>), "Invalid type");
return owner_or_assert().template get_or_emplace<Type>(entt, std::forward<Args>(args)...);
static_assert(((sizeof...(Scope) == 0) || ... || stl::is_same_v<Type, Scope>), "Invalid type");
return owner_or_assert().template get_or_emplace<Type>(entt, stl::forward<Args>(args)...);
}
/**
@@ -353,7 +353,7 @@ public:
*/
template<typename Other, typename... Args>
operator basic_handle<Other, Args...>() const noexcept {
static_assert(std::is_same_v<Other, Registry> || std::is_same_v<std::remove_const_t<Other>, Registry>, "Invalid conversion between different handles");
static_assert(stl::is_same_v<Other, Registry> || stl::is_same_v<stl::remove_const_t<Other>, Registry>, "Invalid conversion between different handles");
static_assert((sizeof...(Scope) == 0 || ((sizeof...(Args) != 0 && sizeof...(Args) <= sizeof...(Scope)) && ... && (type_list_contains_v<type_list<Scope...>, Args>))), "Invalid conversion between different handles");
return owner ? basic_handle<Other, Args...>{*owner, entt} : basic_handle<Other, Args...>{};
}

View File

@@ -1,11 +1,11 @@
#ifndef ENTT_ENTITY_HELPER_HPP
#define ENTT_ENTITY_HELPER_HPP
#include <memory>
#include <type_traits>
#include <utility>
#include "../core/fwd.hpp"
#include "../core/type_traits.hpp"
#include "../stl/memory.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "component.hpp"
#include "fwd.hpp"
#include "group.hpp"
@@ -61,7 +61,7 @@ template<typename Registry>
class as_group {
template<typename... Owned, typename... Get, typename... Exclude>
[[nodiscard]] auto dispatch(owned_t<Owned...>, get_t<Get...>, exclude_t<Exclude...>) const {
if constexpr(std::is_const_v<registry_type>) {
if constexpr(stl::is_const_v<registry_type>) {
return reg->template group_if_exists<typename Owned::element_type...>(get_t<typename Get::element_type...>{}, exclude_t<typename Exclude::element_type...>{});
} else {
return reg->template group<constness_as_t<typename Owned::element_type, Owned>...>(get_t<constness_as_t<typename Get::element_type, Get>...>{}, exclude_t<constness_as_t<typename Exclude::element_type, Exclude>...>{});
@@ -104,9 +104,9 @@ private:
* @param reg A registry that contains the given entity and its elements.
* @param entt Entity from which to get the element.
*/
template<auto Member, typename Registry = std::decay_t<nth_argument_t<0u, decltype(Member)>>>
template<auto Member, typename Registry = stl::decay_t<nth_argument_t<0u, decltype(Member)>>>
void invoke(Registry &reg, const typename Registry::entity_type entt) {
static_assert(std::is_member_function_pointer_v<decltype(Member)>, "Invalid pointer to non-static member function");
static_assert(stl::is_member_function_pointer_v<decltype(Member)>, "Invalid pointer to non-static member function");
(reg.template get<member_class_t<decltype(Member)>>(entt).*Member)(reg, entt);
}
@@ -129,8 +129,8 @@ basic_storage<Args...>::entity_type to_entity(const basic_storage<Args...> &stor
const auto *page = storage.raw();
// NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic)
for(std::size_t pos{}, count = storage.size(); pos < count; pos += traits_type::page_size, ++page) {
if(const auto dist = (std::addressof(instance) - *page); dist >= 0 && dist < static_cast<decltype(dist)>(traits_type::page_size)) {
for(stl::size_t pos{}, count = storage.size(); pos < count; pos += traits_type::page_size, ++page) {
if(const auto dist = (stl::addressof(instance) - *page); dist >= 0 && dist < static_cast<decltype(dist)>(traits_type::page_size)) {
return *(static_cast<const basic_storage<Args...>::base_type &>(storage).rbegin() + static_cast<decltype(dist)>(pos) + dist);
}
}
@@ -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;
}

View File

@@ -1,14 +1,15 @@
#ifndef ENTT_ENTITY_MIXIN_HPP
#define ENTT_ENTITY_MIXIN_HPP
#include <concepts>
#include <type_traits>
#include <utility>
#include "../config/config.h"
#include "../core/any.hpp"
#include "../core/type_info.hpp"
#include "../signal/sigh.hpp"
#include "../stl/concepts.hpp"
#include "../stl/iterator.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "../stl/vector.hpp"
#include "entity.hpp"
#include "fwd.hpp"
@@ -18,25 +19,25 @@ namespace entt {
namespace internal {
template<typename, typename>
struct has_on_construct final: std::false_type {};
struct has_on_construct final: stl::false_type {};
template<typename Type, typename Registry>
requires std::invocable<decltype(&Type::on_construct), Registry &, typename Registry::entity_type>
struct has_on_construct<Type, Registry>: std::true_type {};
requires stl::invocable<decltype(&Type::on_construct), Registry &, typename Registry::entity_type>
struct has_on_construct<Type, Registry>: stl::true_type {};
template<typename, typename>
struct has_on_update final: std::false_type {};
struct has_on_update final: stl::false_type {};
template<typename Type, typename Registry>
requires std::invocable<decltype(&Type::on_update), Registry &, typename Registry::entity_type>
struct has_on_update<Type, Registry>: std::true_type {};
requires stl::invocable<decltype(&Type::on_update), Registry &, typename Registry::entity_type>
struct has_on_update<Type, Registry>: stl::true_type {};
template<typename, typename>
struct has_on_destroy final: std::false_type {};
struct has_on_destroy final: stl::false_type {};
template<typename Type, typename Registry>
requires std::invocable<decltype(&Type::on_destroy), Registry &, typename Registry::entity_type>
struct has_on_destroy<Type, Registry>: std::true_type {};
requires stl::invocable<decltype(&Type::on_destroy), Registry &, typename Registry::entity_type>
struct has_on_destroy<Type, Registry>: stl::true_type {};
} // namespace internal
/*! @endcond */
@@ -64,7 +65,7 @@ class basic_sigh_mixin final: public Type {
using sigh_type = sigh<void(owner_type &, const typename underlying_type::entity_type), typename underlying_type::allocator_type>;
using underlying_iterator = underlying_type::base_type::basic_iterator;
static_assert(std::is_base_of_v<basic_registry_type, owner_type>, "Invalid registry type");
static_assert(stl::is_base_of_v<basic_registry_type, owner_type>, "Invalid registry type");
[[nodiscard]] auto &owner_or_assert() const noexcept {
ENTT_ASSERT(owner != nullptr, "Invalid pointer to registry");
@@ -87,7 +88,7 @@ private:
void pop_all() final {
if(auto &reg = owner_or_assert(); !destruction.empty()) {
if constexpr(std::is_same_v<typename underlying_type::element_type, entity_type>) {
if constexpr(stl::is_same_v<typename underlying_type::element_type, entity_type>) {
for(typename underlying_type::size_type pos{}, last = underlying_type::free_list(); pos < last; ++pos) {
destruction.publish(reg, underlying_type::base_type::operator[](pos));
}
@@ -120,13 +121,13 @@ private:
void bind_any(any value) noexcept final {
owner = any_cast<basic_registry_type>(&value);
if constexpr(!std::is_same_v<registry_type, basic_registry_type>) {
if constexpr(!stl::is_same_v<registry_type, basic_registry_type>) {
if(owner == nullptr) {
owner = any_cast<registry_type>(&value);
}
}
underlying_type::bind_any(std::move(value));
underlying_type::bind_any(stl::move(value));
}
public:
@@ -174,9 +175,9 @@ public:
basic_sigh_mixin(basic_sigh_mixin &&other) noexcept
: underlying_type{static_cast<underlying_type &&>(other)},
owner{other.owner},
construction{std::move(other.construction)},
destruction{std::move(other.destruction)},
update{std::move(other.update)} {}
construction{stl::move(other.construction)},
destruction{stl::move(other.destruction)},
update{stl::move(other.update)} {}
/**
* @brief Allocator-extended move constructor.
@@ -186,9 +187,9 @@ public:
basic_sigh_mixin(basic_sigh_mixin &&other, const allocator_type &allocator)
: underlying_type{static_cast<underlying_type &&>(other), allocator},
owner{other.owner},
construction{std::move(other.construction), allocator},
destruction{std::move(other.destruction), allocator},
update{std::move(other.update), allocator} {}
construction{stl::move(other.construction), allocator},
destruction{stl::move(other.destruction), allocator},
update{stl::move(other.update), allocator} {}
/*! @brief Default destructor. */
~basic_sigh_mixin() override = default;
@@ -214,7 +215,7 @@ public:
* @param other Storage to exchange the content with.
*/
void swap(basic_sigh_mixin &other) noexcept {
using std::swap;
using stl::swap;
swap(owner, other.owner);
swap(construction, other.construction);
swap(destruction, other.destruction);
@@ -335,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);
}
@@ -349,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);
}
@@ -365,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
@@ -392,11 +393,11 @@ class basic_reactive_mixin final: public Type {
using underlying_type = Type;
using owner_type = Registry;
using alloc_traits = std::allocator_traits<typename underlying_type::allocator_type>;
using alloc_traits = stl::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");
static_assert(stl::is_base_of_v<basic_registry_type, owner_type>, "Invalid registry type");
[[nodiscard]] auto &owner_or_assert() const noexcept {
ENTT_ASSERT(owner != nullptr, "Invalid pointer to registry");
@@ -413,13 +414,13 @@ private:
void bind_any(any value) noexcept final {
owner = any_cast<basic_registry_type>(&value);
if constexpr(!std::is_same_v<registry_type, basic_registry_type>) {
if constexpr(!stl::is_same_v<registry_type, basic_registry_type>) {
if(owner == nullptr) {
owner = any_cast<registry_type>(&value);
}
}
underlying_type::bind_any(std::move(value));
underlying_type::bind_any(stl::move(value));
}
public:
@@ -454,7 +455,7 @@ public:
basic_reactive_mixin(basic_reactive_mixin &&other) noexcept
: underlying_type{static_cast<underlying_type &&>(other)},
owner{other.owner},
conn{std::move(other.conn)} {
conn{stl::move(other.conn)} {
}
/**
@@ -465,7 +466,7 @@ public:
basic_reactive_mixin(basic_reactive_mixin &&other, const allocator_type &allocator)
: underlying_type{static_cast<underlying_type &&>(other), allocator},
owner{other.owner},
conn{std::move(other.conn), allocator} {
conn{stl::move(other.conn), allocator} {
}
/*! @brief Default destructor. */
@@ -497,7 +498,7 @@ public:
template<typename Clazz, auto Candidate = &basic_reactive_mixin::emplace_element>
basic_reactive_mixin &on_construct(const id_type id = type_hash<Clazz>::value()) {
auto curr = owner_or_assert().template storage<Clazz>(id).on_construct().template connect<Candidate>(*this);
conn.push_back(std::move(curr));
conn.push_back(stl::move(curr));
return *this;
}
@@ -511,7 +512,7 @@ public:
template<typename Clazz, auto Candidate = &basic_reactive_mixin::emplace_element>
basic_reactive_mixin &on_update(const id_type id = type_hash<Clazz>::value()) {
auto curr = owner_or_assert().template storage<Clazz>(id).on_update().template connect<Candidate>(*this);
conn.push_back(std::move(curr));
conn.push_back(stl::move(curr));
return *this;
}
@@ -525,7 +526,7 @@ public:
template<typename Clazz, auto Candidate = &basic_reactive_mixin::emplace_element>
basic_reactive_mixin &on_destroy(const id_type id = type_hash<Clazz>::value()) {
auto curr = owner_or_assert().template storage<Clazz>(id).on_destroy().template connect<Candidate>(*this);
conn.push_back(std::move(curr));
conn.push_back(stl::move(curr));
return *this;
}
@@ -561,7 +562,7 @@ public:
view(exclude_t<Exclude...> = exclude_t{}) const {
const owner_type &parent = owner_or_assert();
basic_view<get_t<const basic_reactive_mixin, typename basic_registry_type::template storage_for_type<const Get>...>, exclude_t<typename basic_registry_type::template storage_for_type<const Exclude>...>> elem{};
[&elem](const auto *...curr) { ((curr ? elem.storage(*curr) : void()), ...); }(parent.template storage<std::remove_const_t<Exclude>>()..., parent.template storage<std::remove_const_t<Get>>()..., this);
[&elem](const auto *...curr) { ((curr ? elem.storage(*curr) : void()), ...); }(parent.template storage<stl::remove_const_t<Exclude>>()..., parent.template storage<stl::remove_const_t<Get>>()..., this);
return elem;
}
@@ -569,8 +570,8 @@ public:
template<typename... Get, typename... Exclude>
[[nodiscard]] basic_view<get_t<const basic_reactive_mixin, typename basic_registry_type::template storage_for_type<Get>...>, exclude_t<typename basic_registry_type::template storage_for_type<Exclude>...>>
view(exclude_t<Exclude...> = exclude_t{}) {
std::conditional_t<((std::is_const_v<Get> && ...) && (std::is_const_v<Exclude> && ...)), const owner_type, owner_type> &parent = owner_or_assert();
return {*this, parent.template storage<std::remove_const_t<Get>>()..., parent.template storage<std::remove_const_t<Exclude>>()...};
stl::conditional_t<((stl::is_const_v<Get> && ...) && (stl::is_const_v<Exclude> && ...)), const owner_type, owner_type> &parent = owner_or_assert();
return {*this, parent.template storage<stl::remove_const_t<Get>>()..., parent.template storage<stl::remove_const_t<Exclude>>()...};
}
/*! @brief Releases all connections to the underlying registry, if any. */

View File

@@ -1,15 +1,15 @@
#ifndef ENTT_ENTITY_ORGANIZER_HPP
#define ENTT_ENTITY_ORGANIZER_HPP
#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/cstddef.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "../stl/vector.hpp"
#include "fwd.hpp"
#include "helper.hpp"
@@ -19,32 +19,32 @@ namespace entt {
namespace internal {
template<typename>
struct is_view: std::false_type {};
struct is_view: stl::false_type {};
template<typename... Args>
struct is_view<basic_view<Args...>>: std::true_type {};
struct is_view<basic_view<Args...>>: stl::true_type {};
template<typename Type>
inline constexpr bool is_view_v = is_view<Type>::value;
template<typename>
struct is_group: std::false_type {};
struct is_group: stl::false_type {};
template<typename... Args>
struct is_group<basic_group<Args...>>: std::true_type {};
struct is_group<basic_group<Args...>>: stl::true_type {};
template<typename Type>
inline constexpr bool is_group_v = is_group<Type>::value;
template<typename Type, typename Override>
struct unpack_type {
using ro = std::conditional_t<
type_list_contains_v<Override, const Type> || (std::is_const_v<Type> && !type_list_contains_v<Override, std::remove_const_t<Type>>),
type_list<std::remove_const_t<Type>>,
using ro = stl::conditional_t<
type_list_contains_v<Override, const Type> || (stl::is_const_v<Type> && !type_list_contains_v<Override, stl::remove_const_t<Type>>),
type_list<stl::remove_const_t<Type>>,
type_list<>>;
using rw = std::conditional_t<
type_list_contains_v<Override, std::remove_const_t<Type>> || (!std::is_const_v<Type> && !type_list_contains_v<Override, const Type>),
using rw = stl::conditional_t<
type_list_contains_v<Override, stl::remove_const_t<Type>> || (!stl::is_const_v<Type> && !type_list_contains_v<Override, const Type>),
type_list<Type>,
type_list<>>;
};
@@ -84,23 +84,23 @@ struct resource_traits;
template<typename Registry, typename... Args, typename... Req>
struct resource_traits<Registry, type_list<Args...>, type_list<Req...>> {
using args = type_list<std::remove_const_t<Args>...>;
using args = type_list<stl::remove_const_t<Args>...>;
using ro = type_list_cat_t<typename unpack_type<Args, type_list<Req...>>::ro..., typename unpack_type<Req, type_list<>>::ro...>;
using rw = type_list_cat_t<typename unpack_type<Args, type_list<Req...>>::rw..., typename unpack_type<Req, type_list<>>::rw...>;
static constexpr auto sync_point = (std::is_same_v<Args, Registry> || ...);
static constexpr auto sync_point = (stl::is_same_v<Args, Registry> || ...);
};
template<typename Registry, typename... Req, typename Ret, typename... Args>
resource_traits<Registry, type_list<std::remove_reference_t<Args>...>, type_list<Req...>> free_function_to_resource_traits(Ret (*)(Args...));
resource_traits<Registry, type_list<stl::remove_reference_t<Args>...>, type_list<Req...>> free_function_to_resource_traits(Ret (*)(Args...));
template<typename Registry, typename... Req, typename Ret, typename Type, typename... Args>
resource_traits<Registry, type_list<std::remove_reference_t<Args>...>, type_list<Req...>> constrained_function_to_resource_traits(Ret (*)(Type &, Args...));
resource_traits<Registry, type_list<stl::remove_reference_t<Args>...>, type_list<Req...>> constrained_function_to_resource_traits(Ret (*)(Type &, Args...));
template<typename Registry, typename... Req, typename Ret, typename Class, typename... Args>
resource_traits<Registry, type_list<std::remove_reference_t<Args>...>, type_list<Req...>> constrained_function_to_resource_traits(Ret (Class::*)(Args...));
resource_traits<Registry, type_list<stl::remove_reference_t<Args>...>, type_list<Req...>> constrained_function_to_resource_traits(Ret (Class::*)(Args...));
template<typename Registry, typename... Req, typename Ret, typename Class, typename... Args>
resource_traits<Registry, type_list<std::remove_reference_t<Args>...>, type_list<Req...>> constrained_function_to_resource_traits(Ret (Class::*)(Args...) const);
resource_traits<Registry, type_list<stl::remove_reference_t<Args>...>, type_list<Req...>> constrained_function_to_resource_traits(Ret (Class::*)(Args...) const);
} // namespace internal
/*! @endcond */
@@ -120,11 +120,11 @@ template<typename Registry>
class basic_organizer final {
using callback_type = void(const void *, Registry &);
using prepare_type = void(Registry &);
using dependency_type = std::size_t(const bool, const type_info **, const std::size_t);
using dependency_type = stl::size_t(const bool, const type_info **, const stl::size_t);
struct vertex_data final {
std::size_t ro_count{};
std::size_t rw_count{};
stl::size_t ro_count{};
stl::size_t rw_count{};
const char *name{};
const void *payload{};
callback_type *callback{};
@@ -135,24 +135,24 @@ class basic_organizer final {
template<typename Type>
[[nodiscard]] static decltype(auto) extract(Registry &reg) {
if constexpr(std::is_same_v<Type, Registry>) {
if constexpr(stl::is_same_v<Type, Registry>) {
return reg;
} else if constexpr(internal::is_view_v<Type>) {
return static_cast<Type>(as_view{reg});
} else if constexpr(internal::is_group_v<Type>) {
return static_cast<Type>(as_group{reg});
} else {
return reg.ctx().template emplace<std::remove_reference_t<Type>>();
return reg.ctx().template emplace<stl::remove_reference_t<Type>>();
}
}
template<typename... Args>
[[nodiscard]] static auto to_args(Registry &reg, type_list<Args...>) {
return std::tuple<decltype(extract<Args>(reg))...>(extract<Args>(reg)...);
return stl::tuple<decltype(extract<Args>(reg))...>(extract<Args>(reg)...);
}
template<typename... Type>
[[nodiscard]] static std::size_t fill_dependencies(type_list<Type...>, [[maybe_unused]] const type_info **buffer, [[maybe_unused]] const std::size_t count) {
[[nodiscard]] static stl::size_t fill_dependencies(type_list<Type...>, [[maybe_unused]] const type_info **buffer, [[maybe_unused]] const stl::size_t count) {
if constexpr(sizeof...(Type) == 0u) {
return {};
} else {
@@ -160,7 +160,7 @@ class basic_organizer final {
const type_info *info[]{&type_id<Type>()...};
const auto length = count < sizeof...(Type) ? count : sizeof...(Type);
for(std::size_t pos{}; pos < length; ++pos) {
for(stl::size_t pos{}; pos < length; ++pos) {
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic)
buffer[pos] = info[pos];
}
@@ -170,7 +170,7 @@ class basic_organizer final {
}
template<typename... RO, typename... RW>
void track_dependencies(std::size_t index, const bool sync_point, type_list<RO...>, type_list<RW...>) {
void track_dependencies(stl::size_t index, const bool sync_point, type_list<RO...>, type_list<RW...>) {
builder.bind(static_cast<id_type>(index));
builder.set(type_hash<Registry>::value(), sync_point || (sizeof...(RO) + sizeof...(RW) == 0u));
(builder.ro(type_hash<RO>::value()), ...);
@@ -183,7 +183,7 @@ public:
/*! @brief Underlying entity identifier. */
using entity_type = registry_type::entity_type;
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Raw task function type. */
using function_type = callback_type;
@@ -195,10 +195,10 @@ 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)
: node{std::move(data)},
in{std::move(from)},
out{std::move(to)} {}
vertex(vertex_data data, stl::vector<stl::size_t> from, stl::vector<stl::size_t> to)
: node{stl::move(data)},
in{stl::move(from)},
out{stl::move(to)} {}
/**
* @brief Fills a buffer with the type info objects for the writable
@@ -207,7 +207,7 @@ public:
* @param length The length of the user-supplied buffer.
* @return The number of type info objects written to the buffer.
*/
[[nodiscard]] size_type ro_dependency(const type_info **buffer, const std::size_t length) const noexcept {
[[nodiscard]] size_type ro_dependency(const type_info **buffer, const stl::size_t length) const noexcept {
return node.dependency(false, buffer, length);
}
@@ -218,7 +218,7 @@ public:
* @param length The length of the user-supplied buffer.
* @return The number of type info objects written to the buffer.
*/
[[nodiscard]] size_type rw_dependency(const type_info **buffer, const std::size_t length) const noexcept {
[[nodiscard]] size_type rw_dependency(const type_info **buffer, const stl::size_t length) const noexcept {
return node.dependency(true, buffer, length);
}
@@ -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<stl::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<stl::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<stl::size_t> in;
stl::vector<stl::size_t> out;
};
/**
@@ -320,7 +320,7 @@ public:
using resource_type = decltype(internal::free_function_to_resource_traits<registry_type, Req...>(Candidate));
callback_type *callback = +[](const void *, registry_type &reg) {
std::apply(Candidate, to_args(reg, typename resource_type::args{}));
stl::apply(Candidate, to_args(reg, typename resource_type::args{}));
};
vertex_data vdata{
@@ -329,12 +329,12 @@ public:
name,
nullptr,
callback,
+[](const bool rw, const type_info **buffer, const std::size_t length) { return rw ? fill_dependencies(typename resource_type::rw{}, buffer, length) : fill_dependencies(typename resource_type::ro{}, buffer, length); },
+[](const bool rw, const type_info **buffer, const stl::size_t length) { return rw ? fill_dependencies(typename resource_type::rw{}, buffer, length) : fill_dependencies(typename resource_type::ro{}, buffer, length); },
+[](registry_type &reg) { void(to_args(reg, typename resource_type::args{})); },
&type_id<std::integral_constant<decltype(Candidate), Candidate>>()};
&type_id<stl::integral_constant<decltype(Candidate), Candidate>>()};
track_dependencies(vertices.size(), resource_type::sync_point, typename resource_type::ro{}, typename resource_type::rw{});
vertices.push_back(std::move(vdata));
vertices.push_back(stl::move(vdata));
}
/**
@@ -352,7 +352,7 @@ public:
callback_type *callback = +[](const void *payload, registry_type &reg) {
Type *curr = static_cast<Type *>(const_cast<constness_as_t<void, Type> *>(payload));
std::apply(Candidate, std::tuple_cat(std::forward_as_tuple(*curr), to_args(reg, typename resource_type::args{})));
stl::apply(Candidate, stl::tuple_cat(stl::forward_as_tuple(*curr), to_args(reg, typename resource_type::args{})));
};
vertex_data vdata{
@@ -361,12 +361,12 @@ public:
name,
&value_or_instance,
callback,
+[](const bool rw, const type_info **buffer, const std::size_t length) { return rw ? fill_dependencies(typename resource_type::rw{}, buffer, length) : fill_dependencies(typename resource_type::ro{}, buffer, length); },
+[](const bool rw, const type_info **buffer, const stl::size_t length) { return rw ? fill_dependencies(typename resource_type::rw{}, buffer, length) : fill_dependencies(typename resource_type::ro{}, buffer, length); },
+[](registry_type &reg) { void(to_args(reg, typename resource_type::args{})); },
&type_id<std::integral_constant<decltype(Candidate), Candidate>>()};
&type_id<stl::integral_constant<decltype(Candidate), Candidate>>()};
track_dependencies(vertices.size(), resource_type::sync_point, typename resource_type::ro{}, typename resource_type::rw{});
vertices.push_back(std::move(vdata));
vertices.push_back(stl::move(vdata));
}
/**
@@ -388,24 +388,24 @@ public:
name,
payload,
func,
+[](const bool rw, const type_info **buffer, const std::size_t length) { return rw ? fill_dependencies(typename resource_type::rw{}, buffer, length) : fill_dependencies(typename resource_type::ro{}, buffer, length); },
+[](const bool rw, const type_info **buffer, const stl::size_t length) { return rw ? fill_dependencies(typename resource_type::rw{}, buffer, length) : fill_dependencies(typename resource_type::ro{}, buffer, length); },
nullptr,
&type_id<void>()};
vertices.push_back(std::move(vdata));
vertices.push_back(stl::move(vdata));
}
/**
* @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<stl::size_t> in{};
stl::vector<stl::size_t> out{};
for(auto &&edge: adjacency_matrix.in_edges(curr)) {
in.push_back(edge.first);
@@ -415,7 +415,7 @@ public:
out.push_back(edge.second);
}
adjacency_list.emplace_back(vertices[curr], std::move(in), std::move(out));
adjacency_list.emplace_back(vertices[curr], stl::move(in), stl::move(out));
}
return adjacency_list;
@@ -428,7 +428,7 @@ public:
}
private:
std::vector<vertex_data> vertices;
stl::vector<vertex_data> vertices;
flow builder;
};

View File

@@ -1,26 +1,28 @@
#ifndef ENTT_ENTITY_RANGES_HPP
#define ENTT_ENTITY_RANGES_HPP
#if __has_include(<version>)
# include <version>
#
# if defined(__cpp_lib_ranges)
# include <ranges>
# include "fwd.hpp"
#include <version>
#if defined(__cpp_lib_ranges)
# include <ranges>
# include "fwd.hpp"
namespace std::ranges {
template<class... Args>
inline constexpr bool std::ranges::enable_borrowed_range<entt::basic_view<Args...>>{true};
inline constexpr bool enable_borrowed_range<entt::basic_view<Args...>>{true};
template<class... Args>
inline constexpr bool std::ranges::enable_borrowed_range<entt::basic_group<Args...>>{true};
inline constexpr bool enable_borrowed_range<entt::basic_group<Args...>>{true};
template<class... Args>
inline constexpr bool std::ranges::enable_view<entt::basic_view<Args...>>{true};
inline constexpr bool enable_view<entt::basic_view<Args...>>{true};
template<class... Args>
inline constexpr bool std::ranges::enable_view<entt::basic_group<Args...>>{true};
inline constexpr bool enable_view<entt::basic_group<Args...>>{true};
} // namespace std::ranges
# endif
#endif
#endif
#endif

View File

@@ -1,18 +1,7 @@
#ifndef ENTT_ENTITY_REGISTRY_HPP
#define ENTT_ENTITY_REGISTRY_HPP
#include <algorithm>
#include <array>
#include <compare>
#include <concepts>
#include <cstddef>
#include <functional>
#include <iterator>
#include <memory>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>
#include "../config/config.h"
#include "../container/dense_map.hpp"
#include "../core/algorithm.hpp"
@@ -23,8 +12,16 @@
#include "../core/memory.hpp"
#include "../core/type_info.hpp"
#include "../core/type_traits.hpp"
#include "../stl/algorithm.hpp"
#include "../stl/array.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/functional.hpp"
#include "../stl/iterator.hpp"
#include "../stl/memory.hpp"
#include "../stl/tuple.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "entity.hpp"
#include "fwd.hpp"
#include "group.hpp"
@@ -43,15 +40,15 @@ class registry_storage_iterator final {
template<typename>
friend class registry_storage_iterator;
using mapped_type = std::remove_reference_t<decltype(std::declval<It>()->second)>;
using mapped_type = stl::remove_reference_t<decltype(stl::declval<It>()->second)>;
public:
using value_type = std::pair<id_type, constness_as_t<typename mapped_type::element_type, mapped_type> &>;
using value_type = stl::pair<id_type, constness_as_t<typename mapped_type::element_type, mapped_type> &>;
using pointer = input_iterator_pointer<value_type>;
using reference = value_type;
using difference_type = std::ptrdiff_t;
using iterator_category = std::input_iterator_tag;
using iterator_concept = std::random_access_iterator_tag;
using difference_type = stl::ptrdiff_t;
using iterator_category = stl::input_iterator_tag;
using iterator_concept = stl::random_access_iterator_tag;
constexpr registry_storage_iterator() noexcept
: it{} {}
@@ -60,7 +57,7 @@ public:
: it{iter} {}
template<typename Other>
requires (!std::same_as<It, Other> && std::constructible_from<It, Other>)
requires (!stl::same_as<It, Other> && stl::constructible_from<It, Other>)
constexpr registry_storage_iterator(const registry_storage_iterator<Other> &other) noexcept
: registry_storage_iterator{other.it} {}
@@ -113,7 +110,7 @@ public:
}
template<typename Other>
[[nodiscard]] constexpr std::ptrdiff_t operator-(const registry_storage_iterator<Other> &other) const noexcept {
[[nodiscard]] constexpr stl::ptrdiff_t operator-(const registry_storage_iterator<Other> &other) const noexcept {
return it - other.it;
}
@@ -133,8 +130,8 @@ private:
template<typename Allocator>
class registry_context {
using alloc_traits = std::allocator_traits<Allocator>;
using allocator_type = alloc_traits::template rebind_alloc<std::pair<const id_type, basic_any<0u>>>;
using alloc_traits = stl::allocator_traits<Allocator>;
using allocator_type = alloc_traits::template rebind_alloc<stl::pair<const id_type, basic_any<0u>>>;
public:
explicit registry_context(const allocator_type &allocator)
@@ -146,22 +143,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, stl::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<std::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>
@@ -199,7 +196,7 @@ public:
}
private:
dense_map<id_type, basic_any<0u>, stl::identity, std::equal_to<>, allocator_type> ctx;
dense_map<id_type, basic_any<0u>, stl::identity, stl::equal_to<>, allocator_type> ctx;
};
} // namespace internal
@@ -213,16 +210,16 @@ private:
template<typename Entity, typename Allocator>
class basic_registry {
using base_type = basic_sparse_set<Entity, Allocator>;
using alloc_traits = std::allocator_traits<Allocator>;
static_assert(std::is_same_v<typename alloc_traits::value_type, Entity>, "Invalid value type");
// std::shared_ptr because of its type erased allocator which is useful here
using pool_container_type = dense_map<id_type, std::shared_ptr<base_type>, stl::identity, std::equal_to<>, typename alloc_traits::template rebind_alloc<std::pair<const id_type, std::shared_ptr<base_type>>>>;
using group_container_type = dense_map<id_type, std::shared_ptr<internal::group_descriptor>, stl::identity, std::equal_to<>, typename alloc_traits::template rebind_alloc<std::pair<const id_type, std::shared_ptr<internal::group_descriptor>>>>;
using alloc_traits = stl::allocator_traits<Allocator>;
static_assert(stl::is_same_v<typename alloc_traits::value_type, Entity>, "Invalid value type");
// stl::shared_ptr because of its type erased allocator which is useful here
using pool_container_type = dense_map<id_type, stl::shared_ptr<base_type>, stl::identity, stl::equal_to<>, typename alloc_traits::template rebind_alloc<stl::pair<const id_type, stl::shared_ptr<base_type>>>>;
using group_container_type = dense_map<id_type, stl::shared_ptr<internal::group_descriptor>, stl::identity, stl::equal_to<>, typename alloc_traits::template rebind_alloc<stl::pair<const id_type, stl::shared_ptr<internal::group_descriptor>>>>;
using traits_type = entt_traits<Entity>;
template<cvref_unqualified Type>
[[nodiscard]] auto &assure([[maybe_unused]] const id_type id = type_hash<Type>::value()) {
if constexpr(std::is_same_v<Type, entity_type>) {
if constexpr(stl::is_same_v<Type, entity_type>) {
ENTT_ASSERT(id == type_hash<Type>::value(), "User entity storage not allowed");
return entities;
} else {
@@ -233,7 +230,7 @@ class basic_registry {
return static_cast<storage_type &>(*it->second);
}
typename pool_container_type::mapped_type cpool = std::allocate_shared<storage_type>(get_allocator(), get_allocator());
typename pool_container_type::mapped_type cpool = stl::allocate_shared<storage_type>(get_allocator(), get_allocator());
pools.emplace(id, cpool);
cpool->bind(*this);
@@ -243,7 +240,7 @@ class basic_registry {
template<cvref_unqualified Type>
[[nodiscard]] const auto *assure([[maybe_unused]] const id_type id = type_hash<Type>::value()) const {
if constexpr(std::is_same_v<Type, entity_type>) {
if constexpr(stl::is_same_v<Type, entity_type>) {
ENTT_ASSERT(id == type_hash<Type>::value(), "User entity storage not allowed");
return &entities;
} else {
@@ -272,7 +269,7 @@ public:
/*! @brief Underlying version type. */
using version_type = traits_type::version_type;
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Common type among all storage types. */
using common_type = base_type;
/*! @brief Context type. */
@@ -287,7 +284,7 @@ public:
* @tparam Type Storage value type, eventually const.
*/
template<typename Type>
using storage_for_type = storage_for<Type, Entity, typename alloc_traits::template rebind_alloc<std::remove_const_t<Type>>>::type;
using storage_for_type = storage_for<Type, Entity, typename alloc_traits::template rebind_alloc<stl::remove_const_t<Type>>>::type;
/*! @brief Default constructor. */
basic_registry()
@@ -322,10 +319,10 @@ public:
* @param other The instance to move from.
*/
basic_registry(basic_registry &&other) noexcept
: vars{std::move(other.vars)},
pools{std::move(other.pools)},
groups{std::move(other.groups)},
entities{std::move(other.entities)} {
: vars{stl::move(other.vars)},
pools{stl::move(other.pools)},
groups{stl::move(other.groups)},
entities{stl::move(other.entities)} {
rebind();
}
@@ -353,7 +350,7 @@ public:
* @param other Registry to exchange the content with.
*/
void swap(basic_registry &other) noexcept {
using std::swap;
using stl::swap;
swap(vars, other.vars);
swap(pools, other.pools);
@@ -395,7 +392,7 @@ public:
* @return A pointer to the storage if it exists, a null pointer otherwise.
*/
[[nodiscard]] common_type *storage(const id_type id) {
return const_cast<common_type *>(std::as_const(*this).storage(id));
return const_cast<common_type *>(stl::as_const(*this).storage(id));
}
/**
@@ -416,7 +413,7 @@ public:
*/
template<typename Type>
storage_for_type<Type> &storage(const id_type id = type_hash<Type>::value()) {
return assure<std::remove_const_t<Type>>(id);
return assure<stl::remove_const_t<Type>>(id);
}
/**
@@ -427,7 +424,7 @@ public:
*/
template<typename Type>
[[nodiscard]] const storage_for_type<Type> *storage(const id_type id = type_hash<Type>::value()) const {
return assure<std::remove_const_t<Type>>(id);
return assure<stl::remove_const_t<Type>>(id);
}
/**
@@ -491,7 +488,7 @@ public:
*/
template<stl::output_iterator<entity_type> It>
void create(It first, It last) {
entities.generate(std::move(first), std::move(last));
entities.generate(stl::move(first), stl::move(last));
}
/**
@@ -568,7 +565,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)...);
}
/**
@@ -583,8 +580,8 @@ public:
*/
template<typename Type>
void insert(stl::input_iterator auto first, stl::input_iterator auto last, const Type &value = {}) {
ENTT_ASSERT(std::all_of(first, last, [this](const auto entt) { return valid(entt); }), "Invalid entity");
assure<Type>().insert(std::move(first), std::move(last), value);
ENTT_ASSERT(stl::all_of(first, last, [this](const auto entt) { return valid(entt); }), "Invalid entity");
assure<Type>().insert(stl::move(first), stl::move(last), value);
}
/**
@@ -600,9 +597,9 @@ public:
* @param from An iterator to the first element of the range of elements.
*/
template<typename Type, typename EIt, typename CIt>
requires std::same_as<typename std::iterator_traits<CIt>::value_type, Type>
requires stl::same_as<typename stl::iterator_traits<CIt>::value_type, Type>
void insert(EIt first, EIt last, CIt from) {
ENTT_ASSERT(std::all_of(first, last, [this](const auto entt) { return valid(entt); }), "Invalid entity");
ENTT_ASSERT(stl::all_of(first, last, [this](const auto entt) { return valid(entt); }), "Invalid entity");
assure<Type>().insert(first, last, from);
}
@@ -622,7 +619,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)...);
}
/**
@@ -646,7 +643,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)...);
}
/**
@@ -666,7 +663,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)...}), ...); });
}
/**
@@ -697,13 +694,13 @@ public:
size_type remove(It first, It last) {
size_type count{};
if constexpr(std::is_same_v<It, typename common_type::iterator>) {
std::array cpools{static_cast<common_type *>(&assure<Type>()), static_cast<common_type *>(&assure<Other>())...};
if constexpr(stl::is_same_v<It, typename common_type::iterator>) {
stl::array cpools{static_cast<common_type *>(&assure<Type>()), static_cast<common_type *>(&assure<Other>())...};
for(auto from = cpools.begin(), to = cpools.end(); from != to; ++from) {
if constexpr(sizeof...(Other) != 0u) {
if((*from)->data() == first.data()) {
std::swap((*from), cpools.back());
stl::swap((*from), cpools.back());
}
}
@@ -711,8 +708,8 @@ public:
}
} else {
for(auto cpools = std::forward_as_tuple(assure<Type>(), assure<Other>()...); first != last; ++first) {
count += std::apply([entt = *first](auto &...curr) { return (curr.remove(entt) + ... + 0u); }, cpools);
for(auto cpools = stl::forward_as_tuple(assure<Type>(), assure<Other>()...); first != last; ++first) {
count += stl::apply([entt = *first](auto &...curr) { return (curr.remove(entt) + ... + 0u); }, cpools);
}
}
@@ -748,21 +745,21 @@ public:
*/
template<typename Type, typename... Other, stl::input_iterator It>
void erase(It first, It last) {
if constexpr(std::is_same_v<It, typename common_type::iterator>) {
std::array cpools{static_cast<common_type *>(&assure<Type>()), static_cast<common_type *>(&assure<Other>())...};
if constexpr(stl::is_same_v<It, typename common_type::iterator>) {
stl::array cpools{static_cast<common_type *>(&assure<Type>()), static_cast<common_type *>(&assure<Other>())...};
for(auto from = cpools.begin(), to = cpools.end(); from != to; ++from) {
if constexpr(sizeof...(Other) != 0u) {
if((*from)->data() == first.data()) {
std::swap(*from, cpools.back());
stl::swap(*from, cpools.back());
}
}
(*from)->erase(first, last);
}
} else {
for(auto cpools = std::forward_as_tuple(assure<Type>(), assure<Other>()...); first != last; ++first) {
std::apply([entt = *first](auto &...curr) { (curr.erase(entt), ...); }, cpools);
for(auto cpools = stl::forward_as_tuple(assure<Type>(), assure<Other>()...); first != last; ++first) {
stl::apply([entt = *first](auto &...curr) { (curr.erase(entt), ...); }, cpools);
}
}
}
@@ -785,7 +782,7 @@ public:
template<typename Func>
void erase_if(const entity_type entt, Func func) {
for(auto [id, cpool]: storage()) {
if(cpool.contains(entt) && func(id, std::as_const(cpool))) {
if(cpool.contains(entt) && func(id, stl::as_const(cpool))) {
cpool.erase(entt);
}
}
@@ -816,7 +813,7 @@ public:
template<typename... Type>
[[nodiscard]] bool all_of([[maybe_unused]] const entity_type entt) const {
if constexpr(sizeof...(Type) == 1u) {
auto *cpool = assure<std::remove_const_t<Type>...>();
auto *cpool = assure<stl::remove_const_t<Type>...>();
return cpool && cpool->contains(entt);
} else {
return (all_of<Type>(entt) && ...);
@@ -849,9 +846,9 @@ public:
template<typename... Type>
[[nodiscard]] decltype(auto) get([[maybe_unused]] const entity_type entt) const {
if constexpr(sizeof...(Type) == 1u) {
return (assure<std::remove_const_t<Type>>()->get(entt), ...);
return (assure<stl::remove_const_t<Type>>()->get(entt), ...);
} else {
return std::forward_as_tuple(get<Type>(entt)...);
return stl::forward_as_tuple(get<Type>(entt)...);
}
}
@@ -859,9 +856,9 @@ public:
template<typename... Type>
[[nodiscard]] decltype(auto) get([[maybe_unused]] const entity_type entt) {
if constexpr(sizeof...(Type) == 1u) {
return (static_cast<storage_for_type<Type> &>(assure<std::remove_const_t<Type>>()).get(entt), ...);
return (static_cast<storage_for_type<Type> &>(assure<stl::remove_const_t<Type>>()).get(entt), ...);
} else {
return std::forward_as_tuple(get<Type>(entt)...);
return stl::forward_as_tuple(get<Type>(entt)...);
}
}
@@ -884,7 +881,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)...);
}
/**
@@ -900,10 +897,10 @@ public:
template<typename... Type>
[[nodiscard]] auto try_get([[maybe_unused]] const entity_type entt) const {
if constexpr(sizeof...(Type) == 1u) {
const auto *cpool = assure<std::remove_const_t<Type>...>();
return (cpool && cpool->contains(entt)) ? std::addressof(cpool->get(entt)) : nullptr;
const auto *cpool = assure<stl::remove_const_t<Type>...>();
return (cpool && cpool->contains(entt)) ? stl::addressof(cpool->get(entt)) : nullptr;
} else {
return std::make_tuple(try_get<Type>(entt)...);
return stl::make_tuple(try_get<Type>(entt)...);
}
}
@@ -911,9 +908,9 @@ public:
template<typename... Type>
[[nodiscard]] auto try_get([[maybe_unused]] const entity_type entt) {
if constexpr(sizeof...(Type) == 1u) {
return (const_cast<Type *>(std::as_const(*this).template try_get<Type>(entt)), ...);
return (const_cast<Type *>(stl::as_const(*this).template try_get<Type>(entt)), ...);
} else {
return std::make_tuple(try_get<Type>(entt)...);
return stl::make_tuple(try_get<Type>(entt)...);
}
}
@@ -941,7 +938,7 @@ public:
* @return True if the entity has no elements assigned, false otherwise.
*/
[[nodiscard]] bool orphan(const entity_type entt) const {
return std::none_of(pools.cbegin(), pools.cend(), [entt](auto &&curr) { return curr.second->contains(entt); });
return stl::none_of(pools.cbegin(), pools.cend(), [entt](auto &&curr) { return curr.second->contains(entt); });
}
/**
@@ -1027,7 +1024,7 @@ public:
[[nodiscard]] basic_view<get_t<storage_for_type<const Type>, storage_for_type<const Other>...>, exclude_t<storage_for_type<const Exclude>...>>
view(exclude_t<Exclude...> = exclude_t{}) const {
basic_view<get_t<storage_for_type<const Type>, storage_for_type<const Other>...>, exclude_t<storage_for_type<const Exclude>...>> elem{};
[&elem](const auto *...curr) { ((curr ? elem.storage(*curr) : void()), ...); }(assure<std::remove_const_t<Exclude>>()..., assure<std::remove_const_t<Other>>()..., assure<std::remove_const_t<Type>>());
[&elem](const auto *...curr) { ((curr ? elem.storage(*curr) : void()), ...); }(assure<stl::remove_const_t<Exclude>>()..., assure<stl::remove_const_t<Other>>()..., assure<stl::remove_const_t<Type>>());
return elem;
}
@@ -1035,7 +1032,7 @@ public:
template<typename Type, typename... Other, typename... Exclude>
[[nodiscard]] basic_view<get_t<storage_for_type<Type>, storage_for_type<Other>...>, exclude_t<storage_for_type<Exclude>...>>
view(exclude_t<Exclude...> = exclude_t{}) {
return {assure<std::remove_const_t<Type>>(), assure<std::remove_const_t<Other>>()..., assure<std::remove_const_t<Exclude>>()...};
return {assure<stl::remove_const_t<Type>>(), assure<stl::remove_const_t<Other>>()..., assure<stl::remove_const_t<Exclude>>()...};
}
/**
@@ -1052,16 +1049,16 @@ public:
using handler_type = group_type::handler;
if(auto it = groups.find(group_type::group_id()); it != groups.cend()) {
return {*std::static_pointer_cast<handler_type>(it->second)};
return {*stl::static_pointer_cast<handler_type>(it->second)};
}
std::shared_ptr<handler_type> handler{};
stl::shared_ptr<handler_type> handler{};
if constexpr(sizeof...(Owned) == 0u) {
handler = std::allocate_shared<handler_type>(get_allocator(), get_allocator(), std::forward_as_tuple(assure<std::remove_const_t<Get>>()...), std::forward_as_tuple(assure<std::remove_const_t<Exclude>>()...));
handler = stl::allocate_shared<handler_type>(get_allocator(), get_allocator(), stl::forward_as_tuple(assure<stl::remove_const_t<Get>>()...), stl::forward_as_tuple(assure<stl::remove_const_t<Exclude>>()...));
} else {
handler = std::allocate_shared<handler_type>(get_allocator(), std::forward_as_tuple(assure<std::remove_const_t<Owned>>()..., assure<std::remove_const_t<Get>>()...), std::forward_as_tuple(assure<std::remove_const_t<Exclude>>()...));
ENTT_ASSERT(std::all_of(groups.cbegin(), groups.cend(), [](const auto &data) { return !(data.second->owned(type_id<Owned>().hash()) || ...); }), "Conflicting groups");
handler = stl::allocate_shared<handler_type>(get_allocator(), stl::forward_as_tuple(assure<stl::remove_const_t<Owned>>()..., assure<stl::remove_const_t<Get>>()...), stl::forward_as_tuple(assure<stl::remove_const_t<Exclude>>()...));
ENTT_ASSERT(stl::all_of(groups.cbegin(), groups.cend(), [](const auto &data) { return !(data.second->owned(type_id<Owned>().hash()) || ...); }), "Conflicting groups");
}
groups.emplace(group_type::group_id(), handler);
@@ -1076,7 +1073,7 @@ public:
using handler_type = group_type::handler;
if(auto it = groups.find(group_type::group_id()); it != groups.cend()) {
return {*std::static_pointer_cast<handler_type>(it->second)};
return {*stl::static_pointer_cast<handler_type>(it->second)};
}
return {};
@@ -1090,7 +1087,7 @@ public:
*/
template<typename... Type>
[[nodiscard]] bool owned() const {
return std::any_of(groups.cbegin(), groups.cend(), [](auto &&data) { return (data.second->owned(type_id<Type>().hash()) || ...); });
return stl::any_of(groups.cbegin(), groups.cend(), [](auto &&data) { return (data.second->owned(type_id<Type>().hash()) || ...); });
}
/**
@@ -1131,11 +1128,11 @@ public:
ENTT_ASSERT(!owned<Type>(), "Cannot sort owned storage");
auto &cpool = assure<Type>();
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)...);
if constexpr(stl::is_invocable_v<Compare, decltype(cpool.get({})), decltype(cpool.get({}))>) {
auto comp = [&cpool, compare = stl::move(compare)](const auto lhs, const auto rhs) { return compare(stl::as_const(cpool.get(lhs)), stl::as_const(cpool.get(rhs))); };
cpool.sort(stl::move(comp), stl::move(algo), stl::forward<Args>(args)...);
} else {
cpool.sort(std::move(compare), std::move(algo), std::forward<Args>(args)...);
cpool.sort(stl::move(compare), stl::move(algo), stl::forward<Args>(args)...);
}
}

View File

@@ -1,11 +1,11 @@
#ifndef ENTT_ENTITY_RUNTIME_VIEW_HPP
#define ENTT_ENTITY_RUNTIME_VIEW_HPP
#include <algorithm>
#include <cstddef>
#include <iterator>
#include <utility>
#include <vector>
#include "../stl/algorithm.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/iterator.hpp"
#include "../stl/utility.hpp"
#include "../stl/vector.hpp"
#include "entity.hpp"
#include "fwd.hpp"
@@ -17,12 +17,12 @@ namespace internal {
template<typename Set>
class runtime_view_iterator final {
using iterator_type = Set::iterator;
using iterator_traits = std::iterator_traits<iterator_type>;
using iterator_traits = stl::iterator_traits<iterator_type>;
[[nodiscard]] bool valid() const {
return (!tombstone_check || *it != tombstone)
&& std::all_of(++pools->begin(), pools->end(), [entt = *it](const auto *curr) { return curr->contains(entt); })
&& std::none_of(filter->cbegin(), filter->cend(), [entt = *it](const auto *curr) { return curr && curr->contains(entt); });
&& stl::all_of(++pools->begin(), pools->end(), [entt = *it](const auto *curr) { return curr->contains(entt); })
&& stl::none_of(filter->cbegin(), filter->cend(), [entt = *it](const auto *curr) { return curr && curr->contains(entt); });
}
public:
@@ -30,7 +30,7 @@ public:
using pointer = iterator_traits::pointer;
using reference = iterator_traits::reference;
using difference_type = iterator_traits::difference_type;
using iterator_category = std::bidirectional_iterator_tag;
using iterator_category = stl::bidirectional_iterator_tag;
constexpr runtime_view_iterator() noexcept
: pools{},
@@ -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;
};
@@ -117,9 +117,9 @@ private:
*/
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 alloc_traits = stl::allocator_traits<Allocator>;
static_assert(stl::is_same_v<typename alloc_traits::value_type, Type *>, "Invalid value type");
using container_type = stl::vector<Type *, Allocator>;
[[nodiscard]] auto offset() const noexcept {
ENTT_ASSERT(!pools.empty(), "Invalid view");
@@ -133,9 +133,9 @@ public:
/*! @brief Underlying entity identifier. */
using entity_type = Type::entity_type;
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Signed integer type. */
using difference_type = std::ptrdiff_t;
using difference_type = stl::ptrdiff_t;
/*! @brief Common type among all storage types. */
using common_type = Type;
/*! @brief Bidirectional iterator type. */
@@ -174,8 +174,8 @@ public:
* @param allocator The allocator to use.
*/
basic_runtime_view(basic_runtime_view &&other, const allocator_type &allocator)
: pools{std::move(other.pools), allocator},
filter{std::move(other.filter), allocator} {}
: pools{stl::move(other.pools), allocator},
filter{stl::move(other.filter), allocator} {}
/*! @brief Default destructor. */
~basic_runtime_view() = default;
@@ -197,7 +197,7 @@ public:
* @param other View to exchange the content with.
*/
void swap(basic_runtime_view &other) noexcept {
using std::swap;
using stl::swap;
swap(pools, other.pools);
swap(filter, other.filter);
}
@@ -225,7 +225,7 @@ public:
if(pools.empty() || !(base.size() < pools.front()->size())) {
pools.push_back(&base);
} else {
pools.push_back(std::exchange(pools.front(), &base));
pools.push_back(stl::exchange(pools.front(), &base));
}
return *this;
@@ -286,8 +286,8 @@ public:
*/
[[nodiscard]] bool contains(const entity_type entt) const {
return !pools.empty()
&& std::all_of(pools.cbegin(), pools.cend(), [entt](const auto *curr) { return curr->contains(entt); })
&& std::none_of(filter.cbegin(), filter.cend(), [entt](const auto *curr) { return curr && curr->contains(entt); })
&& stl::all_of(pools.cbegin(), pools.cend(), [entt](const auto *curr) { return curr->contains(entt); })
&& stl::none_of(filter.cbegin(), filter.cend(), [entt](const auto *curr) { return curr && curr->contains(entt); })
&& pools.front()->index(entt) < offset();
}

View File

@@ -1,17 +1,15 @@
#ifndef ENTT_ENTITY_SNAPSHOT_HPP
#define ENTT_ENTITY_SNAPSHOT_HPP
#include <concepts>
#include <cstddef>
#include <iterator>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>
#include "../config/config.h"
#include "../container/dense_map.hpp"
#include "../core/type_traits.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/iterator.hpp"
#include "../stl/tuple.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "entity.hpp"
#include "fwd.hpp"
#include "view.hpp"
@@ -45,7 +43,7 @@ void orphans(Registry &registry) {
*/
template<typename Registry>
class basic_snapshot {
static_assert(!std::is_const_v<Registry>, "Non-const registry type required");
static_assert(!stl::is_const_v<Registry>, "Non-const registry type required");
using traits_type = entt_traits<typename Registry::entity_type>;
public:
@@ -97,7 +95,7 @@ public:
archive(static_cast<traits_type::entity_type>(storage->size()));
if constexpr(std::is_same_v<Type, entity_type>) {
if constexpr(stl::is_same_v<Type, entity_type>) {
archive(static_cast<traits_type::entity_type>(storage->free_list()));
for(auto first = base.rbegin(), last = base.rend(); first != last; ++first) {
@@ -109,12 +107,12 @@ public:
archive(static_cast<entity_type>(null));
} else {
archive(entt);
std::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()) {
std::apply([&archive](auto &&...args) { (archive(std::forward<decltype(args)>(args)), ...); }, elem);
stl::apply([&archive](auto &&...args) { (archive(stl::forward<decltype(args)>(args)), ...); }, elem);
}
}
} else {
@@ -137,15 +135,15 @@ public:
*/
template<typename Type, typename Archive>
const basic_snapshot &get(Archive &archive, stl::input_iterator auto first, stl::input_iterator auto last, const id_type id = type_hash<Type>::value()) const {
static_assert(!std::is_same_v<Type, entity_type>, "Entity types not supported");
static_assert(!stl::is_same_v<Type, entity_type>, "Entity types not supported");
if(const auto *storage = reg->template storage<Type>(id); storage && !storage->empty()) {
archive(static_cast<traits_type::entity_type>(std::distance(first, last)));
archive(static_cast<traits_type::entity_type>(stl::distance(first, last)));
for(; first != last; ++first) {
if(const auto entt = *first; storage->contains(entt)) {
archive(entt);
std::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));
}
@@ -173,7 +171,7 @@ private:
*/
template<typename Registry>
class basic_snapshot_loader {
static_assert(!std::is_const_v<Registry>, "Non-const registry type required");
static_assert(!stl::is_const_v<Registry>, "Non-const registry type required");
using traits_type = entt_traits<typename Registry::entity_type>;
public:
@@ -228,7 +226,7 @@ public:
archive(length);
if constexpr(std::is_same_v<Type, entity_type>) {
if constexpr(stl::is_same_v<Type, entity_type>) {
typename traits_type::entity_type count{};
entity_type placeholder{};
@@ -252,12 +250,12 @@ public:
const auto entity = other.contains(entt) ? entt : other.generate(entt);
ENTT_ASSERT(entity == entt, "Entity not available for use");
if constexpr(std::tuple_size_v<decltype(storage.get_as_tuple({}))> == 0u) {
if constexpr(stl::tuple_size_v<decltype(storage.get_as_tuple({}))> == 0u) {
storage.emplace(entity);
} else {
Type elem{};
archive(elem);
storage.emplace(entity, std::move(elem));
storage.emplace(entity, stl::move(elem));
}
}
}
@@ -303,7 +301,7 @@ private:
*/
template<typename Registry>
class basic_continuous_loader {
static_assert(!std::is_const_v<Registry>, "Non-const registry type required");
static_assert(!stl::is_const_v<Registry>, "Non-const registry type required");
using traits_type = entt_traits<typename Registry::entity_type>;
void restore(Registry::entity_type entt) {
@@ -312,7 +310,7 @@ class basic_continuous_loader {
remloc[entity].second = reg->create();
}
} else {
remloc.insert_or_assign(entity, std::make_pair(entt, reg->create()));
remloc.insert_or_assign(entity, stl::make_pair(entt, reg->create()));
}
}
@@ -322,27 +320,27 @@ class basic_continuous_loader {
Container other;
for(auto &&pair: container) {
using first_type = std::remove_const_t<typename std::decay_t<decltype(pair)>::first_type>;
using second_type = std::decay_t<decltype(pair)>::second_type;
using first_type = stl::remove_const_t<typename stl::decay_t<decltype(pair)>::first_type>;
using second_type = stl::decay_t<decltype(pair)>::second_type;
if constexpr(std::is_same_v<first_type, entity_type> && std::is_same_v<second_type, entity_type>) {
if constexpr(stl::is_same_v<first_type, entity_type> && stl::is_same_v<second_type, entity_type>) {
other.emplace(map(pair.first), map(pair.second));
} else if constexpr(std::is_same_v<first_type, entity_type>) {
other.emplace(map(pair.first), std::move(pair.second));
} else if constexpr(stl::is_same_v<first_type, entity_type>) {
other.emplace(map(pair.first), stl::move(pair.second));
} else {
static_assert(std::is_same_v<second_type, entity_type>, "Neither the key nor the value are of entity type");
other.emplace(std::move(pair.first), map(pair.second));
static_assert(stl::is_same_v<second_type, entity_type>, "Neither the key nor the value are of entity type");
other.emplace(stl::move(pair.first), map(pair.second));
}
}
using std::swap;
using stl::swap;
swap(container, other);
}
template<typename Container>
auto update(char, Container &container) -> decltype(typename Container::value_type{}, void()) {
// vector like container
static_assert(std::is_same_v<typename Container::value_type, entity_type>, "Invalid value type");
static_assert(stl::is_same_v<typename Container::value_type, entity_type>, "Invalid value type");
for(auto &&entt: container) {
entt = map(entt);
@@ -351,9 +349,9 @@ class basic_continuous_loader {
template<typename Component, typename Other, typename Member>
void update([[maybe_unused]] Component &instance, [[maybe_unused]] Member Other::*member) {
if constexpr(!std::is_same_v<Component, Other>) {
if constexpr(!stl::is_same_v<Component, Other>) {
return;
} else if constexpr(std::is_same_v<Member, entity_type>) {
} else if constexpr(stl::is_same_v<Member, entity_type>) {
instance.*member = map(instance.*member);
} else {
// maybe a container? let's try...
@@ -418,18 +416,18 @@ public:
archive(length);
if constexpr(std::is_same_v<Type, entity_type>) {
if constexpr(stl::is_same_v<Type, entity_type>) {
typename traits_type::entity_type in_use{};
storage.reserve(length);
archive(in_use);
for(std::size_t pos{}; pos < in_use; ++pos) {
for(stl::size_t pos{}; pos < in_use; ++pos) {
archive(entt);
restore(entt);
}
for(std::size_t pos = in_use; pos < length; ++pos) {
for(stl::size_t pos = in_use; pos < length; ++pos) {
archive(entt);
if(const auto entity = to_entity(entt); remloc.contains(entity)) {
@@ -449,12 +447,12 @@ public:
if(archive(entt); entt != null) {
restore(entt);
if constexpr(std::tuple_size_v<decltype(storage.get_as_tuple({}))> == 0u) {
if constexpr(stl::tuple_size_v<decltype(storage.get_as_tuple({}))> == 0u) {
storage.emplace(map(entt));
} else {
Type elem{};
archive(elem);
storage.emplace(map(entt), std::move(elem));
storage.emplace(map(entt), stl::move(elem));
}
}
}
@@ -502,7 +500,7 @@ public:
}
private:
dense_map<typename traits_type::entity_type, std::pair<entity_type, entity_type>> remloc;
dense_map<typename traits_type::entity_type, stl::pair<entity_type, entity_type>> remloc;
registry_type *reg;
};

View File

@@ -2,19 +2,18 @@
#define ENTT_ENTITY_SPARSE_SET_HPP
#include <compare>
#include <concepts>
#include <cstddef>
#include <iterator>
#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/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/iterator.hpp"
#include "../stl/memory.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "../stl/vector.hpp"
#include "entity.hpp"
#include "fwd.hpp"
@@ -29,7 +28,7 @@ struct sparse_set_iterator final {
using pointer = Container::const_pointer;
using reference = Container::const_reference;
using difference_type = Container::difference_type;
using iterator_category = std::random_access_iterator_tag;
using iterator_category = stl::random_access_iterator_tag;
constexpr sparse_set_iterator() noexcept
: packed{},
@@ -80,14 +79,14 @@ struct sparse_set_iterator final {
}
[[nodiscard]] constexpr pointer operator->() const noexcept {
return std::addressof(operator[](0));
return stl::addressof(operator[](0));
}
[[nodiscard]] constexpr reference operator*() const noexcept {
return operator[](0);
}
[[nodiscard]] constexpr std::ptrdiff_t operator-(const sparse_set_iterator &other) const noexcept {
[[nodiscard]] constexpr stl::ptrdiff_t operator-(const sparse_set_iterator &other) const noexcept {
// intentionally reversed due to backward iteration
return other.offset - offset;
}
@@ -138,24 +137,24 @@ private:
*/
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 alloc_traits = stl::allocator_traits<Allocator>;
static_assert(stl::is_same_v<typename alloc_traits::value_type, Entity>, "Invalid value type");
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));
static constexpr auto max_size = static_cast<stl::size_t>(traits_type::to_entity(null));
// it could be auto but gcc complains and emits a warning due to a false positive
[[nodiscard]] std::size_t policy_to_head() const noexcept {
return static_cast<size_type>(max_size * static_cast<std::remove_const_t<decltype(max_size)>>(mode != deletion_policy::swap_only));
[[nodiscard]] stl::size_t policy_to_head() const noexcept {
return static_cast<size_type>(max_size * static_cast<stl::remove_const_t<decltype(max_size)>>(mode != deletion_policy::swap_only));
}
[[nodiscard]] auto entity_to_pos(const Entity entt) const noexcept {
return static_cast<size_type>(traits_type::to_entity(entt));
}
[[nodiscard]] auto pos_to_page(const std::size_t pos) const noexcept {
[[nodiscard]] auto pos_to_page(const stl::size_t pos) const noexcept {
return static_cast<size_type>(pos / traits_type::page_size);
}
@@ -187,7 +186,7 @@ class basic_sparse_set {
constexpr entity_type init = null;
auto page_allocator{packed.get_allocator()};
sparse[page] = alloc_traits::allocate(page_allocator, traits_type::page_size);
std::uninitialized_fill(sparse[page], sparse[page] + traits_type::page_size, init);
stl::uninitialized_fill(sparse[page], sparse[page] + traits_type::page_size, init);
}
return sparse[page][fast_mod(pos, traits_type::page_size)];
@@ -196,29 +195,29 @@ class basic_sparse_set {
void release_sparse_pages() {
for(auto page_allocator{packed.get_allocator()}; auto &&page: sparse) {
if(page != nullptr) {
std::destroy(page, page + traits_type::page_size);
stl::destroy(page, page + traits_type::page_size);
alloc_traits::deallocate(page_allocator, page, traits_type::page_size);
page = nullptr;
}
}
}
void swap_at(const std::size_t lhs, const std::size_t rhs) {
void swap_at(const stl::size_t lhs, const stl::size_t rhs) {
auto &from = packed[lhs];
auto &to = packed[rhs];
sparse_ref(from) = traits_type::combine(static_cast<traits_type::entity_type>(rhs), traits_type::to_integral(from));
sparse_ref(to) = traits_type::combine(static_cast<traits_type::entity_type>(lhs), traits_type::to_integral(to));
std::swap(from, to);
stl::swap(from, to);
}
private:
[[nodiscard]] virtual const void *get_at(const std::size_t) const {
[[nodiscard]] virtual const void *get_at(const stl::size_t) const {
return nullptr;
}
virtual void swap_or_move([[maybe_unused]] const std::size_t lhs, [[maybe_unused]] const std::size_t rhs) {
virtual void swap_or_move([[maybe_unused]] const stl::size_t lhs, [[maybe_unused]] const stl::size_t rhs) {
ENTT_ASSERT((mode != deletion_policy::swap_only) || ((lhs < head) == (rhs < head)), "Cross swapping is not supported");
}
@@ -261,8 +260,8 @@ protected:
*/
void in_place_pop(const Entity entt) {
ENTT_ASSERT(mode == deletion_policy::in_place, "Deletion policy mismatch");
const auto pos = entity_to_pos(std::exchange(sparse_ref(entt), null));
packed[pos] = traits_type::combine(static_cast<traits_type::entity_type>(std::exchange(head, pos)), tombstone);
const auto pos = entity_to_pos(stl::exchange(sparse_ref(entt), null));
packed[pos] = traits_type::combine(static_cast<traits_type::entity_type>(stl::exchange(head, pos)), tombstone);
}
/**
@@ -324,7 +323,7 @@ protected:
pos = head;
ENTT_ASSERT(elem == null, "Slot not available");
elem = traits_type::combine(static_cast<traits_type::entity_type>(head), traits_type::to_integral(entt));
head = entity_to_pos(std::exchange(packed[pos], entt));
head = entity_to_pos(stl::exchange(packed[pos], entt));
break;
}
[[fallthrough]];
@@ -362,9 +361,9 @@ public:
/*! @brief Underlying version type. */
using version_type = traits_type::version_type;
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Signed integer type. */
using difference_type = std::ptrdiff_t;
using difference_type = stl::ptrdiff_t;
/*! @brief Pointer type to contained entities. */
using pointer = packed_container_type::const_pointer;
/*! @brief Random access iterator type. */
@@ -372,9 +371,9 @@ public:
/*! @brief Constant random access iterator type. */
using const_iterator = iterator;
/*! @brief Reverse iterator type. */
using reverse_iterator = std::reverse_iterator<iterator>;
using reverse_iterator = stl::reverse_iterator<iterator>;
/*! @brief Constant reverse iterator type. */
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
using const_reverse_iterator = stl::reverse_iterator<const_iterator>;
/*! @brief Default constructor. */
basic_sparse_set()
@@ -419,11 +418,11 @@ public:
* @param other The instance to move from.
*/
basic_sparse_set(basic_sparse_set &&other) noexcept
: sparse{std::move(other.sparse)},
packed{std::move(other.packed)},
: sparse{stl::move(other.sparse)},
packed{stl::move(other.packed)},
descriptor{other.descriptor},
mode{other.mode},
head{std::exchange(other.head, policy_to_head())} {}
head{stl::exchange(other.head, policy_to_head())} {}
/**
* @brief Allocator-extended move constructor.
@@ -431,11 +430,11 @@ public:
* @param allocator The allocator to use.
*/
basic_sparse_set(basic_sparse_set &&other, const allocator_type &allocator)
: sparse{std::move(other.sparse), allocator},
packed{std::move(other.packed), allocator},
: sparse{stl::move(other.sparse), allocator},
packed{stl::move(other.packed), allocator},
descriptor{other.descriptor},
mode{other.mode},
head{std::exchange(other.head, policy_to_head())} {
head{stl::exchange(other.head, policy_to_head())} {
ENTT_ASSERT(alloc_traits::is_always_equal::value || get_allocator() == other.get_allocator(), "Copying a sparse set is not allowed");
}
@@ -466,7 +465,7 @@ public:
* @param other Sparse set to exchange the content with.
*/
void swap(basic_sparse_set &other) noexcept {
using std::swap;
using stl::swap;
swap(sparse, other.sparse);
swap(packed, other.packed);
swap(descriptor, other.descriptor);
@@ -534,14 +533,14 @@ public:
const auto len = sparse.size();
other.reserve(len);
for(size_type cnt{}; auto &&elem: std::as_const(packed)) {
for(size_type cnt{}; auto &&elem: stl::as_const(packed)) {
if(elem != tombstone) {
if(const auto page = pos_to_page(entity_to_pos(elem)); sparse[page] != nullptr) {
if(const auto sz = page + 1u; sz > other.size()) {
other.resize(sz, nullptr);
}
other[page] = std::exchange(sparse[page], nullptr);
other[page] = stl::exchange(sparse[page], nullptr);
if(++cnt == len) {
// early exit due to lack of pages
@@ -651,7 +650,7 @@ public:
* array.
*/
[[nodiscard]] reverse_iterator rbegin() const noexcept {
return std::make_reverse_iterator(end());
return stl::make_reverse_iterator(end());
}
/*! @copydoc rbegin */
@@ -665,7 +664,7 @@ public:
* reversed sparse set.
*/
[[nodiscard]] reverse_iterator rend() const noexcept {
return std::make_reverse_iterator(begin());
return stl::make_reverse_iterator(begin());
}
/*! @copydoc rend */
@@ -749,7 +748,7 @@ public:
/*! @copydoc value */
[[nodiscard]] void *value(const entity_type entt) noexcept {
return const_cast<void *>(std::as_const(*this).value(entt));
return const_cast<void *>(stl::as_const(*this).value(entt));
}
/**
@@ -833,7 +832,7 @@ public:
*/
template<stl::input_iterator It>
void erase(It first, It last) {
if constexpr(std::is_same_v<It, basic_iterator>) {
if constexpr(stl::is_same_v<It, basic_iterator>) {
pop(first, last);
} else {
for(; first != last; ++first) {
@@ -862,7 +861,7 @@ public:
size_type remove(It first, It last) {
size_type count{};
if constexpr(std::is_same_v<It, basic_iterator>) {
if constexpr(stl::is_same_v<It, basic_iterator>) {
while(first != last) {
while(first != last && !contains(*first)) {
++first;
@@ -874,7 +873,7 @@ public:
++first;
}
count += static_cast<size_type>(std::distance(it, first));
count += static_cast<size_type>(stl::distance(it, first));
erase(it, first);
}
} else {
@@ -890,12 +889,12 @@ public:
void compact() {
if(mode == deletion_policy::in_place) {
size_type from = packed.size();
size_type pos = std::exchange(head, max_size);
size_type pos = stl::exchange(head, max_size);
for(; from && packed[from - 1u] == tombstone; --from) {}
while(pos != max_size) {
if(const auto to = std::exchange(pos, entity_to_pos(packed[pos])); to < from) {
if(const auto to = stl::exchange(pos, entity_to_pos(packed[pos])); to < from) {
--from;
swap_or_move(from, to);
@@ -968,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(), stl::move(compare), stl::forward<Args>(args)...);
for(size_type pos{}; pos < length; ++pos) {
auto curr = pos;
@@ -981,7 +980,7 @@ public:
swap_or_move(next, idx);
const auto elem = static_cast<traits_type::entity_type>(curr);
sparse_ref(entt) = traits_type::combine(elem, traits_type::to_integral(packed[curr]));
curr = std::exchange(next, idx);
curr = stl::exchange(next, idx);
}
}
}
@@ -1001,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, stl::move(compare), stl::move(algo), stl::forward<Args>(args)...);
}
/**
@@ -1061,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:

View File

@@ -2,21 +2,19 @@
#define ENTT_ENTITY_STORAGE_HPP
#include <compare>
#include <concepts>
#include <cstddef>
#include <iterator>
#include <memory>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>
#include "../config/config.h"
#include "../core/bit.hpp"
#include "../core/iterator.hpp"
#include "../core/memory.hpp"
#include "../core/type_info.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/iterator.hpp"
#include "../stl/memory.hpp"
#include "../stl/tuple.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "../stl/vector.hpp"
#include "component.hpp"
#include "entity.hpp"
#include "fwd.hpp"
@@ -32,20 +30,20 @@ class storage_iterator final {
template<typename, auto>
friend class storage_iterator;
using container_type = std::remove_const_t<Container>;
using alloc_traits = std::allocator_traits<typename container_type::allocator_type>;
using container_type = stl::remove_const_t<Container>;
using alloc_traits = stl::allocator_traits<typename container_type::allocator_type>;
using iterator_traits = std::iterator_traits<std::conditional_t<
std::is_const_v<Container>,
typename alloc_traits::template rebind_traits<typename std::pointer_traits<typename container_type::value_type>::element_type>::const_pointer,
typename alloc_traits::template rebind_traits<typename std::pointer_traits<typename container_type::value_type>::element_type>::pointer>>;
using iterator_traits = stl::iterator_traits<stl::conditional_t<
stl::is_const_v<Container>,
typename alloc_traits::template rebind_traits<typename stl::pointer_traits<typename container_type::value_type>::element_type>::const_pointer,
typename alloc_traits::template rebind_traits<typename stl::pointer_traits<typename container_type::value_type>::element_type>::pointer>>;
public:
using value_type = iterator_traits::value_type;
using pointer = iterator_traits::pointer;
using reference = iterator_traits::reference;
using difference_type = iterator_traits::difference_type;
using iterator_category = std::random_access_iterator_tag;
using iterator_category = stl::random_access_iterator_tag;
constexpr storage_iterator() noexcept = default;
@@ -53,8 +51,8 @@ public:
: payload{ref},
offset{idx} {}
template<std::same_as<std::remove_const_t<Container>> Other>
requires std::is_const_v<Container>
template<stl::same_as<stl::remove_const_t<Container>> Other>
requires stl::is_const_v<Container>
constexpr storage_iterator(const storage_iterator<Other, Page> &other) noexcept
: storage_iterator{other.payload, other.offset} {}
@@ -96,11 +94,11 @@ public:
[[nodiscard]] constexpr reference operator[](const difference_type value) const noexcept {
const auto pos = static_cast<Container::size_type>(index() - value);
return (*payload)[pos / Page][fast_mod(static_cast<std::size_t>(pos), Page)];
return (*payload)[pos / Page][fast_mod(static_cast<stl::size_t>(pos), Page)];
}
[[nodiscard]] constexpr pointer operator->() const noexcept {
return std::addressof(operator[](0));
return stl::addressof(operator[](0));
}
[[nodiscard]] constexpr reference operator*() const noexcept {
@@ -108,7 +106,7 @@ public:
}
template<typename Other, auto Arg>
[[nodiscard]] constexpr std::ptrdiff_t operator-(const storage_iterator<Other, Arg> &other) const noexcept {
[[nodiscard]] constexpr stl::ptrdiff_t operator-(const storage_iterator<Other, Arg> &other) const noexcept {
// intentionally reversed due to backward iteration
return other.offset - offset;
}
@@ -140,12 +138,12 @@ class extended_storage_iterator final {
public:
using iterator_type = It;
using value_type = decltype(std::tuple_cat(std::make_tuple(*std::declval<It>()), std::forward_as_tuple(*std::declval<Other>()...)));
using value_type = decltype(stl::tuple_cat(stl::make_tuple(*stl::declval<It>()), stl::forward_as_tuple(*stl::declval<Other>()...)));
using pointer = input_iterator_pointer<value_type>;
using reference = value_type;
using difference_type = std::ptrdiff_t;
using iterator_category = std::input_iterator_tag;
using iterator_concept = std::forward_iterator_tag;
using difference_type = stl::ptrdiff_t;
using iterator_category = stl::input_iterator_tag;
using iterator_concept = stl::forward_iterator_tag;
constexpr extended_storage_iterator()
: it{} {}
@@ -154,12 +152,12 @@ public:
: it{base, other...} {}
template<typename... Args>
requires (!std::same_as<Other, Args> && ...) && (std::constructible_from<Other, Args> && ...)
requires (!stl::same_as<Other, Args> && ...) && (stl::constructible_from<Other, Args> && ...)
constexpr extended_storage_iterator(const extended_storage_iterator<It, Args...> &other)
: it{other.it} {}
constexpr extended_storage_iterator &operator++() noexcept {
return ++std::get<It>(it), (++std::get<Other>(it), ...), *this;
return ++stl::get<It>(it), (++stl::get<Other>(it), ...), *this;
}
constexpr extended_storage_iterator operator++(int) noexcept {
@@ -172,20 +170,20 @@ public:
}
[[nodiscard]] constexpr reference operator*() const noexcept {
return {*std::get<It>(it), *std::get<Other>(it)...};
return {*stl::get<It>(it), *stl::get<Other>(it)...};
}
[[nodiscard]] constexpr iterator_type base() const noexcept {
return std::get<It>(it);
return stl::get<It>(it);
}
template<typename... Args>
[[nodiscard]] constexpr bool operator==(const extended_storage_iterator<Args...> &other) const noexcept {
return std::get<0>(it) == std::get<0>(other.it);
return stl::get<0>(it) == stl::get<0>(other.it);
}
private:
std::tuple<It, Other...> it;
stl::tuple<It, Other...> it;
};
} // namespace internal
@@ -207,19 +205,19 @@ private:
* @tparam Allocator Type of allocator used to manage memory and elements.
*/
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>>;
class basic_storage: public basic_sparse_set<Entity, typename stl::allocator_traits<Allocator>::template rebind_alloc<Entity>> {
using alloc_traits = stl::allocator_traits<Allocator>;
static_assert(stl::is_same_v<typename alloc_traits::value_type, Type>, "Invalid value type");
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>;
[[nodiscard]] auto &element_at(const std::size_t pos) const {
[[nodiscard]] auto &element_at(const stl::size_t pos) const {
return payload[pos / traits_type::page_size][fast_mod(pos, traits_type::page_size)];
}
auto assure_at_least(const std::size_t pos) {
auto assure_at_least(const stl::size_t pos) {
const auto idx = pos / traits_type::page_size;
if(!(idx < payload.size())) {
@@ -247,7 +245,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);
@@ -257,18 +255,18 @@ class basic_storage: public basic_sparse_set<Entity, typename std::allocator_tra
return it;
}
void shrink_to_size(const std::size_t sz) {
void shrink_to_size(const stl::size_t sz) {
const auto from = (sz + traits_type::page_size - 1u) / traits_type::page_size;
allocator_type allocator{get_allocator()};
if constexpr(!std::is_trivially_destructible_v<element_type>) {
if constexpr(!stl::is_trivially_destructible_v<element_type>) {
for(auto pos = sz, length = base_type::size(); pos < length; ++pos) {
if constexpr(traits_type::in_place_delete) {
if(base_type::data()[pos] != tombstone) {
alloc_traits::destroy(allocator, std::addressof(element_at(pos)));
alloc_traits::destroy(allocator, stl::addressof(element_at(pos)));
}
} else {
alloc_traits::destroy(allocator, std::addressof(element_at(pos)));
alloc_traits::destroy(allocator, stl::addressof(element_at(pos)));
}
}
}
@@ -281,25 +279,25 @@ class basic_storage: public basic_sparse_set<Entity, typename std::allocator_tra
payload.shrink_to_fit();
}
void swap_at(const std::size_t lhs, const std::size_t rhs) {
using std::swap;
void swap_at(const stl::size_t lhs, const stl::size_t rhs) {
using stl::swap;
swap(element_at(lhs), element_at(rhs));
}
void move_to(const std::size_t lhs, const std::size_t rhs) {
void move_to(const stl::size_t lhs, const stl::size_t rhs) {
auto &elem = element_at(lhs);
allocator_type allocator{get_allocator()};
entt::uninitialized_construct_using_allocator(stl::to_address(assure_at_least(rhs)), allocator, std::move(elem));
alloc_traits::destroy(allocator, std::addressof(elem));
entt::uninitialized_construct_using_allocator(stl::to_address(assure_at_least(rhs)), allocator, stl::move(elem));
alloc_traits::destroy(allocator, stl::addressof(elem));
}
private:
[[nodiscard]] const void *get_at(const std::size_t pos) const final {
return std::addressof(element_at(pos));
[[nodiscard]] const void *get_at(const stl::size_t pos) const final {
return stl::addressof(element_at(pos));
}
void swap_or_move([[maybe_unused]] const std::size_t from, [[maybe_unused]] const std::size_t to) override {
static constexpr bool is_pinned_type = !(std::is_move_constructible_v<Type> && std::is_move_assignable_v<Type>);
void swap_or_move([[maybe_unused]] const stl::size_t from, [[maybe_unused]] const stl::size_t to) override {
static constexpr bool is_pinned_type = !(stl::is_move_constructible_v<Type> && stl::is_move_assignable_v<Type>);
// use a runtime value to avoid compile-time suppression that drives the code coverage tool crazy
ENTT_ASSERT((from + 1u) && !is_pinned_type, "Pinned type");
@@ -325,15 +323,15 @@ protected:
if constexpr(traits_type::in_place_delete) {
base_type::in_place_pop(*first);
alloc_traits::destroy(allocator, std::addressof(elem));
} else if constexpr(std::is_trivially_destructible_v<element_type>) {
elem = std::move(element_at(base_type::size() - 1u));
alloc_traits::destroy(allocator, stl::addressof(elem));
} else if constexpr(stl::is_trivially_destructible_v<element_type>) {
elem = stl::move(element_at(base_type::size() - 1u));
base_type::swap_and_pop(*first);
} else {
auto &other = element_at(base_type::size() - 1u);
// destroying on exit allows reentrant destructors
[[maybe_unused]] auto unused = std::exchange(elem, std::move(other));
alloc_traits::destroy(allocator, std::addressof(other));
[[maybe_unused]] auto unused = stl::exchange(elem, stl::move(other));
alloc_traits::destroy(allocator, stl::addressof(other));
base_type::swap_and_pop(*first);
}
}
@@ -341,7 +339,7 @@ protected:
/*! @brief Erases all entities of a storage. */
void pop_all() override {
if constexpr(std::is_trivially_destructible_v<element_type>) {
if constexpr(stl::is_trivially_destructible_v<element_type>) {
base_type::pop_all();
} else {
allocator_type allocator{get_allocator()};
@@ -350,11 +348,11 @@ protected:
if constexpr(traits_type::in_place_delete) {
if(*first != tombstone) {
base_type::in_place_pop(*first);
alloc_traits::destroy(allocator, std::addressof(element_at(static_cast<size_type>(first.index()))));
alloc_traits::destroy(allocator, stl::addressof(element_at(static_cast<size_type>(first.index()))));
}
} else {
base_type::swap_and_pop(*first);
alloc_traits::destroy(allocator, std::addressof(element_at(static_cast<size_type>(first.index()))));
alloc_traits::destroy(allocator, stl::addressof(element_at(static_cast<size_type>(first.index()))));
}
}
}
@@ -369,13 +367,13 @@ protected:
*/
underlying_iterator try_emplace([[maybe_unused]] const Entity entt, [[maybe_unused]] const bool force_back, const void *value) override {
if(value != nullptr) {
if constexpr(std::is_copy_constructible_v<element_type>) {
if constexpr(stl::is_copy_constructible_v<element_type>) {
return emplace_element(entt, force_back, *static_cast<const element_type *>(value));
} else {
return base_type::end();
}
} else {
if constexpr(std::is_default_constructible_v<element_type>) {
if constexpr(stl::is_default_constructible_v<element_type>) {
return emplace_element(entt, force_back);
} else {
return base_type::end();
@@ -395,9 +393,9 @@ public:
/*! @brief Underlying entity identifier. */
using entity_type = Entity;
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Signed integer type. */
using difference_type = std::ptrdiff_t;
using difference_type = stl::ptrdiff_t;
/*! @brief Pointer type to contained elements. */
using pointer = container_type::pointer;
/*! @brief Constant pointer type to contained elements. */
@@ -407,9 +405,9 @@ public:
/*! @brief Constant random access iterator type. */
using const_iterator = internal::storage_iterator<const container_type, traits_type::page_size>;
/*! @brief Reverse iterator type. */
using reverse_iterator = std::reverse_iterator<iterator>;
using reverse_iterator = stl::reverse_iterator<iterator>;
/*! @brief Constant reverse iterator type. */
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
using const_reverse_iterator = stl::reverse_iterator<const_iterator>;
/*! @brief Extended iterable storage proxy. */
using iterable = iterable_adaptor<internal::extended_storage_iterator<typename base_type::iterator, iterator>>;
/*! @brief Constant extended iterable storage proxy. */
@@ -442,7 +440,7 @@ public:
*/
basic_storage(basic_storage &&other) noexcept
: base_type{static_cast<base_type &&>(other)},
payload{std::move(other.payload)} {}
payload{stl::move(other.payload)} {}
/**
* @brief Allocator-extended move constructor.
@@ -451,7 +449,7 @@ public:
*/
basic_storage(basic_storage &&other, const allocator_type &allocator)
: base_type{static_cast<base_type &&>(other), allocator},
payload{std::move(other.payload), allocator} {
payload{stl::move(other.payload), allocator} {
ENTT_ASSERT(alloc_traits::is_always_equal::value || get_allocator() == other.get_allocator(), "Copying a storage is not allowed");
}
@@ -483,7 +481,7 @@ public:
* @param other Storage to exchange the content with.
*/
void swap(basic_storage &other) noexcept {
using std::swap;
using stl::swap;
swap(payload, other.payload);
base_type::swap(other);
}
@@ -589,7 +587,7 @@ public:
* @return An iterator to the first instance of the reversed internal array.
*/
[[nodiscard]] const_reverse_iterator crbegin() const noexcept {
return std::make_reverse_iterator(cend());
return stl::make_reverse_iterator(cend());
}
/*! @copydoc crbegin */
@@ -599,7 +597,7 @@ public:
/*! @copydoc rbegin */
[[nodiscard]] reverse_iterator rbegin() noexcept {
return std::make_reverse_iterator(end());
return stl::make_reverse_iterator(end());
}
/**
@@ -608,7 +606,7 @@ public:
* reversed internal array.
*/
[[nodiscard]] const_reverse_iterator crend() const noexcept {
return std::make_reverse_iterator(cbegin());
return stl::make_reverse_iterator(cbegin());
}
/*! @copydoc crend */
@@ -618,7 +616,7 @@ public:
/*! @copydoc rend */
[[nodiscard]] reverse_iterator rend() noexcept {
return std::make_reverse_iterator(begin());
return stl::make_reverse_iterator(begin());
}
/**
@@ -637,7 +635,7 @@ public:
/*! @copydoc get */
[[nodiscard]] value_type &get(const entity_type entt) noexcept {
return const_cast<value_type &>(std::as_const(*this).get(entt));
return const_cast<value_type &>(stl::as_const(*this).get(entt));
}
/**
@@ -645,13 +643,13 @@ public:
* @param entt A valid identifier.
* @return The object assigned to the entity as a tuple.
*/
[[nodiscard]] std::tuple<const value_type &> get_as_tuple(const entity_type entt) const noexcept {
return std::forward_as_tuple(get(entt));
[[nodiscard]] stl::tuple<const value_type &> get_as_tuple(const entity_type entt) const noexcept {
return stl::forward_as_tuple(get(entt));
}
/*! @copydoc get_as_tuple */
[[nodiscard]] std::tuple<value_type &> get_as_tuple(const entity_type entt) noexcept {
return std::forward_as_tuple(get(entt));
[[nodiscard]] stl::tuple<value_type &> get_as_tuple(const entity_type entt) noexcept {
return stl::forward_as_tuple(get(entt));
}
/**
@@ -668,11 +666,11 @@ 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)...});
if constexpr(stl::is_aggregate_v<value_type> && (sizeof...(Args) != 0u || !stl::is_default_constructible_v<value_type>)) {
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()));
}
}
@@ -688,7 +686,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;
}
@@ -726,7 +724,7 @@ public:
* @return Iterator pointing to the first element inserted, if any.
*/
template<stl::input_iterator It>
requires std::same_as<typename std::iterator_traits<It>::value_type, value_type>
requires stl::same_as<typename stl::iterator_traits<It>::value_type, value_type>
iterator insert(stl::input_iterator auto first, stl::input_iterator auto last, It from) {
for(; first != last; ++first, ++from) {
emplace_element(*first, true, *from);
@@ -776,9 +774,9 @@ private:
template<typename Type, typename Entity, typename Allocator>
requires (component_traits<Type, Entity>::page_size == 0u)
class basic_storage<Type, Entity, Allocator>
: 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");
: public basic_sparse_set<Entity, typename stl::allocator_traits<Allocator>::template rebind_alloc<Entity>> {
using alloc_traits = stl::allocator_traits<Allocator>;
static_assert(stl::is_same_v<typename alloc_traits::value_type, Type>, "Invalid value type");
using traits_type = component_traits<Type, Entity>;
public:
@@ -793,9 +791,9 @@ public:
/*! @brief Underlying entity identifier. */
using entity_type = Entity;
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Signed integer type. */
using difference_type = std::ptrdiff_t;
using difference_type = stl::ptrdiff_t;
/*! @brief Extended iterable storage proxy. */
using iterable = iterable_adaptor<internal::extended_storage_iterator<typename base_type::iterator>>;
/*! @brief Constant extended iterable storage proxy. */
@@ -833,7 +831,7 @@ public:
* @param allocator The allocator to use.
*/
basic_storage(basic_storage &&other, const allocator_type &allocator)
: base_type{std::move(other), allocator} {}
: base_type{stl::move(other), allocator} {}
/*! @brief Default destructor. */
~basic_storage() override = default;
@@ -877,9 +875,9 @@ public:
* @param entt A valid identifier.
* @return Returns an empty tuple.
*/
[[nodiscard]] std::tuple<> get_as_tuple([[maybe_unused]] const entity_type entt) const noexcept {
[[nodiscard]] stl::tuple<> get_as_tuple([[maybe_unused]] const entity_type entt) const noexcept {
ENTT_ASSERT(base_type::contains(entt), "Invalid entity");
return std::tuple{};
return stl::tuple{};
}
/**
@@ -904,7 +902,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)(), ...);
}
/**
@@ -959,8 +957,8 @@ public:
template<typename Entity, typename Allocator>
class basic_storage<Entity, Entity, Allocator>
: public basic_sparse_set<Entity, Allocator> {
using alloc_traits = std::allocator_traits<Allocator>;
static_assert(std::is_same_v<typename alloc_traits::value_type, Entity>, "Invalid value type");
using alloc_traits = stl::allocator_traits<Allocator>;
static_assert(stl::is_same_v<typename alloc_traits::value_type, Entity>, "Invalid value type");
using underlying_iterator = basic_sparse_set<Entity, Allocator>::basic_iterator;
using traits_type = entt_traits<Entity>;
@@ -1009,9 +1007,9 @@ public:
/*! @brief Underlying entity identifier. */
using entity_type = Entity;
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Signed integer type. */
using difference_type = std::ptrdiff_t;
using difference_type = stl::ptrdiff_t;
/*! @brief Extended iterable storage proxy. */
using iterable = iterable_adaptor<internal::extended_storage_iterator<typename base_type::iterator>>;
/*! @brief Constant extended iterable storage proxy. */
@@ -1073,7 +1071,7 @@ public:
*/
basic_storage &operator=(basic_storage &&other) noexcept {
placeholder = other.placeholder;
base_type::operator=(std::move(other));
base_type::operator=(stl::move(other));
return *this;
}
@@ -1082,7 +1080,7 @@ public:
* @param other Storage to exchange the content with.
*/
void swap(basic_storage &other) noexcept {
using std::swap;
using stl::swap;
swap(placeholder, other.placeholder);
base_type::swap(other);
}
@@ -1105,9 +1103,9 @@ public:
* @param entt A valid identifier.
* @return Returns an empty tuple.
*/
[[nodiscard]] std::tuple<> get_as_tuple([[maybe_unused]] const entity_type entt) const noexcept {
[[nodiscard]] stl::tuple<> get_as_tuple([[maybe_unused]] const entity_type entt) const noexcept {
ENTT_ASSERT(base_type::index(entt) < base_type::free_list(), "The requested entity is not a live one");
return std::tuple{};
return stl::tuple{};
}
/**
@@ -1165,7 +1163,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)(), ...);
}
/**
@@ -1176,7 +1174,7 @@ public:
* @return An iterable object to use to _visit_ the storage.
*/
[[nodiscard]] iterable each() noexcept {
return std::as_const(*this).each();
return stl::as_const(*this).each();
}
/*! @copydoc each */
@@ -1194,7 +1192,7 @@ public:
* @return A reverse iterable object to use to _visit_ the storage.
*/
[[nodiscard]] reverse_iterable reach() noexcept {
return std::as_const(*this).reach();
return stl::as_const(*this).reach();
}
/*! @copydoc reach */

View File

@@ -1,17 +1,17 @@
#ifndef ENTT_ENTITY_VIEW_HPP
#define ENTT_ENTITY_VIEW_HPP
#include <array>
#include <concepts>
#include <cstddef>
#include <iterator>
#include <tuple>
#include <type_traits>
#include <utility>
#include "../config/config.h"
#include "../core/concepts.hpp"
#include "../core/iterator.hpp"
#include "../core/type_traits.hpp"
#include "../stl/array.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/iterator.hpp"
#include "../stl/tuple.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "entity.hpp"
#include "fwd.hpp"
@@ -41,13 +41,13 @@ const Type *view_placeholder() {
}
template<typename It>
[[nodiscard]] bool fully_initialized(It first, const It last, const std::remove_pointer_t<typename std::iterator_traits<It>::value_type> *placeholder) noexcept {
[[nodiscard]] bool fully_initialized(It first, const It last, const stl::remove_pointer_t<typename stl::iterator_traits<It>::value_type> *placeholder) noexcept {
for(; (first != last) && *first != placeholder; ++first) {}
return first == last;
}
template<typename Result, typename View, typename Other, std::size_t... GLhs, std::size_t... ELhs, std::size_t... GRhs, std::size_t... ERhs>
[[nodiscard]] Result view_pack(const View &view, const Other &other, std::index_sequence<GLhs...>, std::index_sequence<ELhs...>, std::index_sequence<GRhs...>, std::index_sequence<ERhs...>) {
template<typename Result, typename View, typename Other, stl::size_t... GLhs, stl::size_t... ELhs, stl::size_t... GRhs, stl::size_t... ERhs>
[[nodiscard]] Result view_pack(const View &view, const Other &other, stl::index_sequence<GLhs...>, stl::index_sequence<ELhs...>, stl::index_sequence<GRhs...>, stl::index_sequence<ERhs...>) {
Result elem{};
// friend-initialization, avoid multiple calls to refresh
elem.pools = {view.template storage<GLhs>()..., other.template storage<GRhs>()...};
@@ -57,13 +57,13 @@ template<typename Result, typename View, typename Other, std::size_t... GLhs, st
return elem;
}
template<typename Type, bool Checked, std::size_t Get, std::size_t Exclude>
template<typename Type, bool Checked, stl::size_t Get, stl::size_t Exclude>
class view_iterator final {
template<typename, typename...>
friend struct extended_view_iterator;
using iterator_type = Type::const_iterator;
using iterator_traits = std::iterator_traits<iterator_type>;
using iterator_traits = stl::iterator_traits<iterator_type>;
[[nodiscard]] bool valid(const iterator_traits::value_type entt) const noexcept {
return (!Checked || (entt != tombstone))
@@ -80,7 +80,7 @@ public:
using pointer = iterator_traits::pointer;
using reference = iterator_traits::reference;
using difference_type = iterator_traits::difference_type;
using iterator_category = std::forward_iterator_tag;
using iterator_category = stl::forward_iterator_tag;
constexpr view_iterator() noexcept
: it{},
@@ -88,7 +88,7 @@ public:
filter{},
index{} {}
view_iterator(iterator_type first, std::array<const Type *, Get> value, std::array<const Type *, Exclude> excl, const std::size_t idx) noexcept
view_iterator(iterator_type first, stl::array<const Type *, Get> value, stl::array<const Type *, Exclude> excl, const stl::size_t idx) noexcept
: it{first},
pools{value},
filter{excl},
@@ -123,20 +123,20 @@ public:
private:
iterator_type it;
std::array<const Type *, Get> pools;
std::array<const Type *, Exclude> filter;
stl::array<const Type *, Get> pools;
stl::array<const Type *, Exclude> filter;
difference_type index;
};
template<typename It, typename... Get>
struct extended_view_iterator final {
using iterator_type = It;
using value_type = decltype(std::tuple_cat(std::make_tuple(*std::declval<It>()), std::declval<Get>().get_as_tuple({})...));
using value_type = decltype(stl::tuple_cat(stl::make_tuple(*stl::declval<It>()), stl::declval<Get>().get_as_tuple({})...));
using pointer = input_iterator_pointer<value_type>;
using reference = value_type;
using difference_type = std::ptrdiff_t;
using iterator_category = std::input_iterator_tag;
using iterator_concept = std::forward_iterator_tag;
using difference_type = stl::ptrdiff_t;
using iterator_category = stl::input_iterator_tag;
using iterator_concept = stl::forward_iterator_tag;
constexpr extended_view_iterator()
: it{} {}
@@ -154,9 +154,9 @@ struct extended_view_iterator final {
}
[[nodiscard]] reference operator*() const noexcept {
return [this]<auto... Index>(std::index_sequence<Index...>) {
return std::tuple_cat(std::make_tuple(*it), static_cast<Get *>(const_cast<constness_as_t<typename Get::base_type, Get> *>(std::get<Index>(it.pools)))->get_as_tuple(*it)...);
}(std::index_sequence_for<Get...>{});
return [this]<auto... Index>(stl::index_sequence<Index...>) {
return stl::tuple_cat(stl::make_tuple(*it), static_cast<Get *>(const_cast<constness_as_t<typename Get::base_type, Get> *>(stl::get<Index>(it.pools)))->get_as_tuple(*it)...);
}(stl::index_sequence_for<Get...>{});
}
[[nodiscard]] pointer operator->() const noexcept {
@@ -208,10 +208,10 @@ class basic_view;
* @tparam Get Number of storage iterated by the view.
* @tparam Exclude Number of storage used to filter the view.
*/
template<cvref_unqualified Type, bool Checked, std::size_t Get, std::size_t Exclude>
template<cvref_unqualified Type, bool Checked, stl::size_t Get, stl::size_t Exclude>
class basic_common_view {
template<typename Return, typename View, typename Other, std::size_t... GLhs, std::size_t... ELhs, std::size_t... GRhs, std::size_t... ERhs>
friend Return internal::view_pack(const View &, const Other &, std::index_sequence<GLhs...>, std::index_sequence<ELhs...>, std::index_sequence<GRhs...>, std::index_sequence<ERhs...>);
template<typename Return, typename View, typename Other, stl::size_t... GLhs, stl::size_t... ELhs, stl::size_t... GRhs, stl::size_t... ERhs>
friend Return internal::view_pack(const View &, const Other &, stl::index_sequence<GLhs...>, stl::index_sequence<ELhs...>, stl::index_sequence<GRhs...>, stl::index_sequence<ERhs...>);
[[nodiscard]] auto offset() const noexcept {
ENTT_ASSERT(index != Get, "Invalid view");
@@ -238,28 +238,28 @@ protected:
}
}
basic_common_view(std::array<const Type *, Get> value, std::array<const Type *, Exclude> excl) noexcept
basic_common_view(stl::array<const Type *, Get> value, stl::array<const Type *, Exclude> excl) noexcept
: pools{value},
filter{excl},
index{Get} {
unchecked_refresh();
}
[[nodiscard]] const Type *pool_at(const std::size_t pos) const noexcept {
[[nodiscard]] const Type *pool_at(const stl::size_t pos) const noexcept {
return pools[pos];
}
void pool_at(const std::size_t pos, const Type *elem) noexcept {
void pool_at(const stl::size_t pos, const Type *elem) noexcept {
ENTT_ASSERT(elem != nullptr, "Unexpected element");
pools[pos] = elem;
refresh();
}
[[nodiscard]] const Type *filter_at(const std::size_t pos) const noexcept {
[[nodiscard]] const Type *filter_at(const stl::size_t pos) const noexcept {
return (filter[pos] == placeholder) ? nullptr : filter[pos];
}
void filter_at(const std::size_t pos, const Type *elem) noexcept {
void filter_at(const stl::size_t pos, const Type *elem) noexcept {
ENTT_ASSERT(elem != nullptr, "Unexpected element");
filter[pos] = elem;
}
@@ -268,7 +268,7 @@ protected:
return internal::none_of(filter.begin(), filter.end(), entt);
}
void use(const std::size_t pos) noexcept {
void use(const stl::size_t pos) noexcept {
index = (index != Get) ? pos : Get;
}
/*! @endcond */
@@ -279,9 +279,9 @@ public:
/*! @brief Underlying entity identifier. */
using entity_type = Type::entity_type;
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Signed integer type. */
using difference_type = std::ptrdiff_t;
using difference_type = stl::ptrdiff_t;
/*! @brief Forward iterator type. */
using iterator = internal::view_iterator<common_type, Checked, Get, Exclude>;
@@ -387,8 +387,8 @@ public:
}
private:
std::array<const common_type *, Get> pools{};
std::array<const common_type *, Exclude> filter{};
stl::array<const common_type *, Get> pools{};
stl::array<const common_type *, Exclude> filter{};
const common_type *placeholder{internal::view_placeholder<common_type>()};
size_type index{Get};
};
@@ -408,32 +408,32 @@ private:
template<typename... Get, typename... Exclude>
requires (sizeof...(Get) != 0u)
class basic_view<get_t<Get...>, exclude_t<Exclude...>>
: public basic_common_view<std::common_type_t<typename Get::base_type...>, internal::tombstone_check_v<Get...>, sizeof...(Get), sizeof...(Exclude)> {
using base_type = basic_common_view<std::common_type_t<typename Get::base_type...>, internal::tombstone_check_v<Get...>, sizeof...(Get), sizeof...(Exclude)>;
: public basic_common_view<stl::common_type_t<typename Get::base_type...>, internal::tombstone_check_v<Get...>, sizeof...(Get), sizeof...(Exclude)> {
using base_type = basic_common_view<stl::common_type_t<typename Get::base_type...>, internal::tombstone_check_v<Get...>, sizeof...(Get), sizeof...(Exclude)>;
template<std::size_t Index>
template<stl::size_t Index>
using element_at = type_list_element_t<Index, type_list<Get..., Exclude...>>;
template<typename Type>
static constexpr std::size_t index_of = type_list_index_v<std::remove_const_t<Type>, type_list<typename Get::element_type..., typename Exclude::element_type...>>;
static constexpr stl::size_t index_of = type_list_index_v<stl::remove_const_t<Type>, type_list<typename Get::element_type..., typename Exclude::element_type...>>;
template<std::size_t Curr, std::size_t Other, typename... Args>
[[nodiscard]] auto dispatch_get(const std::tuple<typename base_type::entity_type, Args...> &curr) const {
template<stl::size_t Curr, stl::size_t Other, typename... Args>
[[nodiscard]] auto dispatch_get(const stl::tuple<typename base_type::entity_type, Args...> &curr) const {
if constexpr(Curr == Other) {
return std::forward_as_tuple(std::get<Args>(curr)...);
return stl::forward_as_tuple(stl::get<Args>(curr)...);
} else {
return storage<Other>()->get_as_tuple(std::get<0>(curr));
return storage<Other>()->get_as_tuple(stl::get<0>(curr));
}
}
template<std::size_t Curr, typename Func, std::size_t... Index>
void each(Func func, std::index_sequence<Index...>) const {
template<stl::size_t Curr, typename Func, stl::size_t... Index>
void each(Func func, stl::index_sequence<Index...>) const {
for(const auto curr: storage<Curr>()->each()) {
if(const auto entt = std::get<0>(curr); (!internal::tombstone_check_v<Get...> || (entt != tombstone)) && ((Curr == Index || base_type::pool_at(Index)->contains(entt)) && ...) && base_type::none_of(entt)) {
if constexpr(is_applicable_v<Func, decltype(std::tuple_cat(std::tuple<entity_type>{}, std::declval<basic_view>().get({})))>) {
std::apply(func, std::tuple_cat(std::make_tuple(entt), dispatch_get<Curr, Index>(curr)...));
if(const auto entt = stl::get<0>(curr); (!internal::tombstone_check_v<Get...> || (entt != tombstone)) && ((Curr == Index || base_type::pool_at(Index)->contains(entt)) && ...) && base_type::none_of(entt)) {
if constexpr(is_applicable_v<Func, decltype(stl::tuple_cat(stl::tuple<entity_type>{}, stl::declval<basic_view>().get({})))>) {
stl::apply(func, stl::tuple_cat(stl::make_tuple(entt), dispatch_get<Curr, Index>(curr)...));
} else {
std::apply(func, std::tuple_cat(dispatch_get<Curr, Index>(curr)...));
stl::apply(func, stl::tuple_cat(dispatch_get<Curr, Index>(curr)...));
}
}
}
@@ -454,7 +454,7 @@ public:
/*! @brief Unsigned integer type. */
using size_type = base_type::size_type;
/*! @brief Signed integer type. */
using difference_type = std::ptrdiff_t;
using difference_type = stl::ptrdiff_t;
/*! @brief Forward iterator type. */
using iterator = base_type::iterator;
/*! @brief Iterable view type. */
@@ -478,8 +478,8 @@ public:
* @param value The storage for the types to iterate.
* @param excl The storage for the types used to filter the view.
*/
basic_view(std::tuple<Get &...> value, std::tuple<Exclude &...> excl = {}) noexcept
: basic_view{std::make_from_tuple<basic_view>(std::tuple_cat(value, excl))} {}
basic_view(stl::tuple<Get &...> value, stl::tuple<Exclude &...> excl = {}) noexcept
: basic_view{stl::make_from_tuple<basic_view>(stl::tuple_cat(value, excl))} {}
/**
* @brief Constructs a view from a convertible counterpart.
@@ -487,7 +487,7 @@ public:
* @param other A view to convert from.
*/
template<typename... Args>
requires (!std::same_as<basic_view, basic_view<Args...>>)
requires (!stl::same_as<basic_view, basic_view<Args...>>)
basic_view(const basic_view<Args...> &other) noexcept
: basic_view{} {
(storage_if(other.template storage<typename Get::element_type>()), ...);
@@ -507,7 +507,7 @@ public:
* @brief Forces a view to use a given element to drive iterations
* @tparam Index Index of the element to use to drive iterations.
*/
template<std::size_t Index>
template<stl::size_t Index>
void use() noexcept {
base_type::use(Index);
}
@@ -527,7 +527,7 @@ public:
* @tparam Index Index of the storage to return.
* @return The storage for the given index.
*/
template<std::size_t Index>
template<stl::size_t Index>
[[nodiscard]] auto *storage() const noexcept {
if constexpr(Index < sizeof...(Get)) {
return static_cast<element_at<Index> *>(const_cast<constness_as_t<common_type, element_at<Index>> *>(base_type::pool_at(Index)));
@@ -552,9 +552,9 @@ public:
* @tparam Type Type of storage to assign to the view.
* @param elem A storage to assign to the view.
*/
template<std::size_t Index, typename Type>
template<stl::size_t Index, typename Type>
void storage(Type &elem) noexcept {
static_assert(std::is_convertible_v<Type &, element_at<Index> &>, "Unexpected type");
static_assert(stl::is_convertible_v<Type &, element_at<Index> &>, "Unexpected type");
if constexpr(Index < sizeof...(Get)) {
base_type::pool_at(Index, &elem);
@@ -590,16 +590,16 @@ public:
* @param entt A valid identifier.
* @return The elements assigned to the entity.
*/
template<std::size_t... Index>
template<stl::size_t... Index>
[[nodiscard]] decltype(auto) get(const entity_type entt) const {
if constexpr(sizeof...(Index) == 0) {
return [this, entt]<auto... Idx>(std::index_sequence<Idx...>) {
return std::tuple_cat(this->storage<Idx>()->get_as_tuple(entt)...);
}(std::index_sequence_for<Get...>{});
return [this, entt]<auto... Idx>(stl::index_sequence<Idx...>) {
return stl::tuple_cat(this->storage<Idx>()->get_as_tuple(entt)...);
}(stl::index_sequence_for<Get...>{});
} else if constexpr(sizeof...(Index) == 1) {
return (storage<Index>()->get(entt), ...);
} else {
return std::tuple_cat(storage<Index>()->get_as_tuple(entt)...);
return stl::tuple_cat(storage<Index>()->get_as_tuple(entt)...);
}
}
@@ -620,11 +620,11 @@ public:
*/
template<typename Func>
void each(Func func) const {
[this, &func]<auto... Index>(std::index_sequence<Index...> seq) {
[this, &func]<auto... Index>(stl::index_sequence<Index...> seq) {
if(const auto *view = base_type::handle(); view != nullptr) {
((view == base_type::pool_at(Index) ? each<Index>(std::move(func), seq) : void()), ...);
((view == base_type::pool_at(Index) ? each<Index>(stl::move(func), seq) : void()), ...);
}
}(std::index_sequence_for<Get...>{});
}(stl::index_sequence_for<Get...>{});
}
/**
@@ -646,7 +646,7 @@ public:
* @param other The storage for the type to combine the view with.
* @return A more specific view.
*/
template<std::derived_from<common_type> OGet>
template<stl::derived_from<common_type> OGet>
[[nodiscard]] basic_view<get_t<Get..., OGet>, exclude_t<Exclude...>> operator|(OGet &other) const noexcept {
return *this | basic_view<get_t<OGet>, exclude_t<>>{other};
}
@@ -658,10 +658,10 @@ public:
* @param other The view to combine with.
* @return A more specific view.
*/
template<std::derived_from<common_type>... OGet, std::derived_from<common_type>... OExclude>
template<stl::derived_from<common_type>... OGet, stl::derived_from<common_type>... OExclude>
[[nodiscard]] auto operator|(const basic_view<get_t<OGet...>, exclude_t<OExclude...>> &other) const noexcept {
return internal::view_pack<basic_view<get_t<Get..., OGet...>, exclude_t<Exclude..., OExclude...>>>(
*this, other, std::index_sequence_for<Get...>{}, std::index_sequence_for<Exclude...>{}, std::index_sequence_for<OGet...>{}, std::index_sequence_for<OExclude...>{});
*this, other, stl::index_sequence_for<Get...>{}, stl::index_sequence_for<Exclude...>{}, stl::index_sequence_for<OGet...>{}, stl::index_sequence_for<OExclude...>{});
}
};
@@ -689,13 +689,13 @@ public:
/*! @brief Underlying entity identifier. */
using entity_type = common_type::entity_type;
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Signed integer type. */
using difference_type = std::ptrdiff_t;
using difference_type = stl::ptrdiff_t;
/*! @brief Random access iterator type. */
using iterator = std::conditional_t<Policy == deletion_policy::in_place, internal::view_iterator<common_type, true, 1u, 0u>, typename common_type::iterator>;
using iterator = stl::conditional_t<Policy == deletion_policy::in_place, internal::view_iterator<common_type, true, 1u, 0u>, typename common_type::iterator>;
/*! @brief Reverse iterator type. */
using reverse_iterator = std::conditional_t<Policy == deletion_policy::in_place, void, typename common_type::reverse_iterator>;
using reverse_iterator = stl::conditional_t<Policy == deletion_policy::in_place, void, typename common_type::reverse_iterator>;
/**
* @brief Returns the leading storage of a view, if any.
@@ -912,13 +912,13 @@ public:
/*! @brief Unsigned integer type. */
using size_type = base_type::size_type;
/*! @brief Signed integer type. */
using difference_type = std::ptrdiff_t;
using difference_type = stl::ptrdiff_t;
/*! @brief Random access iterator type. */
using iterator = base_type::iterator;
/*! @brief Reverse iterator type. */
using reverse_iterator = base_type::reverse_iterator;
/*! @brief Iterable view type. */
using iterable = std::conditional_t<Get::storage_policy == deletion_policy::in_place, iterable_adaptor<internal::extended_view_iterator<iterator, Get>>, decltype(std::declval<Get>().each())>;
using iterable = stl::conditional_t<Get::storage_policy == deletion_policy::in_place, iterable_adaptor<internal::extended_view_iterator<iterator, Get>>, decltype(stl::declval<Get>().each())>;
/*! @brief Default constructor to use to create empty, invalid views. */
basic_view() noexcept
@@ -936,8 +936,8 @@ public:
* @brief Constructs a view from a storage class.
* @param value The storage for the type to iterate.
*/
basic_view(std::tuple<Get &> value, std::tuple<> = {}) noexcept
: basic_view{std::get<0>(value)} {}
basic_view(stl::tuple<Get &> value, stl::tuple<> = {}) noexcept
: basic_view{stl::get<0>(value)} {}
/**
* @brief Constructs a view from a convertible counterpart.
@@ -945,7 +945,7 @@ public:
* @param other A view to convert from.
*/
template<typename... Args>
requires (!std::same_as<basic_view, basic_view<Args...>>)
requires (!stl::same_as<basic_view, basic_view<Args...>>)
basic_view(const basic_view<Args...> &other) noexcept
: base_type{} {
storage_if(other.template storage<typename Get::element_type>());
@@ -958,7 +958,7 @@ public:
*/
template<typename Type = Get::element_type>
[[nodiscard]] auto *storage() const noexcept {
static_assert(std::is_same_v<std::remove_const_t<Type>, typename Get::element_type>, "Invalid element type");
static_assert(stl::is_same_v<stl::remove_const_t<Type>, typename Get::element_type>, "Invalid element type");
return storage<0>();
}
@@ -967,7 +967,7 @@ public:
* @tparam Index Index of the storage to return.
* @return The storage for the given index.
*/
template<std::size_t Index>
template<stl::size_t Index>
[[nodiscard]] auto *storage() const noexcept {
static_assert(Index == 0u, "Index out of bounds");
return static_cast<Get *>(const_cast<constness_as_t<common_type, Get> *>(base_type::handle()));
@@ -986,7 +986,7 @@ public:
* @tparam Index Index of the storage to assign to the view.
* @param elem A storage to assign to the view.
*/
template<std::size_t Index>
template<stl::size_t Index>
void storage(Get &elem) noexcept {
static_assert(Index == 0u, "Index out of bounds");
*this = basic_view{elem};
@@ -1017,7 +1017,7 @@ public:
*/
template<typename Elem>
[[nodiscard]] decltype(auto) get(const entity_type entt) const {
static_assert(std::is_same_v<std::remove_const_t<Elem>, typename Get::element_type>, "Invalid element type");
static_assert(stl::is_same_v<stl::remove_const_t<Elem>, typename Get::element_type>, "Invalid element type");
return get<0>(entt);
}
@@ -1027,7 +1027,7 @@ public:
* @param entt A valid identifier.
* @return The element assigned to the entity.
*/
template<std::size_t... Index>
template<stl::size_t... Index>
[[nodiscard]] decltype(auto) get(const entity_type entt) const {
if constexpr(sizeof...(Index) == 0) {
return storage()->get_as_tuple(entt);
@@ -1053,12 +1053,12 @@ public:
*/
template<typename Func>
void each(Func func) const {
if constexpr(is_applicable_v<Func, decltype(std::tuple_cat(std::tuple<entity_type>{}, std::declval<basic_view>().get({})))>) {
if constexpr(is_applicable_v<Func, decltype(stl::tuple_cat(stl::tuple<entity_type>{}, stl::declval<basic_view>().get({})))>) {
for(const auto pack: each()) {
std::apply(func, pack);
stl::apply(func, pack);
}
} else if constexpr(Get::storage_policy == deletion_policy::swap_and_pop || Get::storage_policy == deletion_policy::swap_only) {
if constexpr(std::is_void_v<typename Get::value_type>) {
if constexpr(stl::is_void_v<typename Get::value_type>) {
for(size_type pos = base_type::size(); pos; --pos) {
func();
}
@@ -1073,7 +1073,7 @@ public:
static_assert(Get::storage_policy == deletion_policy::in_place, "Unexpected storage policy");
for(const auto pack: each()) {
std::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);
}
}
}
@@ -1102,7 +1102,7 @@ public:
* @param other The storage for the type to combine the view with.
* @return A more specific view.
*/
template<std::derived_from<common_type> OGet>
template<stl::derived_from<common_type> OGet>
[[nodiscard]] basic_view<get_t<Get, OGet>, exclude_t<>> operator|(OGet &other) const noexcept {
return *this | basic_view<get_t<OGet>, exclude_t<>>{other};
}
@@ -1114,10 +1114,10 @@ public:
* @param other The view to combine with.
* @return A more specific view.
*/
template<std::derived_from<common_type>... OGet, std::derived_from<common_type>... OExclude>
template<stl::derived_from<common_type>... OGet, stl::derived_from<common_type>... OExclude>
[[nodiscard]] auto operator|(const basic_view<get_t<OGet...>, exclude_t<OExclude...>> &other) const noexcept {
return internal::view_pack<basic_view<get_t<Get, OGet...>, exclude_t<OExclude...>>>(
*this, other, std::index_sequence_for<Get>{}, std::index_sequence_for<>{}, std::index_sequence_for<OGet...>{}, std::index_sequence_for<OExclude...>{});
*this, other, stl::index_sequence_for<Get>{}, stl::index_sequence_for<>{}, stl::index_sequence_for<OGet...>{}, stl::index_sequence_for<OExclude...>{});
}
};
@@ -1135,7 +1135,7 @@ basic_view(Type &...storage) -> basic_view<get_t<Type...>, exclude_t<>>;
* @tparam Exclude Types of elements used to filter the view.
*/
template<typename... Get, typename... Exclude>
basic_view(std::tuple<Get &...>, std::tuple<Exclude &...> = {}) -> basic_view<get_t<Get...>, exclude_t<Exclude...>>;
basic_view(stl::tuple<Get &...>, stl::tuple<Exclude &...> = {}) -> basic_view<get_t<Get...>, exclude_t<Exclude...>>;
} // namespace entt

View File

@@ -1,6 +1,9 @@
/*! @brief `EnTT` default namespace. */
namespace entt {}
/*! @brief Custom `EnTT` namespace for the standard template library. */
namespace entt::stl {}
// IWYU pragma: begin_exports
#include "config/config.h"
#include "config/macro.h"
@@ -66,7 +69,25 @@ namespace entt {}
#include "signal/dispatcher.hpp"
#include "signal/emitter.hpp"
#include "signal/sigh.hpp"
#include "stl/algorithm.hpp"
#include "stl/array.hpp"
#include "stl/atomic.hpp"
#include "stl/bit.hpp"
#include "stl/cmath.hpp"
#include "stl/concepts.hpp"
#include "stl/cstddef.hpp"
#include "stl/cstdint.hpp"
#include "stl/functional.hpp"
#include "stl/ios.hpp"
#include "stl/iterator.hpp"
#include "stl/limits.hpp"
#include "stl/memory.hpp"
#include "stl/ostream.hpp"
#include "stl/sstream.hpp"
#include "stl/string.hpp"
#include "stl/string_view.hpp"
#include "stl/tuple.hpp"
#include "stl/type_traits.hpp"
#include "stl/utility.hpp"
#include "stl/vector.hpp"
// IWYU pragma: end_exports

View File

@@ -1,15 +1,15 @@
#ifndef ENTT_GRAPH_ADJACENCY_MATRIX_HPP
#define ENTT_GRAPH_ADJACENCY_MATRIX_HPP
#include <concepts>
#include <cstddef>
#include <iterator>
#include <memory>
#include <type_traits>
#include <utility>
#include <vector>
#include "../config/config.h"
#include "../core/iterator.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/iterator.hpp"
#include "../stl/memory.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "../stl/vector.hpp"
#include "fwd.hpp"
namespace entt {
@@ -19,25 +19,25 @@ namespace internal {
template<typename It>
class edge_iterator {
using size_type = std::size_t;
using size_type = stl::size_t;
void find_next() noexcept {
for(; pos != last && !it[static_cast<It::difference_type>(pos)]; pos += offset) {}
}
public:
using value_type = std::pair<size_type, size_type>;
using value_type = stl::pair<size_type, size_type>;
using pointer = input_iterator_pointer<value_type>;
using reference = value_type;
using difference_type = std::ptrdiff_t;
using iterator_category = std::input_iterator_tag;
using iterator_concept = std::forward_iterator_tag;
using difference_type = stl::ptrdiff_t;
using iterator_category = stl::input_iterator_tag;
using iterator_concept = stl::forward_iterator_tag;
constexpr edge_iterator() noexcept = default;
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
constexpr edge_iterator(It base, const size_type vertices, const size_type from, const size_type to, const size_type step) noexcept
: it{std::move(base)},
: it{stl::move(base)},
vert{vertices},
pos{from},
last{to},
@@ -61,7 +61,7 @@ public:
}
[[nodiscard]] constexpr pointer operator->() const noexcept {
return std::make_pair<size_type>(pos / vert, pos % vert);
return stl::make_pair<size_type>(pos / vert, pos % vert);
}
[[nodiscard]] constexpr bool operator==(const edge_iterator &other) const noexcept {
@@ -84,21 +84,21 @@ private:
* @tparam Category Either a directed or undirected category tag.
* @tparam Allocator Type of allocator used to manage memory and elements.
*/
template<std::derived_from<directed_tag> Category, typename Allocator>
template<stl::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 alloc_traits = stl::allocator_traits<Allocator>;
static_assert(stl::is_same_v<typename alloc_traits::value_type, stl::size_t>, "Invalid value type");
using container_type = stl::vector<stl::size_t, typename alloc_traits::template rebind_alloc<stl::size_t>>;
public:
/*! @brief Allocator type. */
using allocator_type = Allocator;
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Vertex type. */
using vertex_type = size_type;
/*! @brief Edge type. */
using edge_type = std::pair<vertex_type, vertex_type>;
using edge_type = stl::pair<vertex_type, vertex_type>;
/*! @brief Vertex iterator type. */
using vertex_iterator = iota_iterator<vertex_type>;
/*! @brief Edge iterator type. */
@@ -153,7 +153,7 @@ public:
* @param allocator The allocator to use.
*/
adjacency_matrix(adjacency_matrix &&other, const allocator_type &allocator)
: matrix{std::move(other.matrix), allocator},
: matrix{stl::move(other.matrix), allocator},
vert{other.vert} {}
/*! @brief Default destructor. */
@@ -176,7 +176,7 @@ public:
* @param other Adjacency matrix to exchange the content with.
*/
void swap(adjacency_matrix &other) noexcept {
using std::swap;
using stl::swap;
swap(matrix, other.matrix);
swap(vert, other.vert);
}
@@ -280,16 +280,16 @@ public:
* the element that prevented the insertion) and a bool denoting whether the
* insertion took place.
*/
std::pair<edge_iterator, bool> insert(const vertex_type lhs, const vertex_type rhs) {
stl::pair<edge_iterator, bool> insert(const vertex_type lhs, const vertex_type rhs) {
const auto pos = lhs * vert + rhs;
if constexpr(std::is_same_v<graph_category, undirected_tag>) {
if constexpr(stl::is_same_v<graph_category, undirected_tag>) {
const auto rev = rhs * vert + lhs;
ENTT_ASSERT(matrix[pos] == matrix[rev], "Something went really wrong");
matrix[rev] = 1u;
}
const auto inserted = !std::exchange(matrix[pos], 1u);
const auto inserted = !stl::exchange(matrix[pos], 1u);
return {edge_iterator{matrix.cbegin(), vert, pos, matrix.size(), 1u}, inserted};
}
@@ -302,13 +302,13 @@ public:
size_type erase(const vertex_type lhs, const vertex_type rhs) {
const auto pos = lhs * vert + rhs;
if constexpr(std::is_same_v<graph_category, undirected_tag>) {
if constexpr(stl::is_same_v<graph_category, undirected_tag>) {
const auto rev = rhs * vert + lhs;
ENTT_ASSERT(matrix[pos] == matrix[rev], "Something went really wrong");
matrix[rev] = 0u;
}
return std::exchange(matrix[pos], 0u);
return stl::exchange(matrix[pos], 0u);
}
/**

View File

@@ -1,8 +1,8 @@
#ifndef ENTT_GRAPH_DOT_HPP
#define ENTT_GRAPH_DOT_HPP
#include <concepts>
#include <ostream>
#include "../stl/concepts.hpp"
#include "../stl/ostream.hpp"
#include "fwd.hpp"
namespace entt {
@@ -15,9 +15,9 @@ namespace entt {
* @param writer Vertex decorator object.
*/
template<typename Graph>
requires std::derived_from<typename Graph::graph_category, directed_tag>
void dot(std::ostream &out, const Graph &graph, std::invocable<std::ostream &, typename Graph::vertex_type> auto writer) {
if constexpr(std::same_as<typename Graph::graph_category, undirected_tag>) {
requires stl::derived_from<typename Graph::graph_category, directed_tag>
void dot(stl::ostream &out, const Graph &graph, stl::invocable<stl::ostream &, typename Graph::vertex_type> auto writer) {
if constexpr(stl::same_as<typename Graph::graph_category, undirected_tag>) {
out << "graph{";
} else {
out << "digraph{";
@@ -30,7 +30,7 @@ void dot(std::ostream &out, const Graph &graph, std::invocable<std::ostream &, t
}
for(auto [lhs, rhs]: graph.edges()) {
if constexpr(std::same_as<typename Graph::graph_category, undirected_tag>) {
if constexpr(stl::same_as<typename Graph::graph_category, undirected_tag>) {
out << lhs << "--" << rhs << ";";
} else {
out << lhs << "->" << rhs << ";";
@@ -47,7 +47,7 @@ void dot(std::ostream &out, const Graph &graph, std::invocable<std::ostream &, t
* @param graph The graph to output.
*/
template<typename Graph>
void dot(std::ostream &out, const Graph &graph) {
void dot(stl::ostream &out, const Graph &graph) {
return dot(out, graph, [](auto &&...) {});
}

View File

@@ -1,23 +1,21 @@
#ifndef ENTT_GRAPH_FLOW_HPP
#define ENTT_GRAPH_FLOW_HPP
#include <algorithm>
#include <concepts>
#include <cstddef>
#include <functional>
#include <iterator>
#include <memory>
#include <type_traits>
#include <utility>
#include <vector>
#include "../config/config.h"
#include "../container/dense_map.hpp"
#include "../container/dense_set.hpp"
#include "../core/compressed_pair.hpp"
#include "../core/fwd.hpp"
#include "../core/iterator.hpp"
#include "../stl/algorithm.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/functional.hpp"
#include "../stl/iterator.hpp"
#include "../stl/memory.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "../stl/vector.hpp"
#include "adjacency_matrix.hpp"
#include "fwd.hpp"
@@ -29,12 +27,12 @@ namespace entt {
*/
template<typename Allocator>
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 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>>;
using alloc_traits = stl::allocator_traits<Allocator>;
static_assert(stl::is_same_v<typename alloc_traits::value_type, id_type>, "Invalid value type");
using task_container_type = dense_set<id_type, stl::identity, stl::equal_to<>, typename alloc_traits::template rebind_alloc<id_type>>;
using ro_rw_container_type = stl::vector<stl::pair<stl::size_t, bool>, typename alloc_traits::template rebind_alloc<stl::pair<stl::size_t, bool>>>;
using deps_container_type = dense_map<id_type, ro_rw_container_type, stl::identity, stl::equal_to<>, typename alloc_traits::template rebind_alloc<stl::pair<const id_type, ro_rw_container_type>>>;
using adjacency_matrix_type = adjacency_matrix<directed_tag, typename alloc_traits::template rebind_alloc<stl::size_t>>;
void emplace(const id_type res, const bool is_rw) {
ENTT_ASSERT(index.first() < vertices.size(), "Invalid node");
@@ -57,7 +55,7 @@ class basic_flow {
if(auto curr = it++; it != last) {
if(it->second) {
matrix.insert(curr->first, it->first);
} else if(const auto next = std::find_if(it, last, [](const auto &value) { return value.second; }); next != last) {
} else if(const auto next = stl::find_if(it, last, [](const auto &value) { return value.second; }); next != last) {
for(; it != next; ++it) {
matrix.insert(curr->first, it->first);
matrix.insert(it->first, next->first);
@@ -70,7 +68,7 @@ class basic_flow {
}
} else {
// ro item (first iteration only)
if(const auto next = std::find_if(it, last, [](const auto &value) { return value.second; }); next != last) {
if(const auto next = stl::find_if(it, last, [](const auto &value) { return value.second; }); next != last) {
for(; it != next; ++it) {
matrix.insert(it->first, next->first);
}
@@ -85,9 +83,9 @@ class basic_flow {
void transitive_closure(adjacency_matrix_type &matrix) const {
const auto length = matrix.size();
for(std::size_t vk{}; vk < length; ++vk) {
for(std::size_t vi{}; vi < length; ++vi) {
for(std::size_t vj{}; vj < length; ++vj) {
for(stl::size_t vk{}; vk < length; ++vk) {
for(stl::size_t vi{}; vi < length; ++vi) {
for(stl::size_t vj{}; vj < length; ++vj) {
if(matrix.contains(vi, vk) && matrix.contains(vk, vj)) {
matrix.insert(vi, vj);
}
@@ -99,14 +97,14 @@ class basic_flow {
void transitive_reduction(adjacency_matrix_type &matrix) const {
const auto length = matrix.size();
for(std::size_t vert{}; vert < length; ++vert) {
for(stl::size_t vert{}; vert < length; ++vert) {
matrix.erase(vert, vert);
}
for(std::size_t vj{}; vj < length; ++vj) {
for(std::size_t vi{}; vi < length; ++vi) {
for(stl::size_t vj{}; vj < length; ++vj) {
for(stl::size_t vi{}; vi < length; ++vi) {
if(matrix.contains(vi, vj)) {
for(std::size_t vk{}; vk < length; ++vk) {
for(stl::size_t vk{}; vk < length; ++vk) {
if(matrix.contains(vj, vk)) {
matrix.erase(vi, vk);
}
@@ -120,7 +118,7 @@ public:
/*! @brief Allocator type. */
using allocator_type = Allocator;
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Iterable task list. */
using iterable = iterable_adaptor<typename task_container_type::const_iterator>;
/*! @brief Adjacency matrix type. */
@@ -163,8 +161,8 @@ public:
*/
basic_flow(basic_flow &&other, const allocator_type &allocator)
: index{other.index.first(), allocator},
vertices{std::move(other.vertices), allocator},
deps{std::move(other.deps), allocator},
vertices{stl::move(other.vertices), allocator},
deps{stl::move(other.deps), allocator},
sync_on{other.sync_on} {}
/*! @brief Default destructor. */
@@ -187,11 +185,11 @@ public:
* @param other Flow builder to exchange the content with.
*/
void swap(basic_flow &other) noexcept {
using std::swap;
std::swap(index, other.index);
std::swap(vertices, other.vertices);
std::swap(deps, other.deps);
std::swap(sync_on, other.sync_on);
using stl::swap;
swap(index, other.index);
swap(vertices, other.vertices);
swap(deps, other.deps);
swap(sync_on, other.sync_on);
}
/**

View File

@@ -1,10 +1,10 @@
#ifndef ENTT_GRAPH_FWD_HPP
#define ENTT_GRAPH_FWD_HPP
#include <concepts>
#include <cstddef>
#include <memory>
#include "../core/fwd.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/memory.hpp"
namespace entt {
@@ -14,10 +14,10 @@ struct directed_tag {};
/*! @brief Directed graph category tag. */
struct undirected_tag: directed_tag {};
template<std::derived_from<directed_tag>, typename = std::allocator<std::size_t>>
template<stl::derived_from<directed_tag>, typename = stl::allocator<stl::size_t>>
class adjacency_matrix;
template<typename = std::allocator<id_type>>
template<typename = stl::allocator<id_type>>
class basic_flow;
/*! @brief Alias declaration for the most common use case. */

View File

@@ -1,10 +1,10 @@
#ifndef ENTT_LOCATOR_LOCATOR_HPP
#define ENTT_LOCATOR_LOCATOR_HPP
#include <concepts>
#include <memory>
#include <utility>
#include "../config/config.h"
#include "../stl/concepts.hpp"
#include "../stl/memory.hpp"
#include "../stl/utility.hpp"
namespace entt {
@@ -28,7 +28,7 @@ template<typename Service>
class locator final {
class service_handle {
friend class locator<Service>;
std::shared_ptr<Service> value{};
stl::shared_ptr<Service> value{};
};
public:
@@ -85,10 +85,10 @@ public:
* @param args Parameters to use to construct the fallback service.
* @return A reference to a valid service.
*/
template<std::derived_from<Service> Type = Service, typename... Args>
requires std::constructible_from<Type, Args...>
template<stl::derived_from<Service> Type = Service, typename... Args>
requires stl::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)...);
}
/**
@@ -98,10 +98,10 @@ public:
* @param args Parameters to use to construct the service.
* @return A reference to a valid service.
*/
template<std::derived_from<Service> Type = Service, typename... Args>
requires std::constructible_from<Type, Args...>
template<stl::derived_from<Service> Type = Service, typename... Args>
requires stl::constructible_from<Type, Args...>
static Service &emplace(Args &&...args) {
service = std::make_shared<Type>(std::forward<Args>(args)...);
service = stl::make_shared<Type>(stl::forward<Args>(args)...);
return *service;
}
@@ -113,10 +113,10 @@ public:
* @param args Parameters to use to construct the service.
* @return A reference to a valid service.
*/
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)...);
template<stl::derived_from<Service> Type = Service, typename... Args>
requires stl::constructible_from<Type, Args...>
static Service &emplace(stl::allocator_arg_t, auto alloc, Args &&...args) {
service = stl::allocate_shared<Type>(alloc, stl::forward<Args>(args)...);
return *service;
}
@@ -145,15 +145,15 @@ public:
* @param elem A pointer to a service to manage.
* @param deleter A deleter to use to destroy the service.
*/
template<std::derived_from<Service> Type, typename Deleter = std::default_delete<Type>>
template<stl::derived_from<Service> Type, typename Deleter = stl::default_delete<Type>>
static void reset(Type *elem, Deleter deleter = {}) {
service = std::shared_ptr<Service>{elem, std::move(deleter)};
service = stl::shared_ptr<Service>{elem, stl::move(deleter)};
}
private:
// std::shared_ptr because of its type erased allocator which is useful here
// stl::shared_ptr because of its type erased allocator which is useful here
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
inline static std::shared_ptr<Service> service{};
inline static stl::shared_ptr<Service> service{};
};
} // namespace entt

View File

@@ -3,14 +3,13 @@
#ifndef ENTT_META_CONTAINER_HPP
#define ENTT_META_CONTAINER_HPP
#include <concepts>
#include <cstddef>
#include <iterator>
#include <type_traits>
#include <utility>
#include "../core/concepts.hpp"
#include "../core/type_traits.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/iterator.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "context.hpp"
#include "fwd.hpp"
#include "meta.hpp"
@@ -25,19 +24,19 @@ template<typename Type>
struct sequence_container_extent: integral_constant<meta_dynamic_extent> {};
template<typename Type>
requires is_complete_v<std::tuple_size<Type>>
struct sequence_container_extent<Type>: integral_constant<std::tuple_size_v<Type>> {};
requires is_complete_v<stl::tuple_size<Type>>
struct sequence_container_extent<Type>: integral_constant<stl::tuple_size_v<Type>> {};
template<typename Type>
inline constexpr std::size_t sequence_container_extent_v = sequence_container_extent<Type>::value;
inline constexpr stl::size_t sequence_container_extent_v = sequence_container_extent<Type>::value;
template<typename Type>
concept meta_sequence_container_like = requires(Type elem) {
typename Type::value_type;
typename Type::iterator;
requires entt::stl::forward_iterator<typename Type::iterator>;
{ elem.begin() } -> std::same_as<typename Type::iterator>;
{ elem.end() } -> std::same_as<typename Type::iterator>;
{ elem.begin() } -> stl::same_as<typename Type::iterator>;
{ elem.end() } -> stl::same_as<typename Type::iterator>;
requires !requires { typename Type::key_type; };
requires !requires { elem.substr(); };
};
@@ -48,9 +47,9 @@ concept meta_associative_container_like = requires(Type value) {
typename Type::value_type;
typename Type::iterator;
requires entt::stl::forward_iterator<typename Type::iterator>;
{ value.begin() } -> std::same_as<typename Type::iterator>;
{ value.end() } -> std::same_as<typename Type::iterator>;
value.find(std::declval<typename Type::key_type>());
{ value.begin() } -> stl::same_as<typename Type::iterator>;
{ value.end() } -> stl::same_as<typename Type::iterator>;
value.find(stl::declval<typename Type::key_type>());
};
} // namespace internal
@@ -68,7 +67,7 @@ struct basic_meta_sequence_container_traits {
using iterator = meta_sequence_container::iterator;
/*! @brief Number of elements, or `meta_dynamic_extent` if dynamic. */
static constexpr std::size_t extent = internal::sequence_container_extent_v<Type>;
static constexpr stl::size_t extent = internal::sequence_container_extent_v<Type>;
/**
* @brief Returns the number of elements in a container.
@@ -115,7 +114,7 @@ struct basic_meta_sequence_container_traits {
* @return True in case of success, false otherwise.
*/
[[nodiscard]] static bool resize([[maybe_unused]] void *container, [[maybe_unused]] const size_type sz) {
if constexpr(std::is_default_constructible_v<typename Type::value_type> && requires(Type elem) { elem.resize(sz); }) {
if constexpr(stl::is_default_constructible_v<typename Type::value_type> && requires(Type elem) { elem.resize(sz); }) {
static_cast<Type *>(container)->resize(sz);
return true;
} else {
@@ -155,7 +154,7 @@ struct basic_meta_sequence_container_traits {
auto *const non_const = any_cast<typename Type::iterator>(&it.base());
return {area, static_cast<Type *>(container)->insert(
non_const ? *non_const : any_cast<const typename Type::const_iterator &>(it.base()),
(value != nullptr) ? *static_cast<const Type::value_type *>(value) : *static_cast<const std::remove_reference_t<typename Type::const_reference> *>(cref))};
(value != nullptr) ? *static_cast<const Type::value_type *>(value) : *static_cast<const stl::remove_reference_t<typename Type::const_reference> *>(cref))};
} else {
return iterator{};
}
@@ -237,8 +236,8 @@ struct basic_meta_associative_container_traits {
*/
static iterator iter(const meta_ctx &area, void *container, const void *as_const, const bool end) {
return (container == nullptr)
? iterator{area, std::bool_constant<key_only>{}, end ? static_cast<const Type *>(as_const)->cend() : static_cast<const Type *>(as_const)->cbegin()}
: iterator{area, std::bool_constant<key_only>{}, end ? static_cast<Type *>(container)->end() : static_cast<Type *>(container)->begin()};
? iterator{area, stl::bool_constant<key_only>{}, end ? static_cast<const Type *>(as_const)->cend() : static_cast<const Type *>(as_const)->cbegin()}
: iterator{area, stl::bool_constant<key_only>{}, end ? static_cast<Type *>(container)->end() : static_cast<Type *>(container)->begin()};
}
/**
@@ -275,8 +274,8 @@ struct basic_meta_associative_container_traits {
* @return An iterator to the element with the given key, if any.
*/
static iterator find(const meta_ctx &area, void *container, const void *as_const, const void *key) {
return (container != nullptr) ? iterator{area, std::bool_constant<key_only>{}, static_cast<Type *>(container)->find(*static_cast<const Type::key_type *>(key))}
: iterator{area, std::bool_constant<key_only>{}, static_cast<const Type *>(as_const)->find(*static_cast<const Type::key_type *>(key))};
return (container != nullptr) ? iterator{area, stl::bool_constant<key_only>{}, static_cast<Type *>(container)->find(*static_cast<const Type::key_type *>(key))}
: iterator{area, stl::bool_constant<key_only>{}, static_cast<const Type *>(as_const)->find(*static_cast<const Type::key_type *>(key))};
}
};

View File

@@ -1,10 +1,10 @@
#ifndef ENTT_META_CTX_HPP
#define ENTT_META_CTX_HPP
#include <memory>
#include "../container/dense_map.hpp"
#include "../core/fwd.hpp"
#include "../stl/functional.hpp"
#include "../stl/memory.hpp"
#include "fwd.hpp"
namespace entt {
@@ -15,7 +15,7 @@ namespace internal {
struct meta_type_node;
struct meta_context {
using container_type = dense_map<id_type, std::unique_ptr<meta_type_node>, stl::identity>;
using container_type = dense_map<id_type, stl::unique_ptr<meta_type_node>, stl::identity>;
container_type bucket;

View File

@@ -1,14 +1,6 @@
#ifndef ENTT_META_FACTORY_HPP
#define ENTT_META_FACTORY_HPP
#include <concepts>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <memory>
#include <tuple>
#include <type_traits>
#include <utility>
#include "../config/config.h"
#include "../core/bit.hpp"
#include "../core/fwd.hpp"
@@ -16,6 +8,13 @@
#include "../core/type_info.hpp"
#include "../core/type_traits.hpp"
#include "../locator/locator.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/cstdint.hpp"
#include "../stl/functional.hpp"
#include "../stl/memory.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "context.hpp"
#include "fwd.hpp"
#include "meta.hpp"
@@ -31,7 +30,7 @@ namespace entt {
namespace internal {
class basic_meta_factory {
using invoke_type = std::remove_pointer_t<decltype(meta_func_node::invoke)>;
using invoke_type = stl::remove_pointer_t<decltype(meta_func_node::invoke)>;
enum class mode {
type,
@@ -64,14 +63,14 @@ protected:
void insert_or_assign(Type node) {
state = mode::type;
if constexpr(std::is_same_v<Type, meta_base_node>) {
if constexpr(stl::is_same_v<Type, meta_base_node>) {
auto *member = find_member(parent->details->base, node.id);
member ? (*member = node) : parent->details->base.emplace_back(node);
} else if constexpr(std::is_same_v<Type, meta_conv_node>) {
} else if constexpr(stl::is_same_v<Type, meta_conv_node>) {
auto *member = find_member(parent->details->conv, node.id);
member ? (*member = node) : parent->details->conv.emplace_back(node);
} else {
static_assert(std::is_same_v<Type, meta_ctor_node>, "Unexpected type");
static_assert(stl::is_same_v<Type, meta_ctor_node>, "Unexpected type");
auto *member = find_member(parent->details->ctor, node.id);
member ? (*member = node) : parent->details->ctor.emplace_back(node);
}
@@ -82,9 +81,9 @@ protected:
bucket = node.id;
if(auto *member = find_member(parent->details->data, node.id); member == nullptr) {
parent->details->data.emplace_back(std::move(node));
parent->details->data.emplace_back(stl::move(node));
} else if(member->set != node.set || member->get != node.get) {
*member = std::move(node);
*member = stl::move(node);
}
}
@@ -94,10 +93,10 @@ protected:
invoke = node.invoke;
if(auto *member = find_member(parent->details->func, node.id); member == nullptr) {
parent->details->func.emplace_back(std::move(node));
parent->details->func.emplace_back(stl::move(node));
} else if(auto *overload = find_overload(member, node.invoke); overload == nullptr) {
while(member->next != nullptr) { member = member->next.get(); }
member->next = std::make_unique<meta_func_node>(std::move(node));
member->next = stl::make_unique<meta_func_node>(stl::move(node));
}
}
@@ -122,13 +121,13 @@ protected:
void custom(meta_custom_node node) {
switch(state) {
case mode::type:
parent->custom = std::move(node);
parent->custom = stl::move(node);
break;
case mode::data:
find_member_or_assert()->custom = std::move(node);
find_member_or_assert()->custom = stl::move(node);
break;
case mode::func:
find_overload_or_assert()->custom = std::move(node);
find_overload_or_assert()->custom = stl::move(node);
break;
}
}
@@ -139,8 +138,8 @@ public:
bucket{node.info->hash()},
state{mode::type} {
if(const auto it = meta_context::from(*ctx).bucket.find(bucket); it == meta_context::from(*ctx).bucket.cend()) {
parent = meta_context::from(*ctx).bucket.emplace(node.info->hash(), std::make_unique<meta_type_node>(std::move(node))).first->second.get();
parent->details = std::make_unique<meta_type_descriptor>();
parent = meta_context::from(*ctx).bucket.emplace(node.info->hash(), stl::make_unique<meta_type_node>(stl::move(node))).first->second.get();
parent->details = stl::make_unique<meta_type_descriptor>();
} else {
parent = it->second.get();
}
@@ -209,9 +208,9 @@ public:
* @return A meta factory for the parent type.
*/
template<typename Base>
requires std::derived_from<Type, Base>
requires stl::derived_from<Type, Base>
meta_factory base() noexcept {
if constexpr(!std::same_as<Type, Base>) {
if constexpr(!stl::same_as<Type, Base>) {
auto *const op = +[](const void *instance) noexcept { return static_cast<const void *>(static_cast<const Base *>(static_cast<const Type *>(instance))); };
base_type::insert_or_assign(
@@ -238,8 +237,8 @@ public:
*/
template<auto Candidate>
auto conv() noexcept {
using conv_type = std::remove_cvref_t<std::invoke_result_t<decltype(Candidate), Type &>>;
auto *const op = +[](const meta_ctx &area, const void *instance) { return forward_as_meta(area, std::invoke(Candidate, *static_cast<const Type *>(instance))); };
using conv_type = stl::remove_cvref_t<stl::invoke_result_t<decltype(Candidate), Type &>>;
auto *const op = +[](const meta_ctx &area, const void *instance) { return forward_as_meta(area, stl::invoke(Candidate, *static_cast<const Type *>(instance))); };
base_type::insert_or_assign(
internal::meta_conv_node{
@@ -260,7 +259,7 @@ public:
*/
template<typename To>
meta_factory conv() noexcept {
using conv_type = std::remove_cvref_t<To>;
using conv_type = stl::remove_cvref_t<To>;
auto *const op = +[](const meta_ctx &area, const void *instance) { return forward_as_meta(area, static_cast<To>(*static_cast<const Type *>(instance))); };
base_type::insert_or_assign(
@@ -288,7 +287,7 @@ public:
meta_factory ctor() noexcept {
using descriptor = meta_function_helper_t<Type, decltype(Candidate)>;
static_assert(Policy::template value<typename descriptor::return_type>, "Invalid return type for the given policy");
static_assert(std::is_same_v<std::remove_cvref_t<typename descriptor::return_type>, Type>, "The function doesn't return an object of the required type");
static_assert(stl::is_same_v<stl::remove_cvref_t<typename descriptor::return_type>, Type>, "The function doesn't return an object of the required type");
base_type::insert_or_assign(
internal::meta_ctor_node{
@@ -355,8 +354,8 @@ public:
*/
template<auto Data, typename Policy = as_value_t>
meta_factory data(const id_type id, const char *name = nullptr) noexcept {
if constexpr(std::is_member_object_pointer_v<decltype(Data)>) {
using data_type = std::invoke_result_t<decltype(Data), Type &>;
if constexpr(stl::is_member_object_pointer_v<decltype(Data)>) {
using data_type = stl::invoke_result_t<decltype(Data), Type &>;
static_assert(Policy::template value<data_type>, "Invalid return type for the given policy");
base_type::data(
@@ -364,16 +363,16 @@ public:
id,
name,
/* this is never static */
std::is_const_v<std::remove_reference_t<data_type>> ? internal::meta_traits::is_const : internal::meta_traits::is_none,
stl::is_const_v<stl::remove_reference_t<data_type>> ? internal::meta_traits::is_const : internal::meta_traits::is_none,
1u,
&internal::resolve<std::remove_cvref_t<data_type>>,
&meta_arg<type_list<std::remove_cvref_t<data_type>>>,
&internal::resolve<stl::remove_cvref_t<data_type>>,
&meta_arg<type_list<stl::remove_cvref_t<data_type>>>,
&meta_setter<Type, Data>,
&meta_getter<Type, Data, Policy>});
} else {
using data_type = std::remove_pointer_t<decltype(Data)>;
using data_type = stl::remove_pointer_t<decltype(Data)>;
if constexpr(std::is_pointer_v<decltype(Data)>) {
if constexpr(stl::is_pointer_v<decltype(Data)>) {
static_assert(Policy::template value<decltype(*Data)>, "Invalid return type for the given policy");
} else {
static_assert(Policy::template value<data_type>, "Invalid return type for the given policy");
@@ -383,10 +382,10 @@ public:
internal::meta_data_node{
id,
name,
((!std::is_pointer_v<decltype(Data)> || std::is_const_v<data_type>) ? internal::meta_traits::is_const : internal::meta_traits::is_none) | internal::meta_traits::is_static,
((!stl::is_pointer_v<decltype(Data)> || stl::is_const_v<data_type>) ? internal::meta_traits::is_const : internal::meta_traits::is_none) | internal::meta_traits::is_static,
1u,
&internal::resolve<std::remove_cvref_t<data_type>>,
&meta_arg<type_list<std::remove_cvref_t<data_type>>>,
&internal::resolve<stl::remove_cvref_t<data_type>>,
&meta_arg<type_list<stl::remove_cvref_t<data_type>>>,
&meta_setter<Type, Data>,
&meta_getter<Type, Data, Policy>});
}
@@ -434,7 +433,7 @@ public:
using descriptor = meta_function_helper_t<Type, decltype(Getter)>;
static_assert(Policy::template value<typename descriptor::return_type>, "Invalid return type for the given policy");
if constexpr(std::is_same_v<decltype(Setter), std::nullptr_t>) {
if constexpr(stl::is_same_v<decltype(Setter), stl::nullptr_t>) {
base_type::data(
internal::meta_data_node{
id,
@@ -442,7 +441,7 @@ public:
/* this is never static */
internal::meta_traits::is_const,
0u,
&internal::resolve<std::remove_cvref_t<typename descriptor::return_type>>,
&internal::resolve<stl::remove_cvref_t<typename descriptor::return_type>>,
&meta_arg<type_list<>>,
&meta_setter<Type, Setter>,
&meta_getter<Type, Getter, Policy>});
@@ -456,8 +455,8 @@ public:
/* this is never static nor const */
internal::meta_traits::is_none,
1u,
&internal::resolve<std::remove_cvref_t<typename descriptor::return_type>>,
&meta_arg<type_list<type_list_element_t<static_cast<std::size_t>(args_type::size != 1u), args_type>>>,
&internal::resolve<stl::remove_cvref_t<typename descriptor::return_type>>,
&meta_arg<type_list<type_list_element_t<static_cast<stl::size_t>(args_type::size != 1u), args_type>>>,
&meta_setter<Type, Setter>,
&meta_getter<Type, Getter, Policy>});
}
@@ -502,7 +501,7 @@ public:
name,
(descriptor::is_const ? internal::meta_traits::is_const : internal::meta_traits::is_none) | (descriptor::is_static ? internal::meta_traits::is_static : internal::meta_traits::is_none),
descriptor::args_type::size,
&internal::resolve<std::conditional_t<std::is_same_v<Policy, as_void_t>, void, std::remove_cvref_t<typename descriptor::return_type>>>,
&internal::resolve<stl::conditional_t<stl::is_same_v<Policy, as_void_t>, void, stl::remove_cvref_t<typename descriptor::return_type>>>,
&meta_arg<typename descriptor::args_type>,
&meta_invoke<Type, Candidate, Policy>});
@@ -521,7 +520,7 @@ public:
*/
template<typename Value>
meta_factory traits(const Value value, const bool unset = false) {
static_assert(std::is_enum_v<Value>, "Invalid enum type");
static_assert(stl::is_enum_v<Value>, "Invalid enum type");
base_type::traits(internal::user_to_meta_traits(value), unset);
return *this;
}
@@ -535,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(), stl::make_shared<Value>(stl::forward<Args>(args)...)});
return *this;
}
};

View File

@@ -1,8 +1,8 @@
#ifndef ENTT_META_FWD_HPP
#define ENTT_META_FWD_HPP
#include <cstddef>
#include <limits>
#include "../stl/cstddef.hpp"
#include "../stl/limits.hpp"
namespace entt {
@@ -30,7 +30,7 @@ template<typename>
class meta_factory;
/*! @brief Used to identicate that a sequence container has not a fixed size. */
inline constexpr std::size_t meta_dynamic_extent = (std::numeric_limits<std::size_t>::max)();
inline constexpr stl::size_t meta_dynamic_extent = (stl::numeric_limits<stl::size_t>::max)();
} // namespace entt

View File

@@ -1,14 +1,6 @@
#ifndef ENTT_META_META_HPP
#define ENTT_META_META_HPP
#include <array>
#include <concepts>
#include <cstddef>
#include <iterator>
#include <memory>
#include <string_view>
#include <type_traits>
#include <utility>
#include "../config/config.h"
#include "../core/any.hpp"
#include "../core/concepts.hpp"
@@ -18,7 +10,14 @@
#include "../core/type_traits.hpp"
#include "../core/utility.hpp"
#include "../locator/locator.hpp"
#include "../stl/array.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/iterator.hpp"
#include "../stl/memory.hpp"
#include "../stl/string_view.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "adl_pointer.hpp"
#include "context.hpp"
#include "fwd.hpp"
@@ -51,7 +50,7 @@ class meta_sequence_container {
public:
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Meta iterator type. */
using iterator = meta_iterator;
@@ -69,15 +68,15 @@ public:
: ctx{&area},
data{&instance},
value_type_node{&internal::resolve<typename Type::value_type>},
const_reference_node{&internal::resolve<std::remove_cvref_t<typename Type::const_reference>>},
size_fn{meta_sequence_container_traits<std::remove_const_t<Type>>::size},
clear_fn{meta_sequence_container_traits<std::remove_const_t<Type>>::clear},
reserve_fn{meta_sequence_container_traits<std::remove_const_t<Type>>::reserve},
resize_fn{meta_sequence_container_traits<std::remove_const_t<Type>>::resize},
begin_end_fn{meta_sequence_container_traits<std::remove_const_t<Type>>::iter},
insert_fn{meta_sequence_container_traits<std::remove_const_t<Type>>::insert},
erase_fn{meta_sequence_container_traits<std::remove_const_t<Type>>::erase},
const_only{std::is_const_v<Type>} {}
const_reference_node{&internal::resolve<stl::remove_cvref_t<typename Type::const_reference>>},
size_fn{meta_sequence_container_traits<stl::remove_const_t<Type>>::size},
clear_fn{meta_sequence_container_traits<stl::remove_const_t<Type>>::clear},
reserve_fn{meta_sequence_container_traits<stl::remove_const_t<Type>>::reserve},
resize_fn{meta_sequence_container_traits<stl::remove_const_t<Type>>::resize},
begin_end_fn{meta_sequence_container_traits<stl::remove_const_t<Type>>::iter},
insert_fn{meta_sequence_container_traits<stl::remove_const_t<Type>>::insert},
erase_fn{meta_sequence_container_traits<stl::remove_const_t<Type>>::erase},
const_only{stl::is_const_v<Type>} {}
[[nodiscard]] inline meta_type value_type() const noexcept;
[[nodiscard]] inline size_type size() const noexcept;
@@ -112,7 +111,7 @@ class meta_associative_container {
public:
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Meta iterator type. */
using iterator = meta_iterator;
@@ -131,15 +130,15 @@ public:
data{&instance},
key_type_node{&internal::resolve<typename Type::key_type>},
value_type_node{&internal::resolve<typename Type::value_type>},
size_fn{&meta_associative_container_traits<std::remove_const_t<Type>>::size},
clear_fn{&meta_associative_container_traits<std::remove_const_t<Type>>::clear},
reserve_fn{&meta_associative_container_traits<std::remove_const_t<Type>>::reserve},
begin_end_fn{&meta_associative_container_traits<std::remove_const_t<Type>>::iter},
insert_fn{&meta_associative_container_traits<std::remove_const_t<Type>>::insert},
erase_fn{&meta_associative_container_traits<std::remove_const_t<Type>>::erase},
find_fn{&meta_associative_container_traits<std::remove_const_t<Type>>::find},
const_only{std::is_const_v<Type>} {
if constexpr(!meta_associative_container_traits<std::remove_const_t<Type>>::key_only) {
size_fn{&meta_associative_container_traits<stl::remove_const_t<Type>>::size},
clear_fn{&meta_associative_container_traits<stl::remove_const_t<Type>>::clear},
reserve_fn{&meta_associative_container_traits<stl::remove_const_t<Type>>::reserve},
begin_end_fn{&meta_associative_container_traits<stl::remove_const_t<Type>>::iter},
insert_fn{&meta_associative_container_traits<stl::remove_const_t<Type>>::insert},
erase_fn{&meta_associative_container_traits<stl::remove_const_t<Type>>::erase},
find_fn{&meta_associative_container_traits<stl::remove_const_t<Type>>::find},
const_only{stl::is_const_v<Type>} {
if constexpr(!meta_associative_container_traits<stl::remove_const_t<Type>>::key_only) {
mapped_type_node = &internal::resolve<typename Type::mapped_type>;
}
}
@@ -185,31 +184,31 @@ class meta_any {
if constexpr(is_meta_pointer_like_v<Type>) {
if(req == internal::meta_traits::is_pointer) {
if constexpr(!std::is_void_v<std::remove_const_t<typename std::pointer_traits<Type>::element_type>>) {
if constexpr(std::is_constructible_v<bool, Type>) {
if constexpr(!stl::is_void_v<stl::remove_const_t<typename stl::pointer_traits<Type>::element_type>>) {
if constexpr(stl::is_constructible_v<bool, Type>) {
if(const auto &pointer_like = any_cast<const Type &>(value.storage); pointer_like) {
static_cast<meta_any *>(other)->emplace<decltype(adl_meta_pointer_like<Type>::dereference(std::declval<const Type &>()))>(adl_meta_pointer_like<Type>::dereference(pointer_like));
static_cast<meta_any *>(other)->emplace<decltype(adl_meta_pointer_like<Type>::dereference(stl::declval<const Type &>()))>(adl_meta_pointer_like<Type>::dereference(pointer_like));
}
} else {
static_cast<meta_any *>(other)->emplace<decltype(adl_meta_pointer_like<Type>::dereference(std::declval<const Type &>()))>(adl_meta_pointer_like<Type>::dereference(any_cast<const Type &>(value.storage)));
static_cast<meta_any *>(other)->emplace<decltype(adl_meta_pointer_like<Type>::dereference(stl::declval<const Type &>()))>(adl_meta_pointer_like<Type>::dereference(any_cast<const Type &>(value.storage)));
}
}
}
} else if constexpr(requires(Type elem) { *elem; }) {
if(req == internal::meta_traits::is_pointer) {
if constexpr(std::is_class_v<Type>) {
if constexpr(stl::is_class_v<Type>) {
if(const auto &elem = any_cast<const Type &>(value.storage); elem) {
return (value.storage.policy() == any_policy::cref) ? static_cast<meta_any *>(other)->emplace<decltype(*elem)>(*elem) : static_cast<meta_any *>(other)->emplace<decltype(*const_cast<Type &>(elem))>(*const_cast<Type &>(elem));
}
} else if constexpr(!std::is_array_v<Type> && !std::is_void_v<std::remove_const_t<std::remove_pointer_t<Type>>>) {
} else if constexpr(!stl::is_array_v<Type> && !stl::is_void_v<stl::remove_const_t<stl::remove_pointer_t<Type>>>) {
if(auto *pointer = any_cast<Type>(value.storage); pointer) {
static_cast<meta_any *>(other)->emplace<std::conditional_t<std::is_function_v<std::remove_const_t<std::remove_pointer_t<Type>>>, Type, std::remove_pointer_t<Type> &>>(*pointer);
static_cast<meta_any *>(other)->emplace<stl::conditional_t<stl::is_function_v<stl::remove_const_t<stl::remove_pointer_t<Type>>>, Type, stl::remove_pointer_t<Type> &>>(*pointer);
}
}
}
} else if constexpr(is_complete_v<meta_sequence_container_traits<Type>> || is_complete_v<meta_associative_container_traits<Type>>) {
if(constexpr auto flag = (is_complete_v<meta_sequence_container_traits<Type>> ? internal::meta_traits::is_sequence_container : internal::meta_traits::is_associative_container); req == flag) {
using container_type = std::conditional_t<is_complete_v<meta_sequence_container_traits<Type>>, meta_sequence_container, meta_associative_container>;
using container_type = stl::conditional_t<is_complete_v<meta_sequence_container_traits<Type>>, meta_sequence_container, meta_associative_container>;
*static_cast<container_type *>(other) = (value.storage.policy() == any_policy::cref) ? container_type{*value.ctx, any_cast<const Type &>(value.storage)} : container_type{*value.ctx, any_cast<Type &>(const_cast<meta_any &>(value).storage)};
}
}
@@ -226,7 +225,7 @@ class meta_any {
}
meta_any(const meta_any &other, any elem)
: storage{std::move(elem)},
: storage{stl::move(elem)},
ctx{other.ctx},
node{other.node},
vtable{other.vtable} {}
@@ -249,8 +248,8 @@ public:
* @param args Parameters to use to construct the instance.
*/
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)...} {}
explicit meta_any(stl::in_place_type_t<Type>, Args &&...args)
: meta_any{locator<meta_ctx>::value_or(), stl::in_place_type<Type>, stl::forward<Args>(args)...} {}
/**
* @brief Constructs a wrapper by directly initializing the new object.
@@ -260,10 +259,10 @@ public:
* @param args Parameters to use to construct the instance.
*/
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)...},
explicit meta_any(const meta_ctx &area, stl::in_place_type_t<Type>, Args &&...args)
: storage{stl::in_place_type<Type>, stl::forward<Args>(args)...},
ctx{&area},
vtable{&basic_vtable<std::remove_cvref_t<Type>>} {}
vtable{&basic_vtable<stl::remove_cvref_t<Type>>} {}
/**
* @brief Constructs a wrapper taking ownership of the passed object.
@@ -271,8 +270,8 @@ public:
* @param value A pointer to an object to take ownership of.
*/
template<typename Type>
explicit meta_any(std::in_place_t, Type *value)
: meta_any{locator<meta_ctx>::value_or(), std::in_place, value} {}
explicit meta_any(stl::in_place_t, Type *value)
: meta_any{locator<meta_ctx>::value_or(), stl::in_place, value} {}
/**
* @brief Constructs a wrapper taking ownership of the passed object.
@@ -281,8 +280,8 @@ public:
* @param value A pointer to an object to take ownership of.
*/
template<typename Type>
explicit meta_any(const meta_ctx &area, std::in_place_t, Type *value)
: storage{std::in_place, value},
explicit meta_any(const meta_ctx &area, stl::in_place_t, Type *value)
: storage{stl::in_place, value},
ctx{&area},
vtable{storage ? &basic_vtable<Type> : nullptr} {
}
@@ -293,9 +292,9 @@ public:
* @param value An instance of an object to use to initialize the wrapper.
*/
template<typename Type>
requires (!std::same_as<std::remove_cvref_t<Type>, meta_any>)
requires (!stl::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.
@@ -304,9 +303,9 @@ public:
* @param value An instance of an object to use to initialize the wrapper.
*/
template<typename Type>
requires (!std::same_as<std::remove_cvref_t<Type>, meta_any>)
requires (!stl::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, stl::in_place_type<stl::decay_t<Type>>, stl::forward<Type>(value)} {}
/**
* @brief Context aware copy constructor.
@@ -325,10 +324,10 @@ public:
* @param other The instance to move from.
*/
meta_any(const meta_ctx &area, meta_any &&other)
: storage{std::move(other.storage)},
: storage{stl::move(other.storage)},
ctx{&area},
node{(ctx == other.ctx) ? std::exchange(other.node, nullptr) : nullptr},
vtable{std::exchange(other.vtable, nullptr)} {}
node{(ctx == other.ctx) ? stl::exchange(other.node, nullptr) : nullptr},
vtable{stl::exchange(other.vtable, nullptr)} {}
/**
* @brief Copy constructor.
@@ -346,10 +345,10 @@ public:
* @param other The instance to move from.
*/
meta_any(meta_any &&other) noexcept
: storage{std::move(other.storage)},
: storage{stl::move(other.storage)},
ctx{other.ctx},
node{std::exchange(other.node, nullptr)},
vtable{std::exchange(other.vtable, nullptr)} {}
node{stl::exchange(other.node, nullptr)},
vtable{stl::exchange(other.vtable, nullptr)} {}
/*! @brief Default destructor. */
~meta_any() = default;
@@ -376,10 +375,10 @@ public:
* @return This meta any object.
*/
meta_any &operator=(meta_any &&other) noexcept {
storage = std::move(other.storage);
storage = stl::move(other.storage);
ctx = other.ctx;
node = std::exchange(other.node, nullptr);
vtable = std::exchange(other.vtable, nullptr);
node = stl::exchange(other.node, nullptr);
vtable = stl::exchange(other.vtable, nullptr);
return *this;
}
@@ -390,9 +389,9 @@ public:
* @return This meta any object.
*/
template<typename Type>
requires (!std::same_as<std::remove_cvref_t<Type>, meta_any>)
requires (!stl::same_as<stl::remove_cvref_t<Type>, meta_any>)
meta_any &operator=(Type &&value) {
emplace<std::decay_t<Type>>(std::forward<Type>(value));
emplace<stl::decay_t<Type>>(stl::forward<Type>(value));
return *this;
}
@@ -444,13 +443,13 @@ public:
template<typename Type>
[[nodiscard]] const Type *try_cast() const {
const auto *elem = any_cast<const Type>(&storage);
return ((elem != nullptr) || !*this) ? elem : static_cast<const Type *>(internal::try_cast(internal::meta_context::from(*ctx), fetch_node(), type_hash<std::remove_const_t<Type>>::value(), storage.data()));
return ((elem != nullptr) || !*this) ? elem : static_cast<const Type *>(internal::try_cast(internal::meta_context::from(*ctx), fetch_node(), type_hash<stl::remove_const_t<Type>>::value(), storage.data()));
}
/*! @copydoc try_cast */
template<typename Type>
[[nodiscard]] Type *try_cast() {
return ((storage.policy() == any_policy::cref) && !std::is_const_v<Type>) ? nullptr : const_cast<Type *>(std::as_const(*this).try_cast<std::remove_const_t<Type>>());
return ((storage.policy() == any_policy::cref) && !stl::is_const_v<Type>) ? nullptr : const_cast<Type *>(stl::as_const(*this).try_cast<stl::remove_const_t<Type>>());
}
/**
@@ -459,17 +458,17 @@ public:
* @return A reference to the contained instance.
*/
template<typename Type>
[[nodiscard]] std::remove_const_t<Type> cast() const {
auto *const instance = try_cast<std::remove_reference_t<Type>>();
[[nodiscard]] stl::remove_const_t<Type> cast() const {
auto *const instance = try_cast<stl::remove_reference_t<Type>>();
ENTT_ASSERT(instance, "Invalid instance");
return static_cast<Type>(*instance);
}
/*! @copydoc cast */
template<typename Type>
[[nodiscard]] std::remove_const_t<Type> cast() {
[[nodiscard]] stl::remove_const_t<Type> cast() {
// forces const on non-reference types to make them work also with wrappers for const references
auto *const instance = try_cast<std::remove_reference_t<const Type>>();
auto *const instance = try_cast<stl::remove_reference_t<const Type>>();
ENTT_ASSERT(instance, "Invalid instance");
return static_cast<Type>(*instance);
}
@@ -495,25 +494,25 @@ public:
*/
template<typename Type>
[[nodiscard]] meta_any allow_cast() const {
if constexpr(!std::is_reference_v<Type> || std::is_const_v<std::remove_reference_t<Type>>) {
if(storage.has_value<std::remove_cvref_t<Type>>()) {
if constexpr(!stl::is_reference_v<Type> || stl::is_const_v<stl::remove_reference_t<Type>>) {
if(storage.has_value<stl::remove_cvref_t<Type>>()) {
return as_ref();
} else if(*this) {
if constexpr(std::is_arithmetic_v<std::remove_cvref_t<Type>> || std::is_enum_v<std::remove_cvref_t<Type>>) {
if constexpr(stl::is_arithmetic_v<stl::remove_cvref_t<Type>> || stl::is_enum_v<stl::remove_cvref_t<Type>>) {
if(const auto &from = fetch_node(); from.conversion_helper) {
return meta_any{*ctx, static_cast<Type>(from.conversion_helper(nullptr, storage.data()))};
}
}
if(const auto &from = fetch_node(); from.details != nullptr) {
if(const auto *elem = internal::find_member(from.details->conv, entt::type_hash<std::remove_cvref_t<Type>>::value()); elem != nullptr) {
if(const auto *elem = internal::find_member(from.details->conv, entt::type_hash<stl::remove_cvref_t<Type>>::value()); elem != nullptr) {
return elem->conv(*ctx, storage.data());
}
for(auto &&curr: from.details->base) {
if(auto other = curr.type(internal::meta_context::from(*ctx)).from_void(*ctx, nullptr, curr.cast(storage.data())); curr.id == entt::type_hash<std::remove_cvref_t<Type>>::value()) {
if(auto other = curr.type(internal::meta_context::from(*ctx)).from_void(*ctx, nullptr, curr.cast(storage.data())); curr.id == entt::type_hash<stl::remove_cvref_t<Type>>::value()) {
return other;
} else if(auto from_base = std::as_const(other).template allow_cast<Type>(); from_base) {
} else if(auto from_base = stl::as_const(other).template allow_cast<Type>(); from_base) {
return from_base;
}
}
@@ -531,14 +530,14 @@ public:
*/
template<typename Type>
[[nodiscard]] bool allow_cast() {
if constexpr(std::is_reference_v<Type> && !std::is_const_v<std::remove_reference_t<Type>>) {
return allow_cast<const std::remove_reference_t<Type> &>() && (storage.policy() != any_policy::cref);
if constexpr(stl::is_reference_v<Type> && !stl::is_const_v<stl::remove_reference_t<Type>>) {
return allow_cast<const stl::remove_reference_t<Type> &>() && (storage.policy() != any_policy::cref);
} else {
if(storage.has_value<std::remove_cvref_t<Type>>()) {
if(storage.has_value<stl::remove_cvref_t<Type>>()) {
return true;
} else if(auto other = std::as_const(*this).allow_cast<std::remove_cvref_t<Type>>(); other) {
} else if(auto other = stl::as_const(*this).allow_cast<stl::remove_cvref_t<Type>>(); other) {
if(other.storage.owner()) {
std::swap(*this, other);
stl::swap(*this, other);
}
return true;
@@ -551,8 +550,8 @@ public:
/*! @copydoc any::emplace */
template<typename Type, typename... Args>
void emplace(Args &&...args) {
storage.emplace<Type>(std::forward<Args>(args)...);
auto *prev = std::exchange(vtable, &basic_vtable<std::remove_cvref_t<Type>>);
storage.emplace<Type>(stl::forward<Args>(args)...);
auto *prev = stl::exchange(vtable, &basic_vtable<stl::remove_cvref_t<Type>>);
node = (prev == vtable) ? node : nullptr;
}
@@ -673,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, stl::in_place_type<Type &&>, stl::forward<Type>(value)};
}
/**
@@ -684,19 +683,19 @@ 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. */
class meta_handle {
template<typename Type, typename... Args>
requires std::same_as<std::remove_cvref_t<Type>, meta_any>
requires stl::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)..., stl::in_place_type<Type &>, value} {}
public:
/*! Default constructor. */
@@ -709,7 +708,7 @@ public:
* @param value An instance of an object to use to initialize the handle.
*/
template<typename Type>
requires (!std::same_as<std::remove_cvref_t<Type>, meta_handle>)
requires (!stl::same_as<stl::remove_cvref_t<Type>, meta_handle>)
meta_handle(const meta_ctx &ctx, Type &value)
: meta_handle{0, value, ctx} {}
@@ -719,7 +718,7 @@ public:
* @param value An instance of an object to use to initialize the handle.
*/
template<typename Type>
requires (!std::same_as<std::remove_cvref_t<Type>, meta_handle>)
requires (!stl::same_as<stl::remove_cvref_t<Type>, meta_handle>)
meta_handle(Type &value)
: meta_handle{0, value} {}
@@ -729,7 +728,7 @@ public:
* @param other The instance to move from.
*/
meta_handle(const meta_ctx &area, meta_handle &&other)
: any{area, std::move(other.any)} {}
: any{area, stl::move(other.any)} {}
/*! @brief Default copy constructor, deleted on purpose. */
meta_handle(const meta_handle &) = delete;
@@ -790,7 +789,7 @@ struct meta_custom {
*/
template<typename Type>
[[nodiscard]] operator Type *() const noexcept {
return ((node != nullptr) && (type_hash<std::remove_const_t<Type>>::value() == node->id)) ? static_cast<Type *>(node->value.get()) : nullptr;
return ((node != nullptr) && (type_hash<stl::remove_const_t<Type>>::value() == node->id)) ? static_cast<Type *>(node->value.get()) : nullptr;
}
/**
@@ -857,8 +856,8 @@ struct meta_data: meta_object<internal::meta_data_node> {
* @brief Returns the name assigned to a data member, if any.
* @return The name assigned to the data member, if any.
*/
[[nodiscard]] std::string_view name() const noexcept {
return (node_or_assert().name == nullptr) ? std::string_view{} : std::string_view{node_or_assert().name};
[[nodiscard]] stl::string_view name() const noexcept {
return (node_or_assert().name == nullptr) ? stl::string_view{} : stl::string_view{node_or_assert().name};
}
/**
@@ -899,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)});
}
/**
@@ -910,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)});
}
/**
@@ -950,8 +949,8 @@ struct meta_func: meta_object<internal::meta_func_node> {
* @brief Returns the name assigned to a member function, if any.
* @return The name assigned to the member function, if any.
*/
[[nodiscard]] std::string_view name() const noexcept {
return (node_or_assert().name == nullptr) ? std::string_view{} : std::string_view{node_or_assert().name};
[[nodiscard]] stl::string_view name() const noexcept {
return (node_or_assert().name == nullptr) ? stl::string_view{} : stl::string_view{node_or_assert().name};
}
/**
@@ -1001,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};
}
/**
@@ -1015,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), stl::array<meta_any, sizeof...(Args)>{meta_any{*ctx, stl::forward<Args>(args)}...}.data(), sizeof...(Args));
}
/*! @copydoc meta_data::traits */
@@ -1059,7 +1058,7 @@ class meta_type {
bool ambiguous{};
for(auto curr = next(); curr; curr = next()) {
if constexpr(std::is_same_v<std::decay_t<decltype(*curr)>, internal::meta_func_node>) {
if constexpr(stl::is_same_v<stl::decay_t<decltype(*curr)>, internal::meta_func_node>) {
if(constness && !(curr->traits & internal::meta_traits::is_const)) {
continue;
}
@@ -1069,7 +1068,7 @@ class meta_type {
size_type match{};
size_type pos{};
// NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic) - waiting for C++20 (and std::span)
// NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic) - waiting for C++20 (and stl::span)
for(; pos < sz && args[pos]; ++pos) {
const auto other = curr->arg(*ctx, pos);
const auto type = args[pos].type();
@@ -1088,7 +1087,7 @@ class meta_type {
same = match;
ambiguous = false;
} else if(match == same) {
if constexpr(std::is_same_v<std::decay_t<decltype(*curr)>, internal::meta_func_node>) {
if constexpr(stl::is_same_v<stl::decay_t<decltype(*curr)>, internal::meta_func_node>) {
if(!!(curr->traits & internal::meta_traits::is_const) != !!(candidate->traits & internal::meta_traits::is_const)) {
candidate = !!(candidate->traits & internal::meta_traits::is_const) ? curr : candidate;
ambiguous = false;
@@ -1141,8 +1140,8 @@ public:
* @brief Returns the name assigned to a type, if any.
* @return The name assigned to the type, if any.
*/
[[nodiscard]] std::string_view name() const noexcept {
return (fetch_node().name == nullptr) ? std::string_view{} : std::string_view{fetch_node().name};
[[nodiscard]] stl::string_view name() const noexcept {
return (fetch_node().name == nullptr) ? stl::string_view{} : stl::string_view{fetch_node().name};
}
/**
@@ -1386,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(stl::array<meta_any, sizeof...(Args)>{meta_any{*ctx, stl::forward<Args>(args)}...}.data(), sizeof...(Args));
// NOLINTNEXTLINE(clang-analyzer-cplusplus.NewDeleteLeaks)
}
@@ -1421,12 +1420,12 @@ 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) {
if(const auto *candidate = lookup(args, sz, (wrapped->base().policy() == any_policy::cref), [curr = elem]() mutable { return (curr != nullptr) ? std::exchange(curr, curr->next.get()) : nullptr; }); candidate) {
return candidate->invoke(std::move(wrapped), args);
if(const auto *candidate = lookup(args, sz, (wrapped->base().policy() == any_policy::cref), [curr = elem]() mutable { return (curr != nullptr) ? stl::exchange(curr, curr->next.get()) : nullptr; }); candidate) {
return candidate->invoke(stl::move(wrapped), args);
}
}
}
@@ -1452,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), stl::array<meta_any, sizeof...(Args)>{meta_any{*ctx, stl::forward<Args>(args)}...}.data(), sizeof...(Args));
}
/**
@@ -1468,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));
}
/**
@@ -1481,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 */
@@ -1517,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 {
@@ -1557,7 +1556,7 @@ bool meta_any::set(const id_type id, Type &&value) {
for(auto &&curr: from.details->base) {
if(auto other = curr.type(internal::meta_context::from(*ctx)).from_void(*ctx, nullptr, curr.cast(storage.data())); curr.id == type.info().hash()) {
return other;
} else if(auto from_base = std::as_const(other).allow_cast(type); from_base) {
} else if(auto from_base = stl::as_const(other).allow_cast(type); from_base) {
return from_base;
}
}
@@ -1570,9 +1569,9 @@ bool meta_any::set(const id_type id, Type &&value) {
[[nodiscard]] inline bool meta_any::allow_cast(const meta_type &type) {
if(storage.has_value(type.info())) {
return true;
} else if(auto other = std::as_const(*this).allow_cast(type); other) {
} else if(auto other = stl::as_const(*this).allow_cast(type); other) {
if(other.storage.owner()) {
std::swap(*this, other);
stl::swap(*this, other);
}
return true;
@@ -1591,7 +1590,7 @@ inline bool meta_any::assign(const meta_any &other) {
}
inline bool meta_any::assign(meta_any &&other) {
return storage.assign(std::move(other.storage)) || storage.assign(std::as_const(other).allow_cast(type()).storage);
return storage.assign(stl::move(other.storage)) || storage.assign(stl::as_const(other).allow_cast(type()).storage);
}
[[nodiscard]] inline meta_type meta_data::type() const noexcept {
@@ -1616,21 +1615,21 @@ inline bool meta_any::assign(meta_any &&other) {
/*! @cond ENTT_INTERNAL */
class meta_sequence_container::meta_iterator final {
using vtable_type = void(const void *, const std::ptrdiff_t, meta_any *);
using vtable_type = void(const void *, const stl::ptrdiff_t, meta_any *);
template<typename It>
static void basic_vtable(const void *value, const std::ptrdiff_t offset, meta_any *other) {
static void basic_vtable(const void *value, const stl::ptrdiff_t offset, meta_any *other) {
const auto &it = *static_cast<const It *>(value);
other ? other->emplace<decltype(*it)>(*it) : std::advance(const_cast<It &>(it), offset);
other ? other->emplace<decltype(*it)>(*it) : stl::advance(const_cast<It &>(it), offset);
}
public:
using value_type = meta_any;
using pointer = input_iterator_pointer<value_type>;
using reference = value_type;
using difference_type = std::ptrdiff_t;
using iterator_category = std::input_iterator_tag;
using iterator_concept = std::bidirectional_iterator_tag;
using difference_type = stl::ptrdiff_t;
using iterator_category = stl::input_iterator_tag;
using iterator_concept = stl::bidirectional_iterator_tag;
meta_iterator() = default;
@@ -1689,10 +1688,10 @@ private:
};
class meta_associative_container::meta_iterator final {
using vtable_type = void(const void *, std::pair<meta_any, meta_any> *);
using vtable_type = void(const void *, stl::pair<meta_any, meta_any> *);
template<bool KeyOnly, typename It>
static void basic_vtable(const void *value, std::pair<meta_any, meta_any> *other) {
static void basic_vtable(const void *value, stl::pair<meta_any, meta_any> *other) {
if(const auto &it = *static_cast<const It *>(value); other) {
if constexpr(KeyOnly) {
other->first.emplace<decltype(*it)>(*it);
@@ -1706,17 +1705,17 @@ class meta_associative_container::meta_iterator final {
}
public:
using value_type = std::pair<meta_any, meta_any>;
using value_type = stl::pair<meta_any, meta_any>;
using pointer = input_iterator_pointer<value_type>;
using reference = value_type;
using difference_type = std::ptrdiff_t;
using iterator_category = std::input_iterator_tag;
using iterator_concept = std::forward_iterator_tag;
using difference_type = stl::ptrdiff_t;
using iterator_category = stl::input_iterator_tag;
using iterator_concept = stl::forward_iterator_tag;
meta_iterator() = default;
template<bool KeyOnly, stl::forward_iterator It>
meta_iterator(const meta_ctx &area, std::bool_constant<KeyOnly>, It iter) noexcept
meta_iterator(const meta_ctx &area, stl::bool_constant<KeyOnly>, It iter) noexcept
: ctx{&area},
vtable{&basic_vtable<KeyOnly, It>},
handle{iter} {}
@@ -1822,7 +1821,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);

View File

@@ -1,13 +1,6 @@
#ifndef ENTT_META_NODE_HPP
#define ENTT_META_NODE_HPP
#include <array>
#include <bit>
#include <cstddef>
#include <memory>
#include <type_traits>
#include <utility>
#include <vector>
#include "../config/config.h"
#include "../core/bit.hpp"
#include "../core/concepts.hpp"
@@ -16,6 +9,14 @@
#include "../core/type_info.hpp"
#include "../core/type_traits.hpp"
#include "../core/utility.hpp"
#include "../stl/array.hpp"
#include "../stl/bit.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/cstdint.hpp"
#include "../stl/memory.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "../stl/vector.hpp"
#include "context.hpp"
#include "fwd.hpp"
#include "type_traits.hpp"
@@ -25,7 +26,7 @@ namespace entt {
/*! @cond ENTT_INTERNAL */
namespace internal {
enum class meta_traits : std::uint32_t {
enum class meta_traits : stl::uint32_t {
is_none = 0x0000,
is_const = 0x0001,
is_static = 0x0002,
@@ -44,18 +45,18 @@ enum class meta_traits : std::uint32_t {
};
template<typename Type>
requires std::is_enum_v<Type>
requires stl::is_enum_v<Type>
[[nodiscard]] auto meta_to_user_traits(const meta_traits traits) noexcept {
constexpr auto shift = std::popcount(static_cast<std::underlying_type_t<meta_traits>>(meta_traits::_user_defined_traits));
return Type{static_cast<std::underlying_type_t<Type>>(static_cast<std::underlying_type_t<meta_traits>>(traits) >> shift)};
constexpr auto shift = stl::popcount(static_cast<stl::underlying_type_t<meta_traits>>(meta_traits::_user_defined_traits));
return Type{static_cast<stl::underlying_type_t<Type>>(static_cast<stl::underlying_type_t<meta_traits>>(traits) >> shift)};
}
template<typename Type>
requires std::is_enum_v<Type>
requires stl::is_enum_v<Type>
[[nodiscard]] auto user_to_meta_traits(const Type value) noexcept {
constexpr auto shift = std::popcount(static_cast<std::underlying_type_t<meta_traits>>(meta_traits::_user_defined_traits));
const auto traits = static_cast<std::underlying_type_t<internal::meta_traits>>(static_cast<std::underlying_type_t<Type>>(value));
ENTT_ASSERT(traits < ((~static_cast<std::underlying_type_t<meta_traits>>(meta_traits::_user_defined_traits)) >> shift), "Invalid traits");
constexpr auto shift = stl::popcount(static_cast<stl::underlying_type_t<meta_traits>>(meta_traits::_user_defined_traits));
const auto traits = static_cast<stl::underlying_type_t<internal::meta_traits>>(static_cast<stl::underlying_type_t<Type>>(value));
ENTT_ASSERT(traits < ((~static_cast<stl::underlying_type_t<meta_traits>>(meta_traits::_user_defined_traits)) >> shift), "Invalid traits");
return meta_traits{traits << shift};
}
@@ -63,7 +64,7 @@ struct meta_type_node;
struct meta_custom_node {
id_type id{};
std::shared_ptr<void> value{};
stl::shared_ptr<void> value{};
};
struct meta_base_node {
@@ -78,7 +79,7 @@ struct meta_conv_node {
};
struct meta_ctor_node {
using size_type = std::size_t;
using size_type = stl::size_t;
id_type id{};
size_type arity{0u};
@@ -87,7 +88,7 @@ struct meta_ctor_node {
};
struct meta_data_node {
using size_type = std::size_t;
using size_type = stl::size_t;
id_type id{};
const char *name{};
@@ -101,7 +102,7 @@ struct meta_data_node {
};
struct meta_func_node {
using size_type = std::size_t;
using size_type = stl::size_t;
id_type id{};
const char *name{};
@@ -110,12 +111,12 @@ struct meta_func_node {
const meta_type_node &(*ret)(const meta_context &) noexcept {};
meta_type (*arg)(const meta_ctx &, const size_type) noexcept {};
meta_any (*invoke)(meta_handle, meta_any *const){};
std::unique_ptr<meta_func_node> next;
stl::unique_ptr<meta_func_node> next;
meta_custom_node custom{};
};
struct meta_template_node {
using size_type = std::size_t;
using size_type = stl::size_t;
size_type arity{0u};
const meta_type_node &(*resolve)(const meta_context &) noexcept {};
@@ -123,15 +124,15 @@ 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 {
using size_type = std::size_t;
using size_type = stl::size_t;
const type_info *info{};
id_type id{};
@@ -144,7 +145,7 @@ struct meta_type_node {
meta_any (*from_void)(const meta_ctx &, void *, const void *){};
meta_template_node templ{};
meta_custom_node custom{};
std::unique_ptr<meta_type_descriptor> details{};
stl::unique_ptr<meta_type_descriptor> details{};
};
template<typename Type, typename Value>
@@ -158,14 +159,14 @@ template<typename Type, typename Value>
return static_cast<Type::value_type *>(nullptr);
}
[[nodiscard]] inline auto *find_overload(meta_func_node *curr, std::remove_pointer_t<decltype(meta_func_node::invoke)> *const ref) {
[[nodiscard]] inline auto *find_overload(meta_func_node *curr, stl::remove_pointer_t<decltype(meta_func_node::invoke)> *const ref) {
while((curr != nullptr) && (curr->invoke != ref)) { curr = curr->next.get(); }
return curr;
}
template<auto Member>
[[nodiscard]] auto *look_for(const meta_context &context, const meta_type_node &node, const id_type id, bool recursive) {
using value_type = std::remove_reference_t<decltype((node.details.get()->*Member))>::value_type;
using value_type = stl::remove_reference_t<decltype((node.details.get()->*Member))>::value_type;
if(node.details) {
if(auto *member = find_member((node.details.get()->*Member), id); member != nullptr) {
@@ -188,9 +189,9 @@ template<cvref_unqualified Type>
const meta_type_node &resolve(const meta_context &) noexcept;
template<typename... Args>
[[nodiscard]] const meta_type_node &meta_arg_node(const meta_context &context, type_list<Args...>, const std::size_t index) noexcept {
[[nodiscard]] const meta_type_node &meta_arg_node(const meta_context &context, type_list<Args...>, const stl::size_t index) noexcept {
using resolve_type = const meta_type_node &(*)(const meta_context &) noexcept;
constexpr std::array<resolve_type, sizeof...(Args)> list{&resolve<std::remove_cvref_t<Args>>...};
constexpr stl::array<resolve_type, sizeof...(Args)> list{&resolve<stl::remove_cvref_t<Args>>...};
ENTT_ASSERT(index < sizeof...(Args), "Out of bounds");
return list[index](context);
}
@@ -215,47 +216,47 @@ auto setup_node_for() noexcept {
&type_id<Type>(),
type_id<Type>().hash(),
nullptr,
(std::is_arithmetic_v<Type> ? meta_traits::is_arithmetic : meta_traits::is_none)
| (std::is_integral_v<Type> ? meta_traits::is_integral : meta_traits::is_none)
| (std::is_signed_v<Type> ? meta_traits::is_signed : meta_traits::is_none)
| (std::is_array_v<Type> ? meta_traits::is_array : meta_traits::is_none)
| (std::is_enum_v<Type> ? meta_traits::is_enum : meta_traits::is_none)
| (std::is_class_v<Type> ? meta_traits::is_class : meta_traits::is_none)
| (std::is_pointer_v<Type> ? meta_traits::is_pointer : meta_traits::is_none)
(stl::is_arithmetic_v<Type> ? meta_traits::is_arithmetic : meta_traits::is_none)
| (stl::is_integral_v<Type> ? meta_traits::is_integral : meta_traits::is_none)
| (stl::is_signed_v<Type> ? meta_traits::is_signed : meta_traits::is_none)
| (stl::is_array_v<Type> ? meta_traits::is_array : meta_traits::is_none)
| (stl::is_enum_v<Type> ? meta_traits::is_enum : meta_traits::is_none)
| (stl::is_class_v<Type> ? meta_traits::is_class : meta_traits::is_none)
| (stl::is_pointer_v<Type> ? meta_traits::is_pointer : meta_traits::is_none)
| (is_meta_pointer_like_v<Type> ? meta_traits::is_pointer_like : meta_traits::is_none)
| (is_complete_v<meta_sequence_container_traits<Type>> ? meta_traits::is_sequence_container : meta_traits::is_none)
| (is_complete_v<meta_associative_container_traits<Type>> ? meta_traits::is_associative_container : meta_traits::is_none),
size_of_v<Type>,
&resolve<std::remove_const_t<std::remove_pointer_t<Type>>>};
&resolve<stl::remove_const_t<stl::remove_pointer_t<Type>>>};
if constexpr(std::is_default_constructible_v<Type>) {
if constexpr(stl::is_default_constructible_v<Type>) {
node.default_constructor = +[](const meta_ctx &ctx) {
return meta_any{ctx, std::in_place_type<Type>};
return meta_any{ctx, stl::in_place_type<Type>};
};
}
if constexpr(std::is_arithmetic_v<Type>) {
if constexpr(stl::is_arithmetic_v<Type>) {
node.conversion_helper = +[](void *lhs, const void *rhs) {
return lhs ? static_cast<double>(*static_cast<Type *>(lhs) = static_cast<Type>(*static_cast<const double *>(rhs))) : static_cast<double>(*static_cast<const Type *>(rhs));
};
} else if constexpr(std::is_enum_v<Type>) {
} else if constexpr(stl::is_enum_v<Type>) {
node.conversion_helper = +[](void *lhs, const void *rhs) {
return lhs ? static_cast<double>(*static_cast<Type *>(lhs) = static_cast<Type>(static_cast<std::underlying_type_t<Type>>(*static_cast<const double *>(rhs)))) : static_cast<double>(*static_cast<const Type *>(rhs));
return lhs ? static_cast<double>(*static_cast<Type *>(lhs) = static_cast<Type>(static_cast<stl::underlying_type_t<Type>>(*static_cast<const double *>(rhs)))) : static_cast<double>(*static_cast<const Type *>(rhs));
};
}
if constexpr(!std::is_void_v<Type> && !std::is_function_v<Type>) {
if constexpr(!stl::is_void_v<Type> && !stl::is_function_v<Type>) {
node.from_void = +[](const meta_ctx &ctx, void *elem, const void *celem) {
if(elem && celem) { // ownership construction request
return meta_any{ctx, std::in_place, static_cast<std::decay_t<Type> *>(elem)};
return meta_any{ctx, stl::in_place, static_cast<stl::decay_t<Type> *>(elem)};
}
if(elem) { // non-const reference construction request
return meta_any{ctx, std::in_place_type<std::decay_t<Type> &>, *static_cast<std::decay_t<Type> *>(elem)};
return meta_any{ctx, stl::in_place_type<stl::decay_t<Type> &>, *static_cast<stl::decay_t<Type> *>(elem)};
}
// const reference construction request
return meta_any{ctx, std::in_place_type<const std::decay_t<Type> &>, *static_cast<const std::decay_t<Type> *>(celem)};
return meta_any{ctx, stl::in_place_type<const stl::decay_t<Type> &>, *static_cast<const stl::decay_t<Type> *>(celem)};
};
}
@@ -263,7 +264,7 @@ auto setup_node_for() noexcept {
node.templ = meta_template_node{
meta_template_traits<Type>::args_type::size,
&resolve<typename meta_template_traits<Type>::class_type>,
+[](const meta_context &area, const std::size_t index) noexcept -> decltype(auto) { return meta_arg_node(area, typename meta_template_traits<Type>::args_type{}, index); }};
+[](const meta_context &area, const stl::size_t index) noexcept -> decltype(auto) { return meta_arg_node(area, typename meta_template_traits<Type>::args_type{}, index); }};
}
return node;

View File

@@ -3,30 +3,30 @@
#ifndef ENTT_META_POINTER_HPP
#define ENTT_META_POINTER_HPP
#include <memory>
#include <type_traits>
#include "../stl/memory.hpp"
#include "../stl/type_traits.hpp"
#include "type_traits.hpp"
namespace entt {
/**
* @brief Makes `std::shared_ptr`s of any type pointer-like types for the meta
* @brief Makes `stl::shared_ptr`s of any type pointer-like types for the meta
* system.
* @tparam Type Element type.
*/
template<typename Type>
struct is_meta_pointer_like<std::shared_ptr<Type>>
: std::true_type {};
struct is_meta_pointer_like<stl::shared_ptr<Type>>
: stl::true_type {};
/**
* @brief Makes `std::unique_ptr`s of any type pointer-like types for the meta
* @brief Makes `stl::unique_ptr`s of any type pointer-like types for the meta
* system.
* @tparam Type Element type.
* @tparam Args Other arguments.
*/
template<typename Type, typename... Args>
struct is_meta_pointer_like<std::unique_ptr<Type, Args...>>
: std::true_type {};
struct is_meta_pointer_like<stl::unique_ptr<Type, Args...>>
: stl::true_type {};
/**
* @brief Specialization for self-proclaimed meta pointer like types.
@@ -35,7 +35,7 @@ struct is_meta_pointer_like<std::unique_ptr<Type, Args...>>
template<typename Type>
requires requires { typename Type::is_meta_pointer_like; }
struct is_meta_pointer_like<Type>
: std::true_type {};
: stl::true_type {};
} // namespace entt

View File

@@ -1,7 +1,7 @@
#ifndef ENTT_META_POLICY_HPP
#define ENTT_META_POLICY_HPP
#include <type_traits>
#include "../stl/type_traits.hpp"
namespace entt {
@@ -33,7 +33,7 @@ struct as_void_t final: private internal::meta_policy {
struct as_ref_t final: private internal::meta_policy {
/*! @cond ENTT_INTERNAL */
template<typename Type>
static constexpr bool value = std::is_reference_v<Type> && !std::is_const_v<std::remove_reference_t<Type>>;
static constexpr bool value = stl::is_reference_v<Type> && !stl::is_const_v<stl::remove_reference_t<Type>>;
/*! @endcond */
};
@@ -41,7 +41,7 @@ struct as_ref_t final: private internal::meta_policy {
struct as_cref_t final: private internal::meta_policy {
/*! @cond ENTT_INTERNAL */
template<typename Type>
static constexpr bool value = std::is_reference_v<Type>;
static constexpr bool value = stl::is_reference_v<Type>;
/*! @endcond */
};
@@ -60,7 +60,7 @@ struct as_is_t final: private internal::meta_policy {
*/
template<typename Type>
struct is_meta_policy
: std::bool_constant<std::is_base_of_v<internal::meta_policy, Type>> {};
: stl::bool_constant<stl::is_base_of_v<internal::meta_policy, Type>> {};
/**
* @brief Helper variable template.

View File

@@ -2,13 +2,12 @@
#define ENTT_META_RANGE_HPP
#include <compare>
#include <concepts>
#include <cstddef>
#include <iterator>
#include <utility>
#include "../core/fwd.hpp"
#include "../core/iterator.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/iterator.hpp"
#include "../stl/utility.hpp"
#include "context.hpp"
namespace entt {
@@ -20,12 +19,12 @@ struct meta_base_node;
template<typename Type, typename It>
struct meta_range_iterator final {
using value_type = std::pair<id_type, Type>;
using value_type = stl::pair<id_type, Type>;
using pointer = input_iterator_pointer<value_type>;
using reference = value_type;
using difference_type = std::ptrdiff_t;
using iterator_category = std::input_iterator_tag;
using iterator_concept = std::random_access_iterator_tag;
using difference_type = stl::ptrdiff_t;
using iterator_category = stl::input_iterator_tag;
using iterator_concept = stl::random_access_iterator_tag;
constexpr meta_range_iterator() noexcept
: it{},
@@ -72,7 +71,7 @@ struct meta_range_iterator final {
}
[[nodiscard]] constexpr reference operator[](const difference_type value) const noexcept {
if constexpr(std::is_same_v<It, typename meta_context::container_type::const_iterator>) {
if constexpr(stl::is_same_v<It, typename meta_context::container_type::const_iterator>) {
return {it[value].first, Type{*ctx, *it[value].second}};
} else {
return {it[value].id, Type{*ctx, it[value]}};
@@ -87,7 +86,7 @@ struct meta_range_iterator final {
return operator[](0);
}
[[nodiscard]] constexpr std::ptrdiff_t operator-(const meta_range_iterator &other) const noexcept {
[[nodiscard]] constexpr stl::ptrdiff_t operator-(const meta_range_iterator &other) const noexcept {
return it - other.it;
}

View File

@@ -1,9 +1,9 @@
#ifndef ENTT_META_RESOLVE_HPP
#define ENTT_META_RESOLVE_HPP
#include <type_traits>
#include "../core/type_info.hpp"
#include "../locator/locator.hpp"
#include "../stl/type_traits.hpp"
#include "context.hpp"
#include "meta.hpp"
#include "node.hpp"
@@ -20,7 +20,7 @@ namespace entt {
template<typename Type>
[[nodiscard]] meta_type resolve(const meta_ctx &ctx) noexcept {
const auto &context = internal::meta_context::from(ctx);
return {ctx, internal::resolve<std::remove_cvref_t<Type>>(context)};
return {ctx, internal::resolve<stl::remove_cvref_t<Type>>(context)};
}
/**

View File

@@ -1,8 +1,8 @@
#ifndef ENTT_META_TYPE_TRAITS_HPP
#define ENTT_META_TYPE_TRAITS_HPP
#include <type_traits>
#include <utility>
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
namespace entt {
@@ -32,7 +32,7 @@ struct meta_associative_container_traits;
* pointer-like type from the point of view of the meta system, false otherwise.
*/
template<typename>
struct is_meta_pointer_like: std::false_type {};
struct is_meta_pointer_like: stl::false_type {};
/**
* @brief Partial specialization to ensure that const pointer-like types are

View File

@@ -1,12 +1,12 @@
#ifndef ENTT_META_UTILITY_HPP
#define ENTT_META_UTILITY_HPP
#include <cstddef>
#include <functional>
#include <type_traits>
#include <utility>
#include "../core/type_traits.hpp"
#include "../locator/locator.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/functional.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "meta.hpp"
#include "node.hpp"
#include "policy.hpp"
@@ -48,8 +48,8 @@ template<typename Type, typename Ret, typename Class, typename... Args>
struct meta_function_descriptor<Type, Ret (Class::*)(Args...) const>
: meta_function_descriptor_traits<
Ret,
std::conditional_t<std::is_base_of_v<Class, Type>, type_list<Args...>, type_list<const Class &, Args...>>,
!std::is_base_of_v<Class, Type>,
stl::conditional_t<stl::is_base_of_v<Class, Type>, type_list<Args...>, type_list<const Class &, Args...>>,
!stl::is_base_of_v<Class, Type>,
true> {};
/**
@@ -63,8 +63,8 @@ template<typename Type, typename Ret, typename Class, typename... Args>
struct meta_function_descriptor<Type, Ret (Class::*)(Args...)>
: meta_function_descriptor_traits<
Ret,
std::conditional_t<std::is_base_of_v<Class, Type>, type_list<Args...>, type_list<Class &, Args...>>,
!std::is_base_of_v<Class, Type>,
stl::conditional_t<stl::is_base_of_v<Class, Type>, type_list<Args...>, type_list<Class &, Args...>>,
!stl::is_base_of_v<Class, Type>,
false> {};
/**
@@ -77,8 +77,8 @@ template<typename Type, typename Ret, typename Class>
struct meta_function_descriptor<Type, Ret Class::*>
: meta_function_descriptor_traits<
Ret &,
std::conditional_t<std::is_base_of_v<Class, Type>, type_list<>, type_list<Class &>>,
!std::is_base_of_v<Class, Type>,
stl::conditional_t<stl::is_base_of_v<Class, Type>, type_list<>, type_list<Class &>>,
!stl::is_base_of_v<Class, Type>,
false> {};
/**
@@ -92,12 +92,12 @@ template<typename Type, typename Ret, typename MaybeType, typename... Args>
struct meta_function_descriptor<Type, Ret (*)(MaybeType, Args...)>
: meta_function_descriptor_traits<
Ret,
std::conditional_t<
std::is_same_v<std::remove_cvref_t<MaybeType>, Type> || std::is_base_of_v<std::remove_cvref_t<MaybeType>, Type>,
stl::conditional_t<
stl::is_same_v<stl::remove_cvref_t<MaybeType>, Type> || stl::is_base_of_v<stl::remove_cvref_t<MaybeType>, Type>,
type_list<Args...>,
type_list<MaybeType, Args...>>,
!(std::is_same_v<std::remove_cvref_t<MaybeType>, Type> || std::is_base_of_v<std::remove_cvref_t<MaybeType>, Type>),
std::is_const_v<std::remove_reference_t<MaybeType>> && (std::is_same_v<std::remove_cvref_t<MaybeType>, Type> || std::is_base_of_v<std::remove_cvref_t<MaybeType>, Type>)> {};
!(stl::is_same_v<stl::remove_cvref_t<MaybeType>, Type> || stl::is_base_of_v<stl::remove_cvref_t<MaybeType>, Type>),
stl::is_const_v<stl::remove_reference_t<MaybeType>> && (stl::is_same_v<stl::remove_cvref_t<MaybeType>, Type> || stl::is_base_of_v<stl::remove_cvref_t<MaybeType>, Type>)> {};
/**
* @brief Meta function descriptor.
@@ -130,7 +130,7 @@ class meta_function_helper {
static meta_function_descriptor<Type, Ret (Class::*)(Args...)> get_rid_of_noexcept(Ret (Class::*)(Args...));
template<typename Ret, typename Class>
requires std::is_member_object_pointer_v<Ret Class::*>
requires stl::is_member_object_pointer_v<Ret Class::*>
static meta_function_descriptor<Type, Ret Class::*> get_rid_of_noexcept(Ret Class::*);
template<typename Ret, typename... Args>
@@ -141,7 +141,7 @@ class meta_function_helper {
public:
/*! @brief The meta function descriptor of the given function. */
using type = decltype(get_rid_of_noexcept(std::declval<Candidate>()));
using type = decltype(get_rid_of_noexcept(stl::declval<Candidate>()));
};
/**
@@ -167,15 +167,15 @@ using meta_function_helper_t = meta_function_helper<Type, Candidate>::type;
*/
template<meta_policy Policy = as_value_t, typename Type>
[[nodiscard]] meta_any meta_dispatch(const meta_ctx &ctx, [[maybe_unused]] Type &&value) {
if constexpr(std::is_same_v<Policy, as_cref_t>) {
static_assert(std::is_lvalue_reference_v<Type>, "Invalid type");
return meta_any{ctx, std::in_place_type<const std::remove_reference_t<Type> &>, std::as_const(value)};
} else if constexpr(std::is_same_v<Policy, as_ref_t> || (std::is_same_v<Policy, as_is_t> && std::is_lvalue_reference_v<Type>)) {
return meta_any{ctx, std::in_place_type<Type>, value};
} else if constexpr(std::is_same_v<Policy, as_void_t>) {
return meta_any{ctx, std::in_place_type<void>};
if constexpr(stl::is_same_v<Policy, as_cref_t>) {
static_assert(stl::is_lvalue_reference_v<Type>, "Invalid type");
return meta_any{ctx, stl::in_place_type<const stl::remove_reference_t<Type> &>, stl::as_const(value)};
} else if constexpr(stl::is_same_v<Policy, as_ref_t> || (stl::is_same_v<Policy, as_is_t> && stl::is_lvalue_reference_v<Type>)) {
return meta_any{ctx, stl::in_place_type<Type>, value};
} else if constexpr(stl::is_same_v<Policy, as_void_t>) {
return meta_any{ctx, stl::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,30 +196,30 @@ 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...);
return meta_any{ctx, std::in_place_type<void>};
if constexpr(stl::is_void_v<decltype(stl::invoke(stl::forward<Candidate>(candidate), args...))>) {
stl::invoke(stl::forward<Candidate>(candidate), args...);
return meta_any{ctx, stl::in_place_type<void>};
} else {
return meta_dispatch<Policy>(ctx, std::invoke(std::forward<Candidate>(candidate), args...));
return meta_dispatch<Policy>(ctx, stl::invoke(stl::forward<Candidate>(candidate), args...));
}
}
template<typename Type, typename Policy, typename Candidate, std::size_t... Index>
[[nodiscard]] meta_any meta_invoke(meta_any &instance, Candidate &&candidate, [[maybe_unused]] meta_any *const args, std::index_sequence<Index...>) {
using descriptor = meta_function_helper_t<Type, std::remove_reference_t<Candidate>>;
template<typename Type, typename Policy, typename Candidate, stl::size_t... Index>
[[nodiscard]] meta_any meta_invoke(meta_any &instance, Candidate &&candidate, [[maybe_unused]] meta_any *const args, stl::index_sequence<Index...>) {
using descriptor = meta_function_helper_t<Type, stl::remove_reference_t<Candidate>>;
// 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>...>) {
// NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic) - waiting for C++20 (and stl::span)
if constexpr(stl::is_invocable_v<stl::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>...>) {
} else if constexpr(stl::is_invocable_v<stl::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)
@@ -227,11 +227,11 @@ template<typename Type, typename Policy, typename Candidate, std::size_t... Inde
return meta_any{meta_ctx_arg, instance.context()};
}
template<typename Type, typename... Args, std::size_t... Index>
[[nodiscard]] meta_any meta_construct(const meta_ctx &ctx, meta_any *const args, std::index_sequence<Index...>) {
// NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic) - waiting for C++20 (and std::span)
template<typename Type, typename... Args, stl::size_t... Index>
[[nodiscard]] meta_any meta_construct(const meta_ctx &ctx, meta_any *const args, stl::index_sequence<Index...>) {
// NOLINTBEGIN(cppcoreguidelines-pro-bounds-pointer-arithmetic) - waiting for C++20 (and stl::span)
if(((args + Index)->allow_cast<Args>() && ...)) {
return meta_any{ctx, std::in_place_type<Type>, (args + Index)->cast<Args>()...};
return meta_any{ctx, stl::in_place_type<Type>, (args + Index)->cast<Args>()...};
}
// NOLINTEND(cppcoreguidelines-pro-bounds-pointer-arithmetic)
@@ -249,7 +249,7 @@ template<typename Type, typename... Args, std::size_t... Index>
* @return The meta type of the i-th element of the list of arguments.
*/
template<typename Type>
[[nodiscard]] meta_type meta_arg(const meta_ctx &ctx, const std::size_t index) noexcept {
[[nodiscard]] meta_type meta_arg(const meta_ctx &ctx, const stl::size_t index) noexcept {
const auto &context = internal::meta_context::from(ctx);
return {ctx, internal::meta_arg_node(context, Type{}, index)};
}
@@ -261,7 +261,7 @@ template<typename Type>
* @return The meta type of the i-th element of the list of arguments.
*/
template<typename Type>
[[nodiscard]] meta_type meta_arg(const std::size_t index) noexcept {
[[nodiscard]] meta_type meta_arg(const stl::size_t index) noexcept {
return meta_arg<Type>(locator<meta_ctx>::value_or(), index);
}
@@ -275,27 +275,27 @@ template<typename Type>
*/
template<typename Type, auto Data>
[[nodiscard]] bool meta_setter([[maybe_unused]] meta_handle instance, [[maybe_unused]] meta_any value) {
if constexpr(std::is_member_function_pointer_v<decltype(Data)> || std::is_function_v<std::remove_reference_t<std::remove_pointer_t<decltype(Data)>>>) {
if constexpr(stl::is_member_function_pointer_v<decltype(Data)> || stl::is_function_v<stl::remove_reference_t<stl::remove_pointer_t<decltype(Data)>>>) {
using descriptor = meta_function_helper_t<Type, decltype(Data)>;
using data_type = type_list_element_t<descriptor::is_static, typename descriptor::args_type>;
if(auto *const clazz = instance->try_cast<Type>(); clazz && value.allow_cast<data_type>()) {
std::invoke(Data, *clazz, value.cast<data_type>());
stl::invoke(Data, *clazz, value.cast<data_type>());
return true;
}
} else if constexpr(std::is_member_object_pointer_v<decltype(Data)>) {
using data_type = std::remove_reference_t<typename meta_function_helper_t<Type, decltype(Data)>::return_type>;
} else if constexpr(stl::is_member_object_pointer_v<decltype(Data)>) {
using data_type = stl::remove_reference_t<typename meta_function_helper_t<Type, decltype(Data)>::return_type>;
if constexpr(!std::is_array_v<data_type> && !std::is_const_v<data_type>) {
if constexpr(!stl::is_array_v<data_type> && !stl::is_const_v<data_type>) {
if(auto *const clazz = instance->try_cast<Type>(); clazz && value.allow_cast<data_type>()) {
std::invoke(Data, *clazz) = value.cast<data_type>();
stl::invoke(Data, *clazz) = value.cast<data_type>();
return true;
}
}
} else if constexpr(std::is_pointer_v<decltype(Data)>) {
using data_type = std::remove_reference_t<decltype(*Data)>;
} else if constexpr(stl::is_pointer_v<decltype(Data)>) {
using data_type = stl::remove_reference_t<decltype(*Data)>;
if constexpr(!std::is_array_v<data_type> && !std::is_const_v<data_type>) {
if constexpr(!stl::is_array_v<data_type> && !stl::is_const_v<data_type>) {
if(value.allow_cast<data_type>()) {
*Data = value.cast<data_type>();
return true;
@@ -316,24 +316,24 @@ template<typename Type, auto Data>
*/
template<typename Type, auto Data, meta_policy Policy = as_value_t>
[[nodiscard]] meta_any meta_getter(meta_handle instance) {
if constexpr(std::is_member_pointer_v<decltype(Data)> || std::is_function_v<std::remove_reference_t<std::remove_pointer_t<decltype(Data)>>>) {
if constexpr(!std::is_array_v<std::remove_cvref_t<std::invoke_result_t<decltype(Data), Type &>>>) {
if constexpr(std::is_invocable_v<decltype(Data), Type &>) {
if constexpr(stl::is_member_pointer_v<decltype(Data)> || stl::is_function_v<stl::remove_reference_t<stl::remove_pointer_t<decltype(Data)>>>) {
if constexpr(!stl::is_array_v<stl::remove_cvref_t<stl::invoke_result_t<decltype(Data), Type &>>>) {
if constexpr(stl::is_invocable_v<decltype(Data), Type &>) {
if(auto *clazz = instance->try_cast<Type>(); clazz) {
return meta_dispatch<Policy>(instance->context(), std::invoke(Data, *clazz));
return meta_dispatch<Policy>(instance->context(), stl::invoke(Data, *clazz));
}
}
if constexpr(std::is_invocable_v<decltype(Data), const Type &>) {
if constexpr(stl::is_invocable_v<decltype(Data), const Type &>) {
if(auto *fallback = instance->try_cast<const Type>(); fallback) {
return meta_dispatch<Policy>(instance->context(), std::invoke(Data, *fallback));
return meta_dispatch<Policy>(instance->context(), stl::invoke(Data, *fallback));
}
}
}
return meta_any{meta_ctx_arg, instance->context()};
} else if constexpr(std::is_pointer_v<decltype(Data)>) {
if constexpr(std::is_array_v<std::remove_pointer_t<decltype(Data)>>) {
} else if constexpr(stl::is_pointer_v<decltype(Data)>) {
if constexpr(stl::is_array_v<stl::remove_pointer_t<decltype(Data)>>) {
return meta_any{meta_ctx_arg, instance->context()};
} else {
return meta_dispatch<Policy>(instance->context(), *Data);
@@ -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, stl::make_index_sequence<meta_function_helper_t<Type, stl::remove_reference_t<Candidate>>::args_type::size>{});
}
/**
@@ -369,7 +369,7 @@ template<typename Type, meta_policy Policy = as_value_t, typename Candidate>
*/
template<typename Type, auto Candidate, meta_policy Policy = as_value_t>
[[nodiscard]] meta_any meta_invoke(meta_handle instance, meta_any *const args) {
return internal::meta_invoke<Type, Policy>(*instance.operator->(), Candidate, args, std::make_index_sequence<meta_function_helper_t<Type, std::remove_reference_t<decltype(Candidate)>>::args_type::size>{});
return internal::meta_invoke<Type, Policy>(*instance.operator->(), Candidate, args, stl::make_index_sequence<meta_function_helper_t<Type, stl::remove_reference_t<decltype(Candidate)>>::args_type::size>{});
}
/**
@@ -387,7 +387,7 @@ template<typename Type, auto Candidate, meta_policy Policy = as_value_t>
*/
template<typename Type, typename... Args>
[[nodiscard]] meta_any meta_construct(const meta_ctx &ctx, meta_any *const args) {
return internal::meta_construct<Type, Args...>(ctx, args, std::index_sequence_for<Args...>{});
return internal::meta_construct<Type, Args...>(ctx, args, stl::index_sequence_for<Args...>{});
}
/**
@@ -419,12 +419,12 @@ template<typename Type, typename... Args>
*/
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<std::remove_cvref_t<Candidate>>) {
if constexpr(meta_function_helper_t<Type, Candidate>::is_static || stl::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, stl::make_index_sequence<meta_function_helper_t<Type, stl::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>{});
// NOLINTNEXTLINE(cppcoreguidelines-pro-bounds-pointer-arithmetic) - waiting for C++20 (and stl::span)
return internal::meta_invoke<Type, Policy>(*args, stl::forward<Candidate>(candidate), args + 1u, stl::make_index_sequence<meta_function_helper_t<Type, stl::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);
}
/**

View File

@@ -1,12 +1,12 @@
#ifndef ENTT_POLY_FWD_HPP
#define ENTT_POLY_FWD_HPP
#include <cstddef>
#include "../stl/cstddef.hpp"
namespace entt {
// NOLINTNEXTLINE(cppcoreguidelines-avoid-c-arrays, modernize-avoid-c-arrays)
template<typename, std::size_t Len = sizeof(double[2]), std::size_t = alignof(double[2])>
template<typename, stl::size_t Len = sizeof(double[2]), stl::size_t = alignof(double[2])>
class basic_poly;
/**

View File

@@ -1,16 +1,16 @@
#ifndef ENTT_POLY_POLY_HPP
#define ENTT_POLY_POLY_HPP
#include <concepts>
#include <cstddef>
#include <functional>
#include <tuple>
#include <type_traits>
#include <utility>
#include "../core/any.hpp"
#include "../core/concepts.hpp"
#include "../core/type_info.hpp"
#include "../core/type_traits.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/functional.hpp"
#include "../stl/tuple.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "fwd.hpp"
namespace entt {
@@ -31,11 +31,11 @@ struct poly_inspector {
* @param args The arguments to pass to the function.
* @return A poly inspector convertible to any type.
*/
template<std::size_t Member, typename... Args>
template<stl::size_t Member, typename... Args>
[[nodiscard]] poly_inspector invoke(Args &&...args) const;
/*! @copydoc invoke */
template<std::size_t Member, typename... Args>
template<stl::size_t Member, typename... Args>
[[nodiscard]] poly_inspector invoke(Args &&...args);
};
@@ -45,12 +45,12 @@ struct poly_inspector {
* @tparam Len Size of the storage reserved for the small buffer optimization.
* @tparam Align Alignment requirement.
*/
template<typename Concept, std::size_t Len, std::size_t Align>
template<typename Concept, stl::size_t Len, stl::size_t Align>
class poly_vtable {
using inspector = Concept::template type<poly_inspector>;
template<typename Ret, typename Clazz, typename... Args>
requires std::derived_from<inspector, std::remove_const_t<Clazz>>
requires stl::derived_from<inspector, stl::remove_const_t<Clazz>>
static auto vtable_entry(Ret (*)(Clazz &, Args...))
-> Ret (*)(constness_as_t<basic_any<Len, Align>, Clazz> &, Args...);
@@ -59,54 +59,54 @@ class poly_vtable {
-> Ret (*)(const basic_any<Len, Align> &, Args...);
template<typename Ret, typename Clazz, typename... Args>
requires std::derived_from<inspector, Clazz>
requires stl::derived_from<inspector, Clazz>
static auto vtable_entry(Ret (Clazz::*)(Args...))
-> Ret (*)(basic_any<Len, Align> &, Args...);
template<typename Ret, typename Clazz, typename... Args>
requires std::derived_from<inspector, Clazz>
requires stl::derived_from<inspector, Clazz>
static auto vtable_entry(Ret (Clazz::*)(Args...) const)
-> Ret (*)(const basic_any<Len, Align> &, Args...);
template<auto... Candidate>
static auto make_vtable(value_list<Candidate...>) noexcept
-> decltype(std::make_tuple(vtable_entry(Candidate)...));
-> decltype(stl::make_tuple(vtable_entry(Candidate)...));
template<typename... Func>
[[nodiscard]] static ENTT_CONSTEVAL auto make_vtable(type_list<Func...>) noexcept {
if constexpr(sizeof...(Func) == 0u) {
return decltype(make_vtable(typename Concept::template impl<inspector>{})){};
} else if constexpr((std::is_function_v<Func> && ...)) {
return decltype(std::make_tuple(vtable_entry(std::declval<Func inspector::*>())...)){};
} else if constexpr((stl::is_function_v<Func> && ...)) {
return decltype(stl::make_tuple(vtable_entry(stl::declval<Func inspector::*>())...)){};
}
}
template<typename Type, auto Candidate, typename Ret, typename Any, typename... Args>
static void fill_vtable_entry(Ret (*&entry)(Any &, Args...)) noexcept {
if constexpr(std::is_invocable_r_v<Ret, decltype(Candidate), Args...>) {
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 stl::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>(stl::invoke(Candidate, any_cast<constness_as_t<Type, Any> &>(instance), stl::forward<Args>(args)...));
};
}
}
template<typename Type, auto... Index>
[[nodiscard]] static auto fill_vtable(std::index_sequence<Index...>) noexcept {
[[nodiscard]] static auto fill_vtable(stl::index_sequence<Index...>) noexcept {
vtable_type impl{};
(fill_vtable_entry<Type, value_list_element_v<Index, typename Concept::template impl<Type>>>(std::get<Index>(impl)), ...);
(fill_vtable_entry<Type, value_list_element_v<Index, typename Concept::template impl<Type>>>(stl::get<Index>(impl)), ...);
return impl;
}
using vtable_type = decltype(make_vtable(Concept{}));
static constexpr bool is_mono = std::tuple_size_v<vtable_type> == 1u;
static constexpr bool is_mono = stl::tuple_size_v<vtable_type> == 1u;
public:
/*! @brief Virtual table type. */
using type = std::conditional_t<is_mono, std::tuple_element_t<0u, vtable_type>, const vtable_type *>;
using type = stl::conditional_t<is_mono, stl::tuple_element_t<0u, vtable_type>, const vtable_type *>;
/**
* @brief Returns a static virtual table for a specific concept and type.
@@ -115,10 +115,10 @@ public:
*/
template<cvref_unqualified Type>
[[nodiscard]] static type instance() noexcept {
static const vtable_type vtable = fill_vtable<Type>(std::make_index_sequence<Concept::template impl<Type>::size>{});
static const vtable_type vtable = fill_vtable<Type>(stl::make_index_sequence<Concept::template impl<Type>::size>{});
if constexpr(is_mono) {
return std::get<0>(vtable);
return stl::get<0>(vtable);
} else {
return &vtable;
}
@@ -139,27 +139,27 @@ struct poly_base {
* @param args The arguments to pass to the function.
* @return The return value of the invoked function, if any.
*/
template<std::size_t Member, typename... Args>
template<stl::size_t Member, typename... Args>
[[nodiscard]] decltype(auto) invoke(const poly_base &self, Args &&...args) const {
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)...);
if constexpr(stl::is_function_v<stl::remove_pointer_t<decltype(poly.vtable)>>) {
return poly.vtable(poly.storage, stl::forward<Args>(args)...);
} else {
return std::get<Member>(*poly.vtable)(poly.storage, std::forward<Args>(args)...);
return stl::get<Member>(*poly.vtable)(poly.storage, stl::forward<Args>(args)...);
}
}
/*! @copydoc invoke */
template<std::size_t Member, typename... Args>
template<stl::size_t Member, typename... Args>
[[nodiscard]] decltype(auto) invoke(poly_base &self, Args &&...args) {
auto &poly = static_cast<Poly &>(self);
if constexpr(std::is_function_v<std::remove_pointer_t<decltype(poly.vtable)>>) {
if constexpr(stl::is_function_v<stl::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 stl::get<Member>(*poly.vtable)(poly.storage, stl::forward<Args>(args)...);
}
}
};
@@ -173,9 +173,9 @@ struct poly_base {
* @param args The arguments to pass to the function.
* @return The return value of the invoked function, if any.
*/
template<std::size_t Member, typename Poly, typename... Args>
template<stl::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)...);
}
/**
@@ -193,7 +193,7 @@ decltype(auto) poly_call(Poly &&self, Args &&...args) {
* @tparam Len Size of the storage reserved for the small buffer optimization.
* @tparam Align Optional alignment requirement.
*/
template<typename Concept, std::size_t Len, std::size_t Align>
template<typename Concept, stl::size_t Len, stl::size_t Align>
class basic_poly: private Concept::template type<poly_base<basic_poly<Concept, Len, Align>>> {
friend struct poly_base<basic_poly>;
@@ -213,9 +213,9 @@ public:
* @param args Parameters to use to construct the instance.
*/
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)...},
vtable{poly_vtable<Concept, Len, Align>::template instance<std::remove_cvref_t<Type>>()} {}
explicit basic_poly(stl::in_place_type_t<Type>, Args &&...args)
: storage{stl::in_place_type<Type>, stl::forward<Args>(args)...},
vtable{poly_vtable<Concept, Len, Align>::template instance<stl::remove_cvref_t<Type>>()} {}
/**
* @brief Constructs a poly from a given value.
@@ -223,9 +223,9 @@ public:
* @param value An instance of an object to use to initialize the poly.
*/
template<typename Type>
requires (!std::same_as<std::remove_cvref_t<Type>, basic_poly>)
requires (!stl::same_as<stl::remove_cvref_t<Type>, basic_poly>)
basic_poly(Type &&value) noexcept
: basic_poly{std::in_place_type<std::remove_cvref_t<Type>>, std::forward<Type>(value)} {}
: basic_poly{stl::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,8 +256,8 @@ public:
*/
template<typename Type, typename... Args>
void emplace(Args &&...args) {
storage.template emplace<Type>(std::forward<Args>(args)...);
vtable = poly_vtable<Concept, Len, Align>::template instance<std::remove_cvref_t<Type>>();
storage.template emplace<Type>(stl::forward<Args>(args)...);
vtable = poly_vtable<Concept, Len, Align>::template instance<stl::remove_cvref_t<Type>>();
}
/*! @brief Destroys contained object */

View File

@@ -1,22 +1,22 @@
#ifndef ENTT_PROCESS_FWD_HPP
#define ENTT_PROCESS_FWD_HPP
#include <cstdint>
#include <memory>
#include "../stl/cstdint.hpp"
#include "../stl/memory.hpp"
namespace entt {
template<typename, typename = std::allocator<void>>
template<typename, typename = stl::allocator<void>>
class basic_process;
/*! @brief Alias declaration for the most common use case. */
using process = basic_process<std::uint32_t>;
using process = basic_process<stl::uint32_t>;
template<typename, typename = std::allocator<void>>
template<typename, typename = stl::allocator<void>>
class basic_scheduler;
/*! @brief Alias declaration for the most common use case. */
using scheduler = basic_scheduler<std::uint32_t>;
using scheduler = basic_scheduler<stl::uint32_t>;
} // namespace entt

View File

@@ -1,12 +1,12 @@
#ifndef ENTT_PROCESS_PROCESS_HPP
#define ENTT_PROCESS_PROCESS_HPP
#include <cstdint>
#include <memory>
#include <type_traits>
#include <utility>
#include "../core/compressed_pair.hpp"
#include "../core/type_traits.hpp"
#include "../stl/cstdint.hpp"
#include "../stl/memory.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "fwd.hpp"
namespace entt {
@@ -69,8 +69,8 @@ struct process_adaptor;
* @tparam Allocator Type of allocator used to manage memory and elements.
*/
template<typename Delta, typename Allocator>
class basic_process: public std::enable_shared_from_this<basic_process<Delta, Allocator>> {
enum class state : std::uint8_t {
class basic_process: public stl::enable_shared_from_this<basic_process<Delta, Allocator>> {
enum class state : stl::uint8_t {
idle = 0,
running,
paused,
@@ -95,7 +95,7 @@ public:
/*! @brief Type used to provide elapsed time. */
using delta_type = Delta;
/*! @brief Handle type. */
using handle_type = std::shared_ptr<basic_process>;
using handle_type = stl::shared_ptr<basic_process>;
/*! @brief Default constructor. */
basic_process()
@@ -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() = stl::allocate_shared<Type>(allocator, allocator, stl::forward<Args>(args)...));
}
/**
@@ -234,7 +234,7 @@ public:
basic_process &then(Func func) {
const auto &allocator = next.second();
using process_type = internal::process_adaptor<delta_type, Func, allocator_type>;
return *(next.first() = std::allocate_shared<process_type>(allocator, allocator, std::move(func)));
return *(next.first() = stl::allocate_shared<process_type>(allocator, allocator, stl::move(func)));
}
/**
@@ -298,7 +298,7 @@ struct process_adaptor: public basic_process<Delta, Allocator> {
process_adaptor(const allocator_type &allocator, Func proc)
: base_type{allocator},
func{std::move(proc)} {}
func{stl::move(proc)} {}
void update(const delta_type delta, void *data) override {
func(*this, delta, data);

View File

@@ -1,13 +1,13 @@
#ifndef ENTT_PROCESS_SCHEDULER_HPP
#define ENTT_PROCESS_SCHEDULER_HPP
#include <cstddef>
#include <memory>
#include <type_traits>
#include <utility>
#include <vector>
#include "../config/config.h"
#include "../core/compressed_pair.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/memory.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "../stl/vector.hpp"
#include "fwd.hpp"
#include "process.hpp"
@@ -35,9 +35,9 @@ namespace entt {
template<typename Delta, typename Allocator>
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 alloc_traits = stl::allocator_traits<Allocator>;
using container_allocator = alloc_traits::template rebind_alloc<stl::shared_ptr<base_type>>;
using container_type = stl::vector<stl::shared_ptr<base_type>, container_allocator>;
public:
/*! @brief Process type. */
@@ -45,7 +45,7 @@ public:
/*! @brief Allocator type. */
using allocator_type = Allocator;
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Unsigned integer type. */
using delta_type = Delta;
@@ -68,7 +68,7 @@ public:
* @param other The instance to move from.
*/
basic_scheduler(basic_scheduler &&other) noexcept
: handlers{std::move(other.handlers)} {}
: handlers{stl::move(other.handlers)} {}
/**
* @brief Allocator-extended move constructor.
@@ -76,7 +76,7 @@ public:
* @param allocator The allocator to use.
*/
basic_scheduler(basic_scheduler &&other, const allocator_type &allocator)
: handlers{container_type{std::move(other.handlers.first()), allocator}, allocator} {
: handlers{container_type{stl::move(other.handlers.first()), allocator}, allocator} {
ENTT_ASSERT(alloc_traits::is_always_equal::value || get_allocator() == other.get_allocator(), "Copying a scheduler is not allowed");
}
@@ -105,7 +105,7 @@ public:
* @param other Scheduler to exchange the content with.
*/
void swap(basic_scheduler &other) noexcept {
using std::swap;
using stl::swap;
swap(handlers, other.handlers);
}
@@ -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(stl::allocate_shared<Type>(allocator, allocator, stl::forward<Args>(args)...));
}
/**
@@ -166,7 +166,7 @@ public:
type &attach(Func func) {
const auto &allocator = handlers.second();
using process_type = internal::process_adaptor<delta_type, Func, allocator_type>;
return *handlers.first().emplace_back(std::allocate_shared<process_type>(allocator, allocator, std::move(func)));
return *handlers.first().emplace_back(stl::allocate_shared<process_type>(allocator, allocator, stl::move(func)));
}
/**
@@ -192,7 +192,7 @@ public:
}
if(!elem || elem->rejected()) {
elem = std::move(handlers.first().back());
elem = stl::move(handlers.first().back());
handlers.first().pop_back();
}
}

View File

@@ -2,19 +2,18 @@
#define ENTT_RESOURCE_RESOURCE_CACHE_HPP
#include <compare>
#include <concepts>
#include <cstddef>
#include <functional>
#include <iterator>
#include <memory>
#include <tuple>
#include <type_traits>
#include <utility>
#include "../container/dense_map.hpp"
#include "../core/compressed_pair.hpp"
#include "../core/fwd.hpp"
#include "../core/iterator.hpp"
#include "../stl/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/functional.hpp"
#include "../stl/iterator.hpp"
#include "../stl/memory.hpp"
#include "../stl/tuple.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "fwd.hpp"
#include "loader.hpp"
#include "resource.hpp"
@@ -30,12 +29,12 @@ class resource_cache_iterator final {
friend class resource_cache_iterator;
public:
using value_type = std::pair<id_type, resource<Type>>;
using value_type = stl::pair<id_type, resource<Type>>;
using pointer = input_iterator_pointer<value_type>;
using reference = value_type;
using difference_type = std::ptrdiff_t;
using iterator_category = std::input_iterator_tag;
using iterator_concept = std::random_access_iterator_tag;
using difference_type = stl::ptrdiff_t;
using iterator_category = stl::input_iterator_tag;
using iterator_concept = stl::random_access_iterator_tag;
constexpr resource_cache_iterator() noexcept = default;
@@ -43,8 +42,8 @@ public:
: it{iter} {}
template<typename Other>
requires (!std::same_as<It, Other> && std::constructible_from<It, Other>)
constexpr resource_cache_iterator(const resource_cache_iterator<std::remove_const_t<Type>, Other> &other) noexcept
requires (!stl::same_as<It, Other> && stl::constructible_from<It, Other>)
constexpr resource_cache_iterator(const resource_cache_iterator<stl::remove_const_t<Type>, Other> &other) noexcept
: it{other.it} {}
constexpr resource_cache_iterator &operator++() noexcept {
@@ -96,7 +95,7 @@ public:
}
template<typename... Args>
[[nodiscard]] constexpr std::ptrdiff_t operator-(const resource_cache_iterator<Args...> &other) const noexcept {
[[nodiscard]] constexpr stl::ptrdiff_t operator-(const resource_cache_iterator<Args...> &other) const noexcept {
return it - other.it;
}
@@ -125,10 +124,10 @@ private:
*/
template<typename Type, typename Loader, typename Allocator>
class resource_cache {
using alloc_traits = std::allocator_traits<Allocator>;
static_assert(std::is_same_v<typename alloc_traits::value_type, Type>, "Invalid value type");
using container_allocator = alloc_traits::template rebind_alloc<std::pair<const id_type, typename Loader::result_type>>;
using container_type = dense_map<id_type, typename Loader::result_type, stl::identity, std::equal_to<>, container_allocator>;
using alloc_traits = stl::allocator_traits<Allocator>;
static_assert(stl::is_same_v<typename alloc_traits::value_type, Type>, "Invalid value type");
using container_allocator = alloc_traits::template rebind_alloc<stl::pair<const id_type, typename Loader::result_type>>;
using container_type = dense_map<id_type, typename Loader::result_type, stl::identity, stl::equal_to<>, container_allocator>;
public:
/*! @brief Allocator type. */
@@ -136,7 +135,7 @@ public:
/*! @brief Resource type. */
using value_type = Type;
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Loader type. */
using loader_type = Loader;
/*! @brief Input iterator type. */
@@ -172,7 +171,7 @@ public:
* @param allocator The allocator to use.
*/
resource_cache(const resource_cache &other, const allocator_type &allocator)
: pool{std::piecewise_construct, std::forward_as_tuple(other.pool.first(), allocator), std::forward_as_tuple(other.pool.second())} {}
: pool{stl::piecewise_construct, stl::forward_as_tuple(other.pool.first(), allocator), stl::forward_as_tuple(other.pool.second())} {}
/*! @brief Default move constructor. */
resource_cache(resource_cache &&) noexcept = default;
@@ -183,7 +182,7 @@ public:
* @param allocator The allocator to use.
*/
resource_cache(resource_cache &&other, const allocator_type &allocator)
: pool{std::piecewise_construct, std::forward_as_tuple(std::move(other.pool.first()), allocator), std::forward_as_tuple(std::move(other.pool.second()))} {}
: pool{stl::piecewise_construct, stl::forward_as_tuple(stl::move(other.pool.first()), allocator), stl::forward_as_tuple(stl::move(other.pool.second()))} {}
/*! @brief Default destructor. */
~resource_cache() = default;
@@ -287,12 +286,12 @@ public:
* insertion took place.
*/
template<typename... Args>
std::pair<iterator, bool> load(const id_type id, Args &&...args) {
stl::pair<iterator, bool> load(const id_type id, Args &&...args) {
if(auto it = pool.first().find(id); it != pool.first().end()) {
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)...));
}
/**
@@ -300,8 +299,8 @@ public:
* @copydetails load
*/
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};
stl::pair<iterator, bool> force_load(const id_type id, Args &&...args) {
return {pool.first().insert_or_assign(id, pool.second()(stl::forward<Args>(args)...)).first, true};
}
/**

View File

@@ -1,14 +1,14 @@
#ifndef ENTT_RESOURCE_FWD_HPP
#define ENTT_RESOURCE_FWD_HPP
#include <memory>
#include "../stl/memory.hpp"
namespace entt {
template<typename>
struct resource_loader;
template<typename Type, typename = resource_loader<Type>, typename = std::allocator<Type>>
template<typename Type, typename = resource_loader<Type>, typename = stl::allocator<Type>>
class resource_cache;
template<typename>

View File

@@ -1,8 +1,8 @@
#ifndef ENTT_RESOURCE_LOADER_HPP
#define ENTT_RESOURCE_LOADER_HPP
#include <memory>
#include <utility>
#include "../stl/memory.hpp"
#include "../stl/utility.hpp"
#include "fwd.hpp"
namespace entt {
@@ -14,7 +14,7 @@ namespace entt {
template<typename Type>
struct resource_loader {
/*! @brief Result type. */
using result_type = std::shared_ptr<Type>;
using result_type = stl::shared_ptr<Type>;
/**
* @brief Constructs a shared pointer to a resource from its arguments.
@@ -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 stl::make_shared<Type>(stl::forward<Args>(args)...);
}
};

View File

@@ -2,9 +2,9 @@
#define ENTT_RESOURCE_RESOURCE_HPP
#include <compare>
#include <concepts>
#include <memory>
#include <utility>
#include "../stl/concepts.hpp"
#include "../stl/memory.hpp"
#include "../stl/utility.hpp"
#include "fwd.hpp"
namespace entt {
@@ -28,7 +28,7 @@ public:
/*! @brief Resource type. */
using element_type = Type;
/*! @brief Handle type. */
using handle_type = std::shared_ptr<element_type>;
using handle_type = stl::shared_ptr<element_type>;
/*! @brief Default constructor. */
resource() noexcept
@@ -39,7 +39,7 @@ public:
* @param res A handle to a resource.
*/
explicit resource(handle_type res) noexcept
: value{std::move(res)} {}
: value{stl::move(res)} {}
/*! @brief Default copy constructor. */
resource(const resource &) noexcept = default;
@@ -55,7 +55,7 @@ public:
*/
template<typename Other>
resource(const resource<Other> &other, element_type &res) noexcept
: value{other.value, std::addressof(res)} {}
: value{other.value, stl::addressof(res)} {}
/**
* @brief Copy constructs a handle which shares ownership of the resource.
@@ -63,7 +63,7 @@ public:
* @param other The handle to copy from.
*/
template<typename Other>
requires (!std::same_as<Type, Other> && std::constructible_from<Type &, Other &>)
requires (!stl::same_as<Type, Other> && stl::constructible_from<Type &, Other &>)
resource(const resource<Other> &other) noexcept
: value{other.value} {}
@@ -73,9 +73,9 @@ public:
* @param other The handle to move from.
*/
template<typename Other>
requires (!std::same_as<Type, Other> && std::constructible_from<Type &, Other &>)
requires (!stl::same_as<Type, Other> && stl::constructible_from<Type &, Other &>)
resource(resource<Other> &&other) noexcept
: value{std::move(other.value)} {}
: value{stl::move(other.value)} {}
/*! @brief Default destructor. */
~resource() = default;
@@ -99,7 +99,7 @@ public:
* @return This resource handle.
*/
template<typename Other>
requires (!std::same_as<Type, Other> && std::constructible_from<Type &, Other &>)
requires (!stl::same_as<Type, Other> && stl::constructible_from<Type &, Other &>)
resource &operator=(const resource<Other> &other) noexcept {
value = other.value;
return *this;
@@ -112,9 +112,9 @@ public:
* @return This resource handle.
*/
template<typename Other>
requires (!std::same_as<Type, Other> && std::constructible_from<Type &, Other &>)
requires (!stl::same_as<Type, Other> && stl::constructible_from<Type &, Other &>)
resource &operator=(resource<Other> &&other) noexcept {
value = std::move(other.value);
value = stl::move(other.value);
return *this;
}
@@ -123,7 +123,7 @@ public:
* @param other Resource to exchange the content with.
*/
void swap(resource &other) noexcept {
using std::swap;
using stl::swap;
swap(value, other.value);
}
@@ -168,7 +168,7 @@ public:
*/
template<typename Other>
[[nodiscard]] bool operator==(const resource<Other> &other) const noexcept {
return (std::addressof(*value) == std::addressof(*other.value));
return (stl::addressof(*value) == stl::addressof(*other.value));
}
/**
@@ -179,7 +179,7 @@ public:
*/
template<typename Other>
[[nodiscard]] auto operator<=>(const resource<Other> &other) const noexcept {
return (std::addressof(*value) <=> std::addressof(*other.value));
return (stl::addressof(*value) <=> stl::addressof(*other.value));
}
/*! @brief Releases the ownership of the managed resource. */
@@ -192,7 +192,7 @@ public:
* @param other A handle to a resource.
*/
void reset(handle_type other) {
value = std::move(other);
value = stl::move(other);
}
/**

View File

@@ -1,13 +1,13 @@
#ifndef ENTT_SIGNAL_DELEGATE_HPP
#define ENTT_SIGNAL_DELEGATE_HPP
#include <cstddef>
#include <functional>
#include <tuple>
#include <type_traits>
#include <utility>
#include "../config/config.h"
#include "../core/type_traits.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/functional.hpp"
#include "../stl/tuple.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "fwd.hpp"
namespace entt {
@@ -28,15 +28,15 @@ template<typename Class, typename Ret, typename... Args, typename... Other>
auto function_pointer(Ret (Class::*)(Args...) const, Other &&...) -> Ret (*)(Args...);
template<typename Class, typename Type, typename... Other>
requires std::is_member_object_pointer_v<Type Class::*>
requires stl::is_member_object_pointer_v<Type Class::*>
auto function_pointer(Type Class::*, Other &&...) -> Type (*)();
template<typename... Type>
using function_pointer_t = decltype(function_pointer(std::declval<Type>()...));
using function_pointer_t = decltype(function_pointer(stl::declval<Type>()...));
template<typename... Class, typename Ret, typename... Args>
[[nodiscard]] ENTT_CONSTEVAL auto index_sequence_for(Ret (*)(Args...)) {
return std::index_sequence_for<Class..., Args...>{};
return stl::index_sequence_for<Class..., Args...>{};
}
} // namespace internal
@@ -65,35 +65,35 @@ class delegate;
*/
template<typename Ret, typename... Args>
class delegate<Ret(Args...)> {
using return_type = std::remove_const_t<Ret>;
using return_type = stl::remove_const_t<Ret>;
using delegate_type = return_type(const void *, Args...);
template<auto Candidate, std::size_t... Index>
[[nodiscard]] auto wrap(std::index_sequence<Index...>) noexcept {
template<auto Candidate, stl::size_t... Index>
[[nodiscard]] auto wrap(stl::index_sequence<Index...>) noexcept {
return [](const void *, Args... args) -> return_type {
[[maybe_unused]] const auto arguments = std::forward_as_tuple(std::forward<Args>(args)...);
[[maybe_unused]] constexpr auto offset = !std::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))...));
[[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>(stl::invoke(Candidate, stl::forward<type_list_element_t<Index + offset, type_list<Args...>>>(stl::get<Index + offset>(arguments))...));
};
}
template<auto Candidate, typename Type, std::size_t... Index>
[[nodiscard]] auto wrap(Type &, std::index_sequence<Index...>) noexcept {
template<auto Candidate, typename Type, stl::size_t... Index>
[[nodiscard]] auto wrap(Type &, stl::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 = std::forward_as_tuple(std::forward<Args>(args)...);
[[maybe_unused]] constexpr auto offset = !std::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))...));
[[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>(stl::invoke(Candidate, *curr, stl::forward<type_list_element_t<Index + offset, type_list<Args...>>>(stl::get<Index + offset>(arguments))...));
};
}
template<auto Candidate, typename Type, std::size_t... Index>
[[nodiscard]] auto wrap(Type *, std::index_sequence<Index...>) noexcept {
template<auto Candidate, typename Type, stl::size_t... Index>
[[nodiscard]] auto wrap(Type *, stl::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 = std::forward_as_tuple(std::forward<Args>(args)...);
[[maybe_unused]] constexpr auto offset = !std::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))...));
[[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>(stl::invoke(Candidate, curr, stl::forward<type_list_element_t<Index + offset, type_list<Args...>>>(stl::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)...);
}
/**
@@ -137,11 +137,11 @@ public:
void connect() noexcept {
instance = nullptr;
if constexpr(std::is_invocable_r_v<Ret, decltype(Candidate), Args...>) {
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(stl::invoke(Candidate, stl::forward<Args>(args)...));
};
} else if constexpr(std::is_member_pointer_v<decltype(Candidate)>) {
} else if constexpr(stl::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)>{}));
} else {
fn = wrap<Candidate>(internal::index_sequence_for(internal::function_pointer_t<decltype(Candidate)>{}));
@@ -167,10 +167,10 @@ public:
void connect(Type &value_or_instance) noexcept {
instance = &value_or_instance;
if constexpr(std::is_invocable_r_v<Ret, decltype(Candidate), Type &, Args...>) {
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(stl::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>{}));
@@ -191,10 +191,10 @@ public:
void connect(Type *value_or_instance) noexcept {
instance = value_or_instance;
if constexpr(std::is_invocable_r_v<Ret, decltype(Candidate), Type *, Args...>) {
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(stl::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)...);
}
/**
@@ -291,7 +291,7 @@ private:
* @tparam Candidate Function or member to connect to the delegate.
*/
template<auto Candidate>
delegate(connect_arg_t<Candidate>) -> delegate<std::remove_pointer_t<internal::function_pointer_t<decltype(Candidate)>>>;
delegate(connect_arg_t<Candidate>) -> delegate<stl::remove_pointer_t<internal::function_pointer_t<decltype(Candidate)>>>;
/**
* @brief Deduction guide.
@@ -299,7 +299,7 @@ delegate(connect_arg_t<Candidate>) -> delegate<std::remove_pointer_t<internal::f
* @tparam Type Type of class or type of payload.
*/
template<auto Candidate, typename Type>
delegate(connect_arg_t<Candidate>, Type &&) -> delegate<std::remove_pointer_t<internal::function_pointer_t<decltype(Candidate), Type>>>;
delegate(connect_arg_t<Candidate>, Type &&) -> delegate<stl::remove_pointer_t<internal::function_pointer_t<decltype(Candidate), Type>>>;
/**
* @brief Deduction guide.

View File

@@ -1,18 +1,17 @@
#ifndef ENTT_SIGNAL_DISPATCHER_HPP
#define ENTT_SIGNAL_DISPATCHER_HPP
#include <cstddef>
#include <functional>
#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/cstddef.hpp"
#include "../stl/functional.hpp"
#include "../stl/memory.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "../stl/vector.hpp"
#include "fwd.hpp"
#include "sigh.hpp"
@@ -26,14 +25,14 @@ struct basic_dispatcher_handler {
virtual void publish() = 0;
virtual void disconnect(void *) = 0;
virtual void clear() noexcept = 0;
[[nodiscard]] virtual std::size_t size() const noexcept = 0;
[[nodiscard]] virtual stl::size_t size() const noexcept = 0;
};
template<cvref_unqualified Type, typename Allocator>
class dispatcher_handler final: public basic_dispatcher_handler {
using alloc_traits = std::allocator_traits<Allocator>;
using alloc_traits = stl::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;
@@ -69,14 +68,14 @@ 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)...});
if constexpr(stl::is_aggregate_v<Type> && (sizeof...(Args) != 0u || !stl::is_default_constructible_v<Type>)) {
events.push_back(Type{stl::forward<Args>(args)...});
} else {
events.emplace_back(std::forward<Args>(args)...);
events.emplace_back(stl::forward<Args>(args)...);
}
}
[[nodiscard]] std::size_t size() const noexcept override {
[[nodiscard]] stl::size_t size() const noexcept override {
return events.size();
}
@@ -108,12 +107,12 @@ class basic_dispatcher {
using handler_type = internal::dispatcher_handler<Type, Allocator>;
using key_type = id_type;
// std::shared_ptr because of its type erased allocator which is useful here
using mapped_type = std::shared_ptr<internal::basic_dispatcher_handler>;
// stl::shared_ptr because of its type erased allocator which is useful here
using mapped_type = stl::shared_ptr<internal::basic_dispatcher_handler>;
using alloc_traits = std::allocator_traits<Allocator>;
using container_allocator = alloc_traits::template rebind_alloc<std::pair<const key_type, mapped_type>>;
using container_type = dense_map<key_type, mapped_type, stl::identity, std::equal_to<>, container_allocator>;
using alloc_traits = stl::allocator_traits<Allocator>;
using container_allocator = alloc_traits::template rebind_alloc<stl::pair<const key_type, mapped_type>>;
using container_type = dense_map<key_type, mapped_type, stl::identity, stl::equal_to<>, container_allocator>;
template<cvref_unqualified Type>
[[nodiscard]] handler_type<Type> &assure(const id_type id) {
@@ -121,7 +120,7 @@ class basic_dispatcher {
if(!ptr) {
const auto &allocator = get_allocator();
ptr = std::allocate_shared<handler_type<Type>>(allocator, allocator);
ptr = stl::allocate_shared<handler_type<Type>>(allocator, allocator);
}
return static_cast<handler_type<Type> &>(*ptr);
@@ -140,7 +139,7 @@ public:
/*! @brief Allocator type. */
using allocator_type = Allocator;
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Default constructor. */
basic_dispatcher()
@@ -161,7 +160,7 @@ public:
* @param other The instance to move from.
*/
basic_dispatcher(basic_dispatcher &&other) noexcept
: pools{std::move(other.pools)} {}
: pools{stl::move(other.pools)} {}
/**
* @brief Allocator-extended move constructor.
@@ -169,7 +168,7 @@ public:
* @param allocator The allocator to use.
*/
basic_dispatcher(basic_dispatcher &&other, const allocator_type &allocator)
: pools{container_type{std::move(other.pools.first()), allocator}, allocator} {
: pools{container_type{stl::move(other.pools.first()), allocator}, allocator} {
ENTT_ASSERT(alloc_traits::is_always_equal::value || get_allocator() == other.get_allocator(), "Copying a dispatcher is not allowed");
}
@@ -198,7 +197,7 @@ public:
* @param other Dispatcher to exchange the content with.
*/
void swap(basic_dispatcher &other) noexcept {
using std::swap;
using stl::swap;
swap(pools, other.pools);
}
@@ -218,7 +217,7 @@ public:
*/
template<typename Type>
[[nodiscard]] size_type size(const id_type id = type_hash<Type>::value()) const noexcept {
const auto *cpool = assure<std::decay_t<Type>>(id);
const auto *cpool = assure<stl::decay_t<Type>>(id);
return cpool ? cpool->size() : 0u;
}
@@ -267,7 +266,7 @@ public:
*/
template<typename Type>
void trigger(Type value) {
trigger(type_hash<std::decay_t<Type>>::value(), value);
trigger(type_hash<stl::decay_t<Type>>::value(), value);
}
/**
@@ -278,7 +277,7 @@ public:
*/
template<typename Type>
void trigger(const id_type id, Type value) {
assure<std::decay_t<Type>>(id).trigger(value);
assure<stl::decay_t<Type>>(id).trigger(value);
}
/**
@@ -289,7 +288,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 +298,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<stl::decay_t<Type>>::value(), stl::forward<Type>(value));
}
/**
@@ -311,7 +310,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 +321,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<stl::decay_t<Type>>(id).enqueue(stl::forward<Type>(value));
}
/**

View File

@@ -1,14 +1,13 @@
#ifndef ENTT_SIGNAL_EMITTER_HPP
#define ENTT_SIGNAL_EMITTER_HPP
#include <functional>
#include <type_traits>
#include <utility>
#include "../container/dense_map.hpp"
#include "../core/compressed_pair.hpp"
#include "../core/fwd.hpp"
#include "../core/type_info.hpp"
#include "../stl/functional.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "fwd.hpp"
namespace entt {
@@ -35,17 +34,17 @@ namespace entt {
template<typename Derived, typename Allocator>
class emitter {
using key_type = id_type;
using mapped_type = std::function<void(void *)>;
using mapped_type = stl::function<void(void *)>;
using alloc_traits = std::allocator_traits<Allocator>;
using container_allocator = alloc_traits::template rebind_alloc<std::pair<const key_type, mapped_type>>;
using container_type = dense_map<key_type, mapped_type, stl::identity, std::equal_to<>, container_allocator>;
using alloc_traits = stl::allocator_traits<Allocator>;
using container_allocator = alloc_traits::template rebind_alloc<stl::pair<const key_type, mapped_type>>;
using container_type = dense_map<key_type, mapped_type, stl::identity, stl::equal_to<>, container_allocator>;
public:
/*! @brief Allocator type. */
using allocator_type = Allocator;
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Default constructor. */
emitter()
@@ -66,7 +65,7 @@ public:
* @param other The instance to move from.
*/
emitter(emitter &&other) noexcept
: handlers{std::move(other.handlers)} {}
: handlers{stl::move(other.handlers)} {}
/**
* @brief Allocator-extended move constructor.
@@ -74,13 +73,13 @@ public:
* @param allocator The allocator to use.
*/
emitter(emitter &&other, const allocator_type &allocator)
: handlers{container_type{std::move(other.handlers.first()), allocator}, allocator} {
: handlers{container_type{stl::move(other.handlers.first()), allocator}, allocator} {
ENTT_ASSERT(alloc_traits::is_always_equal::value || handlers.second() == other.handlers.second(), "Copying an emitter is not allowed");
}
/*! @brief Default destructor. */
virtual ~emitter() {
static_assert(std::is_base_of_v<emitter<Derived, Allocator>, Derived>, "Invalid emitter type");
static_assert(stl::is_base_of_v<emitter<Derived, Allocator>, Derived>, "Invalid emitter type");
}
/**
@@ -105,7 +104,7 @@ public:
* @param other Emitter to exchange the content with.
*/
void swap(emitter &other) noexcept {
using std::swap;
using stl::swap;
swap(handlers, other.handlers);
}
@@ -135,8 +134,8 @@ public:
* @param func The listener to register.
*/
template<typename Type>
void on(std::function<void(Type &, Derived &)> func) {
handlers.first().insert_or_assign(type_id<Type>().hash(), [func = std::move(func), this](void *value) {
void on(stl::function<void(Type &, Derived &)> func) {
handlers.first().insert_or_assign(type_id<Type>().hash(), [func = stl::move(func), this](void *value) {
func(*static_cast<Type *>(value), static_cast<Derived &>(*this));
});
}
@@ -147,7 +146,7 @@ public:
*/
template<typename Type>
void erase() {
handlers.first().erase(type_hash<std::remove_cvref_t<Type>>::value());
handlers.first().erase(type_hash<stl::remove_cvref_t<Type>>::value());
}
/*! @brief Disconnects all the listeners. */
@@ -162,7 +161,7 @@ public:
*/
template<typename Type>
[[nodiscard]] bool contains() const {
return handlers.first().contains(type_hash<std::remove_cvref_t<Type>>::value());
return handlers.first().contains(type_hash<stl::remove_cvref_t<Type>>::value());
}
/**

View File

@@ -1,17 +1,17 @@
#ifndef ENTT_SIGNAL_FWD_HPP
#define ENTT_SIGNAL_FWD_HPP
#include <memory>
#include "../stl/memory.hpp"
namespace entt {
template<typename>
class delegate;
template<typename = std::allocator<void>>
template<typename = stl::allocator<void>>
class basic_dispatcher;
template<typename, typename = std::allocator<void>>
template<typename, typename = stl::allocator<void>>
class emitter;
class connection;
@@ -21,7 +21,7 @@ struct scoped_connection;
template<typename>
class sink;
template<typename Type, typename = std::allocator<void>>
template<typename Type, typename = stl::allocator<void>>
class sigh;
/*! @brief Alias declaration for the most common use case. */

View File

@@ -1,11 +1,11 @@
#ifndef ENTT_SIGNAL_SIGH_HPP
#define ENTT_SIGNAL_SIGH_HPP
#include <cstddef>
#include <memory>
#include <type_traits>
#include <utility>
#include <vector>
#include "../stl/cstddef.hpp"
#include "../stl/memory.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "../stl/vector.hpp"
#include "delegate.hpp"
#include "fwd.hpp"
@@ -54,15 +54,15 @@ template<typename Ret, typename... Args, typename Allocator>
class sigh<Ret(Args...), Allocator> {
friend class sink<sigh<Ret(Args...), Allocator>>;
using alloc_traits = std::allocator_traits<Allocator>;
using alloc_traits = stl::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. */
using allocator_type = Allocator;
/*! @brief Unsigned integer type. */
using size_type = std::size_t;
using size_type = stl::size_t;
/*! @brief Sink type. */
using sink_type = sink<sigh<Ret(Args...), Allocator>>;
@@ -97,7 +97,7 @@ public:
* @param other The instance to move from.
*/
sigh(sigh &&other) noexcept
: calls{std::move(other.calls)} {}
: calls{stl::move(other.calls)} {}
/**
* @brief Allocator-extended move constructor.
@@ -105,7 +105,7 @@ public:
* @param allocator The allocator to use.
*/
sigh(sigh &&other, const allocator_type &allocator)
: calls{std::move(other.calls), allocator} {}
: calls{stl::move(other.calls), allocator} {}
/*! @brief Default destructor. */
~sigh() = default;
@@ -135,7 +135,7 @@ public:
* @param other Signal handler to exchange the content with.
*/
void swap(sigh &other) noexcept {
using std::swap;
using stl::swap;
swap(calls, other.calls);
}
@@ -193,17 +193,17 @@ public:
template<typename Func>
void collect(Func func, Args... args) const {
for(auto pos = calls.size(); pos; --pos) {
if constexpr(std::is_void_v<Ret> || !std::is_invocable_v<Func, Ret>) {
if constexpr(stl::is_void_v<Ret> || !stl::is_invocable_v<Func, Ret>) {
calls[pos - 1u](args...);
if constexpr(std::is_invocable_r_v<bool, Func>) {
if constexpr(stl::is_invocable_r_v<bool, Func>) {
if(func()) {
break;
}
} else {
func();
}
} else if constexpr(std::is_invocable_r_v<bool, Func, Ret>) {
} else if constexpr(stl::is_invocable_r_v<bool, Func, Ret>) {
if(func(calls[pos - 1u](args...))) {
break;
}
@@ -285,7 +285,7 @@ struct scoped_connection {
* @param other The scoped connection to move from.
*/
scoped_connection(scoped_connection &&other) noexcept
: conn{std::exchange(other.conn, {})} {}
: conn{stl::exchange(other.conn, {})} {}
/*! @brief Automatically breaks the link on destruction. */
~scoped_connection() {
@@ -304,7 +304,7 @@ struct scoped_connection {
* @return This scoped connection.
*/
scoped_connection &operator=(scoped_connection &&other) noexcept {
conn = std::exchange(other.conn, {});
conn = stl::exchange(other.conn, {});
return *this;
}
@@ -376,7 +376,7 @@ class sink<sigh<Ret(Args...), Allocator>> {
for(auto pos = ref.calls.size(); pos; --pos) {
if(auto &elem = ref.calls[pos - 1u]; callback(elem)) {
elem = std::move(ref.calls.back());
elem = stl::move(ref.calls.back());
ref.calls.pop_back();
}
}
@@ -418,7 +418,7 @@ public:
delegate_type call{};
call.template connect<Candidate>();
signal_or_assert().calls.push_back(std::move(call));
signal_or_assert().calls.push_back(stl::move(call));
delegate<void(void *)> conn{};
conn.template connect<&release<Candidate>>();
@@ -447,7 +447,7 @@ public:
delegate_type call{};
call.template connect<Candidate>(value_or_instance);
signal_or_assert().calls.push_back(std::move(call));
signal_or_assert().calls.push_back(stl::move(call));
delegate<void(void *)> conn{};
conn.template connect<&release<Candidate, Type &>>(value_or_instance);
@@ -471,7 +471,7 @@ public:
delegate_type call{};
call.template connect<Candidate>(value_or_instance);
signal_or_assert().calls.push_back(std::move(call));
signal_or_assert().calls.push_back(stl::move(call));
delegate<void(void *)> conn{};
conn.template connect<&release<Candidate, Type *>>(value_or_instance);

View File

@@ -0,0 +1,18 @@
#ifndef ENTT_STL_ALGORITHM_HPP
#define ENTT_STL_ALGORITHM_HPP
#include <algorithm>
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::all_of;
using std::any_of;
using std::find_if;
using std::none_of;
using std::sort;
} // namespace entt::stl
/*! @endcond */
#endif

15
src/entt/stl/array.hpp Normal file
View File

@@ -0,0 +1,15 @@
#ifndef ENTT_STL_ARRAY_HPP
#define ENTT_STL_ARRAY_HPP
#include <array>
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::array;
using std::get;
} // namespace entt::stl
/*! @endcond */
#endif

14
src/entt/stl/atomic.hpp Normal file
View File

@@ -0,0 +1,14 @@
#ifndef ENTT_STL_ATOMIC_HPP
#define ENTT_STL_ATOMIC_HPP
#include <atomic>
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::atomic;
} // namespace entt::stl
/*! @endcond */
#endif

16
src/entt/stl/bit.hpp Normal file
View File

@@ -0,0 +1,16 @@
#ifndef ENTT_STL_BIT_HPP
#define ENTT_STL_BIT_HPP
#include <bit>
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::bit_ceil;
using std::has_single_bit;
using std::popcount;
} // namespace entt::stl
/*! @endcond */
#endif

14
src/entt/stl/cmath.hpp Normal file
View File

@@ -0,0 +1,14 @@
#ifndef ENTT_STL_CMATH_HPP
#define ENTT_STL_CMATH_HPP
#include <cmath>
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::ceil;
} // namespace entt::stl
/*! @endcond */
#endif

20
src/entt/stl/concepts.hpp Normal file
View File

@@ -0,0 +1,20 @@
#ifndef ENTT_STL_CONCEPTS_HPP
#define ENTT_STL_CONCEPTS_HPP
#include <concepts>
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::constructible_from;
using std::default_initializable;
using std::derived_from;
using std::integral;
using std::invocable;
using std::same_as;
using std::unsigned_integral;
} // namespace entt::stl
/*! @endcond */
#endif

17
src/entt/stl/cstddef.hpp Normal file
View File

@@ -0,0 +1,17 @@
#ifndef ENTT_STL_CSTDDEF_HPP
#define ENTT_STL_CSTDDEF_HPP
#include <cstddef>
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::byte;
using std::nullptr_t;
using std::ptrdiff_t;
using std::size_t;
} // namespace entt::stl
/*! @endcond */
#endif

17
src/entt/stl/cstdint.hpp Normal file
View File

@@ -0,0 +1,17 @@
#ifndef ENTT_STL_CSTDINT_HPP
#define ENTT_STL_CSTDINT_HPP
#include <cstdint>
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::uint16_t;
using std::uint32_t;
using std::uint64_t;
using std::uint8_t;
} // namespace entt::stl
/*! @endcond */
#endif

View File

@@ -1,16 +1,24 @@
#ifndef ENTT_STL_FUNCTIONAL_HPP
#define ENTT_STL_FUNCTIONAL_HPP
#include <functional>
#include <version>
#include "../config/config.h"
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::equal_to;
using std::function;
using std::hash;
using std::invoke;
using std::less;
} // namespace entt::stl
#ifndef ENTT_FORCE_STL
# if __has_include(<version>)
# include <version>
#
# if defined(__cpp_lib_ranges)
# define ENTT_HAS_IDENTITY
# include <functional>
# if defined(__cpp_lib_ranges)
# define ENTT_HAS_IDENTITY
namespace entt::stl {
@@ -18,7 +26,6 @@ using std::identity;
} // namespace entt::stl
# endif
# endif
#endif
@@ -41,4 +48,6 @@ struct identity {
#endif
/*! @endcond */
#undef ENTT_HAS_IDENTITY
#endif

14
src/entt/stl/ios.hpp Normal file
View File

@@ -0,0 +1,14 @@
#ifndef ENTT_STL_IOS_HPP
#define ENTT_STL_IOS_HPP
#include <ios>
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::boolalpha;
} // namespace entt::stl
/*! @endcond */
#endif

View File

@@ -1,19 +1,27 @@
#ifndef ENTT_STL_ITERATOR_HPP
#define ENTT_STL_ITERATOR_HPP
#include <iterator>
#include <version>
#include "../config/config.h"
/*! @cond ENTT_INTERNAL */
#ifndef ENTT_FORCE_STL
# if __has_include(<version>)
# include <version>
#
# if defined(__cpp_lib_ranges)
# define ENTT_HAS_ITERATOR_CONCEPTS
# include <iterator>
namespace entt::stl {
using std::advance;
using std::bidirectional_iterator_tag;
using std::distance;
using std::forward_iterator_tag;
using std::input_iterator_tag;
using std::iterator_traits;
using std::make_reverse_iterator;
using std::random_access_iterator_tag;
using std::reverse_iterator;
#ifndef ENTT_FORCE_STL
# if defined(__cpp_lib_ranges)
# define ENTT_HAS_ITERATOR_CONCEPTS
using std::bidirectional_iterator;
using std::forward_iterator;
using std::input_iterator;
@@ -22,19 +30,13 @@ using std::output_iterator;
using std::random_access_iterator;
using std::sentinel_for;
} // namespace entt::stl
# endif
# endif
#endif
#ifndef ENTT_HAS_ITERATOR_CONCEPTS
# include <concepts>
# include <iterator>
# include <utility>
namespace entt::stl {
namespace internal {
template<typename It>
@@ -94,9 +96,11 @@ concept sentinel_for = input_or_output_iterator<It> && requires(Sentinel sentine
{ it == sentinel } -> std::same_as<bool>;
};
} // namespace entt::stl
#endif
} // namespace entt::stl
/*! @endcond */
#undef ENTT_HAS_ITERATOR_CONCEPTS
#endif

14
src/entt/stl/limits.hpp Normal file
View File

@@ -0,0 +1,14 @@
#ifndef ENTT_STL_LIMITS_HPP
#define ENTT_STL_LIMITS_HPP
#include <limits>
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::numeric_limits;
} // namespace entt::stl
/*! @endcond */
#endif

View File

@@ -1,16 +1,36 @@
#ifndef ENTT_STL_MEMORY_HPP
#define ENTT_STL_MEMORY_HPP
#include <memory>
#include <version>
#include "../config/config.h"
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::addressof;
using std::allocate_shared;
using std::allocator;
using std::allocator_arg;
using std::allocator_arg_t;
using std::allocator_traits;
using std::default_delete;
using std::destroy;
using std::enable_shared_from_this;
using std::make_shared;
using std::make_unique;
using std::pointer_traits;
using std::shared_ptr;
using std::static_pointer_cast;
using std::uninitialized_fill;
using std::unique_ptr;
using std::uses_allocator_v;
} // namespace entt::stl
#ifndef ENTT_FORCE_STL
# if __has_include(<version>)
# include <version>
#
# if defined(__cpp_lib_to_address)
# define ENTT_HAS_TO_ADDRESS
# include <memory>
# if defined(__cpp_lib_to_address)
# define ENTT_HAS_TO_ADDRESS
namespace entt::stl {
@@ -18,12 +38,10 @@ using std::to_address;
} // namespace entt::stl
# endif
# endif
#endif
#ifndef ENTT_HAS_TO_ADDRESS
# include <memory>
# include <type_traits>
namespace entt::stl {
@@ -39,7 +57,7 @@ constexpr auto to_address(const Type &ptr) noexcept {
if constexpr(requires { std::pointer_traits<Type>::to_address(ptr); }) {
return std::pointer_traits<Type>::to_address(ptr);
} else {
return to_address(ptr.operator->());
return std::to_address(ptr.operator->());
}
}
@@ -48,4 +66,6 @@ constexpr auto to_address(const Type &ptr) noexcept {
#endif
/*! @endcond */
#undef ENTT_HAS_TO_ADDRESS
#endif

14
src/entt/stl/ostream.hpp Normal file
View File

@@ -0,0 +1,14 @@
#ifndef ENTT_STL_OSTREAM_HPP
#define ENTT_STL_OSTREAM_HPP
#include <ostream>
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::ostream;
} // namespace entt::stl
/*! @endcond */
#endif

14
src/entt/stl/sstream.hpp Normal file
View File

@@ -0,0 +1,14 @@
#ifndef ENTT_STL_SSTREAM_HPP
#define ENTT_STL_SSTREAM_HPP
#include <sstream>
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::stringstream;
} // namespace entt::stl
/*! @endcond */
#endif

14
src/entt/stl/string.hpp Normal file
View File

@@ -0,0 +1,14 @@
#ifndef ENTT_STL_STRING_HPP
#define ENTT_STL_STRING_HPP
#include <string>
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::string;
} // namespace entt::stl
/*! @endcond */
#endif

View File

@@ -0,0 +1,15 @@
#ifndef ENTT_STL_STRING_VIEW_HPP
#define ENTT_STL_STRING_VIEW_HPP
#include <string_view>
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::string_view;
using std::swap;
} // namespace entt::stl
/*! @endcond */
#endif

24
src/entt/stl/tuple.hpp Normal file
View File

@@ -0,0 +1,24 @@
#ifndef ENTT_STL_TUPLE_HPP
#define ENTT_STL_TUPLE_HPP
#include <tuple>
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::apply;
using std::forward_as_tuple;
using std::get;
using std::make_from_tuple;
using std::make_tuple;
using std::tuple;
using std::tuple_cat;
using std::tuple_element;
using std::tuple_element_t;
using std::tuple_size;
using std::tuple_size_v;
} // namespace entt::stl
/*! @endcond */
#endif

View File

@@ -0,0 +1,65 @@
#ifndef ENTT_STL_TYPE_TRAITS_HPP
#define ENTT_STL_TYPE_TRAITS_HPP
#include <type_traits>
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::bool_constant;
using std::common_type_t;
using std::conditional_t;
using std::decay_t;
using std::extent_v;
using std::false_type;
using std::integral_constant;
using std::invoke_result_t;
using std::is_aggregate_v;
using std::is_arithmetic_v;
using std::is_array_v;
using std::is_base_of_v;
using std::is_class_v;
using std::is_const_v;
using std::is_constructible_v;
using std::is_convertible_v;
using std::is_copy_assignable_v;
using std::is_copy_constructible_v;
using std::is_default_constructible_v;
using std::is_empty_v;
using std::is_enum_v;
using std::is_final_v;
using std::is_function_v;
using std::is_integral_v;
using std::is_invocable;
using std::is_invocable_r;
using std::is_invocable_r_v;
using std::is_invocable_v;
using std::is_lvalue_reference_v;
using std::is_member_function_pointer_v;
using std::is_member_object_pointer_v;
using std::is_member_pointer_v;
using std::is_move_assignable_v;
using std::is_move_constructible_v;
using std::is_nothrow_constructible_v;
using std::is_nothrow_copy_constructible_v;
using std::is_nothrow_default_constructible_v;
using std::is_nothrow_destructible_v;
using std::is_nothrow_invocable_v;
using std::is_nothrow_move_constructible_v;
using std::is_pointer_v;
using std::is_reference_v;
using std::is_same_v;
using std::is_signed_v;
using std::is_trivially_destructible_v;
using std::is_void_v;
using std::remove_const_t;
using std::remove_cvref_t;
using std::remove_pointer_t;
using std::remove_reference_t;
using std::true_type;
using std::underlying_type_t;
} // namespace entt::stl
/*! @endcond */
#endif

30
src/entt/stl/utility.hpp Normal file
View File

@@ -0,0 +1,30 @@
#ifndef ENTT_STL_UTILITY_HPP
#define ENTT_STL_UTILITY_HPP
#include <utility>
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::as_const;
using std::declval;
using std::exchange;
using std::forward;
using std::in_place;
using std::in_place_t;
using std::in_place_type;
using std::in_place_type_t;
using std::index_sequence;
using std::index_sequence_for;
using std::make_index_sequence;
using std::make_pair;
using std::move;
using std::pair;
using std::piecewise_construct;
using std::piecewise_construct_t;
using std::swap;
} // namespace entt::stl
/*! @endcond */
#endif

14
src/entt/stl/vector.hpp Normal file
View File

@@ -0,0 +1,14 @@
#ifndef ENTT_STL_VECTOR_HPP
#define ENTT_STL_VECTOR_HPP
#include <vector>
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::vector;
} // namespace entt::stl
/*! @endcond */
#endif

View File

@@ -1,10 +1,6 @@
#ifndef ENTT_TOOLS_DAVEY_HPP
#define ENTT_TOOLS_DAVEY_HPP
#include <cstdint>
#include <ios>
#include <sstream>
#include <string>
#include "../config/config.h"
#include "../entity/mixin.hpp"
#include "../entity/registry.hpp"
@@ -16,6 +12,10 @@
#include "../meta/meta.hpp"
#include "../meta/pointer.hpp"
#include "../meta/resolve.hpp"
#include "../stl/cstdint.hpp"
#include "../stl/ios.hpp"
#include "../stl/sstream.hpp"
#include "../stl/string.hpp"
#if __has_include(<imgui.h>)
# include <imgui.h>
@@ -30,13 +30,13 @@ template<typename Entity, typename OnEntity>
static void present_element(const meta_any &obj, OnEntity on_entity) {
for([[maybe_unused]] const auto [id, data]: obj.type().data()) {
const auto elem = data.get(obj);
const std::string name = data.name().empty() ? std::string{data.type().info().name()} : std::string{data.name()};
const stl::string name = data.name().empty() ? stl::string{data.type().info().name()} : stl::string{data.name()};
const char *const label = name.c_str();
if(auto type = data.type(); type.info() == type_id<const char *>()) {
ImGui::Text("%s: %s", label, elem.template cast<const char *>());
} else if(type.info() == type_id<std::string>()) {
ImGui::Text("%s: %s", label, elem.template cast<const std::string &>().data());
} else if(type.info() == type_id<stl::string>()) {
ImGui::Text("%s: %s", label, elem.template cast<const stl::string &>().data());
} else if(type.info() == type_id<Entity>()) {
if(const auto entt = elem.template cast<Entity>(); entt == null) {
ImGui::Text("%s: %s", label, "null");
@@ -56,17 +56,17 @@ static void present_element(const meta_any &obj, OnEntity on_entity) {
if(as_string) {
ImGui::Text("%s: %s", label, as_string);
} else {
ImGui::Text("%s: %zu", label, elem.template allow_cast<std::uint64_t>().template cast<std::uint64_t>());
ImGui::Text("%s: %zu", label, elem.template allow_cast<stl::uint64_t>().template cast<stl::uint64_t>());
}
} else if(type.is_arithmetic()) {
if(type.info() == type_id<bool>()) {
std::stringstream buffer{};
buffer << std::boolalpha << elem.template cast<bool>();
stl::stringstream buffer{};
buffer << stl::boolalpha << elem.template cast<bool>();
ImGui::Text("%s: %s", label, buffer.str().data());
} else if(type.info() == type_id<char>()) {
ImGui::Text("%s: %c", label, elem.template cast<char>());
} else if(type.is_integral()) {
ImGui::Text("%s: %zu", label, elem.template allow_cast<std::uint64_t>().template cast<std::uint64_t>());
ImGui::Text("%s: %zu", label, elem.template allow_cast<stl::uint64_t>().template cast<stl::uint64_t>());
} else {
ImGui::Text("%s: %f", label, elem.template allow_cast<double>().template cast<double>());
}
@@ -83,7 +83,7 @@ static void present_element(const meta_any &obj, OnEntity on_entity) {
if(ImGui::TreeNode(label)) {
meta_sequence_container view = elem.as_sequence_container();
for(std::size_t pos{}, last = view.size(); pos < last; ++pos) {
for(stl::size_t pos{}, last = view.size(); pos < last; ++pos) {
ImGui::PushID(static_cast<int>(pos));
if(ImGui::TreeNode(label, "%zu", pos)) {
@@ -101,7 +101,7 @@ static void present_element(const meta_any &obj, OnEntity on_entity) {
meta_associative_container view = elem.as_associative_container();
auto it = view.begin();
for(std::size_t pos{}, last = view.size(); pos < last; ++pos, ++it) {
for(stl::size_t pos{}, last = view.size(); pos < last; ++pos, ++it) {
ImGui::PushID(static_cast<int>(pos));
if(ImGui::TreeNode(label, "%zu", pos)) {
@@ -131,7 +131,7 @@ static void present_element(const meta_any &obj, OnEntity on_entity) {
ImGui::TreePop();
}
} else {
const std::string underlying_type{data.type().info().name()};
const stl::string underlying_type{data.type().info().name()};
ImGui::Text("%s: %s", label, underlying_type.data());
}
}
@@ -149,7 +149,7 @@ static void present_storage(const meta_ctx &ctx, const basic_sparse_set<Entity,
if(ImGui::TreeNode(&storage.info(), "%d [%d/%d]", to_integral(entt), to_entity(entt), to_version(entt))) {
if(const auto obj = type.from_void(storage.value(entt)); obj) {
present_element<typename std::decay_t<decltype(storage)>::entity_type>(obj, [](const char *name, const Entity entt) {
present_element<typename stl::decay_t<decltype(storage)>::entity_type>(obj, [](const char *name, const Entity entt) {
ImGui::Text("%s: %d [%d/%d]", name, to_integral(entt), to_entity(entt), to_version(entt));
});
}
@@ -171,7 +171,7 @@ static void present_entity(const meta_ctx &ctx, const Entity entt, const It from
for(auto it = from; it != to; ++it) {
if(const auto &storage = it->second; storage.contains(entt)) {
if(auto type = resolve(ctx, storage.info()); type) {
const std::string name = type.name().empty() ? std::string{storage.info().name()} : std::string{type.name()};
const stl::string name = type.name().empty() ? stl::string{storage.info().name()} : stl::string{type.name()};
const char *const label = name.c_str();
if(ImGui::TreeNode(&storage.info(), "%s", label)) {
@@ -187,26 +187,26 @@ static void present_entity(const meta_ctx &ctx, const Entity entt, const It from
ImGui::TreePop();
}
} else {
const std::string name{storage.info().name()};
const stl::string name{storage.info().name()};
ImGui::Text("%s", name.data());
}
}
}
}
template<typename... Get, typename... Exclude, std::size_t... Index>
static void present_view(const meta_ctx &ctx, const basic_view<get_t<Get...>, exclude_t<Exclude...>> &view, std::index_sequence<Index...>) {
template<typename... Get, typename... Exclude, stl::size_t... Index>
static void present_view(const meta_ctx &ctx, const basic_view<get_t<Get...>, exclude_t<Exclude...>> &view, stl::index_sequence<Index...>) {
using view_type = basic_view<get_t<Get...>, exclude_t<Exclude...>>;
const std::array<const typename view_type::common_type *, sizeof...(Index)> range{view.template storage<Index>()...};
const stl::array<const typename view_type::common_type *, sizeof...(Index)> range{view.template storage<Index>()...};
for(auto tup: view.each()) {
const auto entt = std::get<0>(tup);
const auto entt = stl::get<0>(tup);
ImGui::PushID(static_cast<int>(to_entity(entt)));
if(ImGui::TreeNode(&type_id<typename view_type::entity_type>(), "%d [%d/%d]", to_integral(entt), to_entity(entt), to_version(entt))) {
for(const auto *storage: range) {
if(auto type = resolve(ctx, storage->info()); type) {
const std::string name = type.name().empty() ? std::string{storage->info().name()} : std::string{type.name()};
const stl::string name = type.name().empty() ? stl::string{storage->info().name()} : stl::string{type.name()};
const char *const label = name.c_str();
if(ImGui::TreeNode(&storage->info(), "%s", label)) {
@@ -219,7 +219,7 @@ static void present_view(const meta_ctx &ctx, const basic_view<get_t<Get...>, ex
ImGui::TreePop();
}
} else {
const std::string name{storage->info().name()};
const stl::string name{storage->info().name()};
ImGui::Text("%s", name.data());
}
}
@@ -268,7 +268,7 @@ void davey(const basic_storage<Type, Entity, Allocator> &storage) {
*/
template<typename... Get, typename... Exclude>
void davey(const meta_ctx &ctx, const basic_view<get_t<Get...>, exclude_t<Exclude...>> &view) {
internal::present_view(ctx, view, std::index_sequence_for<Get...>{});
internal::present_view(ctx, view, stl::index_sequence_for<Get...>{});
}
/**
@@ -312,7 +312,7 @@ void davey(const meta_ctx &ctx, const basic_registry<Entity, Allocator> &registr
if(ImGui::BeginTabItem("Storage")) {
for([[maybe_unused]] auto [id, storage]: registry.storage()) {
const auto type = resolve(ctx, storage.info());
const std::string name = type.name().empty() ? std::string{storage.info().name()} : std::string{type.name()};
const stl::string name = type.name().empty() ? stl::string{storage.info().name()} : stl::string{type.name()};
const char *const label = name.c_str();
if(ImGui::TreeNode(&storage.info(), "%s (%zu)", label, storage.size())) {

View File

@@ -220,17 +220,19 @@ endif()
# Test config
SETUP_BASIC_TEST(
NAME config_ext
SOURCES entt/config/config.cpp
INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include
)
SETUP_BASIC_TEST(
NAME config
SOURCES entt/config/version.cpp
)
# Test config_ext
SETUP_BASIC_TEST(
NAME config_ext
SOURCES entt/config_ext/config.cpp
INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include
)
# Test container
SETUP_BASIC_TEST(
@@ -288,10 +290,12 @@ SETUP_BASIC_TEST(
entt/entity/view.cpp
)
# Test entity_no_mixin
SETUP_BASIC_TEST(
NAME entity_no_mixin
SOURCES
entt/entity/storage_utility.cpp
entt/entity_no_mixin/storage_utility.cpp
DEFS ENTT_NO_MIXIN
)
@@ -382,3 +386,32 @@ SETUP_BASIC_TEST(
entt/stl/memory.cpp
DEFS ENTT_USE_STL
)
# Test stl_ext
SETUP_BASIC_TEST(
NAME stl_ext
SOURCES
entt/stl_ext/algorithm.cpp
entt/stl_ext/array.cpp
entt/stl_ext/atomic.cpp
entt/stl_ext/bit.cpp
entt/stl_ext/cmath.cpp
entt/stl_ext/concepts.cpp
entt/stl_ext/cstddef.cpp
entt/stl_ext/cstdint.cpp
entt/stl_ext/functional.cpp
entt/stl_ext/ios.cpp
entt/stl_ext/iterator.cpp
entt/stl_ext/limits.cpp
entt/stl_ext/memory.cpp
entt/stl_ext/ostream.cpp
entt/stl_ext/sstream.cpp
entt/stl_ext/string.cpp
entt/stl_ext/string_view.cpp
entt/stl_ext/tuple.cpp
entt/stl_ext/type_traits.cpp
entt/stl_ext/utility.cpp
entt/stl_ext/vector.cpp
INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/include
)

View File

@@ -1,15 +1,14 @@
#ifndef ENTT_COMMON_TRACKED_MEMORY_RESOURCE_HPP
#define ENTT_COMMON_TRACKED_MEMORY_RESOURCE_HPP
#if __has_include(<version>)
# include <version>
#include <version>
#if defined(__cpp_lib_memory_resource) && __cpp_lib_memory_resource >= 201603L
# define ENTT_HAS_TRACKED_MEMORY_RESOURCE
#
# if defined(__cpp_lib_memory_resource) && __cpp_lib_memory_resource >= 201603L
# define ENTT_HAS_TRACKED_MEMORY_RESOURCE
#
# include <cstddef>
# include <memory_resource>
# include <string>
# include <cstddef>
# include <memory_resource>
# include <string>
namespace test {
@@ -58,7 +57,6 @@ private:
} // namespace test
# endif
#endif
#endif

View File

@@ -1,7 +1,6 @@
#include <array>
#include <cstddef>
#include <utility>
#include <vector>
#include <gtest/gtest.h>
#include <entt/core/type_info.hpp>
#include <entt/entity/group.hpp>

View File

@@ -14,28 +14,16 @@ TYPED_TEST(StorageUtility, StorageType) {
using value_type = TestFixture::type;
// just a bunch of static asserts to avoid regressions
#ifdef ENTT_NO_MIXIN
testing::StaticAssertTypeEq<entt::storage_type_t<value_type, entt::entity>, entt::basic_storage<value_type, entt::entity>>();
testing::StaticAssertTypeEq<entt::storage_type_t<value_type>, entt::storage<value_type>>();
#else
testing::StaticAssertTypeEq<entt::storage_type_t<value_type, entt::entity>, entt::sigh_mixin<entt::basic_storage<value_type, entt::entity>>>();
testing::StaticAssertTypeEq<entt::storage_type_t<value_type>, entt::sigh_mixin<entt::storage<value_type>>>();
#endif // ENTT_NO_MIXIN
}
TYPED_TEST(StorageUtility, StorageFor) {
using value_type = TestFixture::type;
// just a bunch of static asserts to avoid regressions
#ifdef ENTT_NO_MIXIN
testing::StaticAssertTypeEq<entt::storage_for_t<const value_type, entt::entity>, const entt::basic_storage<value_type, entt::entity>>();
testing::StaticAssertTypeEq<entt::storage_for_t<value_type, entt::entity>, entt::basic_storage<value_type, entt::entity>>();
testing::StaticAssertTypeEq<entt::storage_for_t<const value_type>, const entt::storage<value_type>>();
testing::StaticAssertTypeEq<entt::storage_for_t<value_type>, entt::storage<value_type>>();
#else
testing::StaticAssertTypeEq<entt::storage_for_t<const value_type, entt::entity>, const entt::sigh_mixin<entt::basic_storage<value_type, entt::entity>>>();
testing::StaticAssertTypeEq<entt::storage_for_t<value_type, entt::entity>, entt::sigh_mixin<entt::basic_storage<value_type, entt::entity>>>();
testing::StaticAssertTypeEq<entt::storage_for_t<const value_type>, const entt::sigh_mixin<entt::storage<value_type>>>();
testing::StaticAssertTypeEq<entt::storage_for_t<value_type>, entt::sigh_mixin<entt::storage<value_type>>>();
#endif
}

View File

@@ -0,0 +1,29 @@
#include <gtest/gtest.h>
#include <entt/entity/storage.hpp>
template<typename Type>
struct StorageUtility: testing::Test {
using type = Type;
};
using StorageUtilityTypes = ::testing::Types<int, char, double, void>;
TYPED_TEST_SUITE(StorageUtility, StorageUtilityTypes, );
TYPED_TEST(StorageUtility, StorageType) {
using value_type = TestFixture::type;
// just a bunch of static asserts to avoid regressions
testing::StaticAssertTypeEq<entt::storage_type_t<value_type, entt::entity>, entt::basic_storage<value_type, entt::entity>>();
testing::StaticAssertTypeEq<entt::storage_type_t<value_type>, entt::storage<value_type>>();
}
TYPED_TEST(StorageUtility, StorageFor) {
using value_type = TestFixture::type;
// just a bunch of static asserts to avoid regressions
testing::StaticAssertTypeEq<entt::storage_for_t<const value_type, entt::entity>, const entt::basic_storage<value_type, entt::entity>>();
testing::StaticAssertTypeEq<entt::storage_for_t<value_type, entt::entity>, entt::basic_storage<value_type, entt::entity>>();
testing::StaticAssertTypeEq<entt::storage_for_t<const value_type>, const entt::storage<value_type>>();
testing::StaticAssertTypeEq<entt::storage_for_t<value_type>, entt::storage<value_type>>();
}

View File

@@ -0,0 +1,3 @@
#include <memory>
#include <gtest/gtest.h>
#include <entt/stl/algorithm.hpp>

View File

@@ -0,0 +1,3 @@
#include <memory>
#include <gtest/gtest.h>
#include <entt/stl/array.hpp>

Some files were not shown because too many files have changed in this diff Show More