build: add EnTT library

This commit is contained in:
2026-07-25 10:29:04 +08:00
parent 3e7ce71219
commit 849386a3bc
111 changed files with 24637 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
#ifndef ENTT_STL_ALGORITHM_HPP
#define ENTT_STL_ALGORITHM_HPP
/*! @cond ENTT_INTERNAL */
#if __has_include(<entt/ext/stl/algorithm.hpp>)
# include <entt/ext/stl/algorithm.hpp>
#else
# include <algorithm>
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
#endif
/*! @endcond */
#endif

View File

@@ -0,0 +1,19 @@
#ifndef ENTT_STL_ARRAY_HPP
#define ENTT_STL_ARRAY_HPP
/*! @cond ENTT_INTERNAL */
#if __has_include(<entt/ext/stl/array.hpp>)
# include <entt/ext/stl/array.hpp>
#else
# include <array>
namespace entt::stl {
using std::array;
using std::get;
} // namespace entt::stl
#endif
/*! @endcond */
#endif

View File

@@ -0,0 +1,18 @@
#ifndef ENTT_STL_ATOMIC_HPP
#define ENTT_STL_ATOMIC_HPP
/*! @cond ENTT_INTERNAL */
#if __has_include(<entt/ext/stl/atomic.hpp>)
# include <entt/ext/stl/atomic.hpp>
#else
# include <atomic>
namespace entt::stl {
using std::atomic;
} // namespace entt::stl
#endif
/*! @endcond */
#endif

20
include/entt/stl/bit.hpp Normal file
View File

@@ -0,0 +1,20 @@
#ifndef ENTT_STL_BIT_HPP
#define ENTT_STL_BIT_HPP
/*! @cond ENTT_INTERNAL */
#if __has_include(<entt/ext/stl/bit.hpp>)
# include <entt/ext/stl/bit.hpp>
#else
# include <bit>
namespace entt::stl {
using std::bit_ceil;
using std::has_single_bit;
using std::popcount;
} // namespace entt::stl
#endif
/*! @endcond */
#endif

View File

@@ -0,0 +1,18 @@
#ifndef ENTT_STL_CMATH_HPP
#define ENTT_STL_CMATH_HPP
/*! @cond ENTT_INTERNAL */
#if __has_include(<entt/ext/stl/cmath.hpp>)
# include <entt/ext/stl/cmath.hpp>
#else
# include <cmath>
namespace entt::stl {
using std::ceil;
} // namespace entt::stl
#endif
/*! @endcond */
#endif

View File

@@ -0,0 +1,24 @@
#ifndef ENTT_STL_CONCEPTS_HPP
#define ENTT_STL_CONCEPTS_HPP
/*! @cond ENTT_INTERNAL */
#if __has_include(<entt/ext/stl/concepts.hpp>)
# include <entt/ext/stl/concepts.hpp>
#else
# include <concepts>
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
#endif
/*! @endcond */
#endif

View File

@@ -0,0 +1,21 @@
#ifndef ENTT_STL_CSTDDEF_HPP
#define ENTT_STL_CSTDDEF_HPP
/*! @cond ENTT_INTERNAL */
#if __has_include(<entt/ext/stl/cstddef.hpp>)
# include <entt/ext/stl/cstddef.hpp>
#else
# include <cstddef>
namespace entt::stl {
using std::byte;
using std::nullptr_t;
using std::ptrdiff_t;
using std::size_t;
} // namespace entt::stl
#endif
/*! @endcond */
#endif

View File

@@ -0,0 +1,21 @@
#ifndef ENTT_STL_CSTDINT_HPP
#define ENTT_STL_CSTDINT_HPP
/*! @cond ENTT_INTERNAL */
#if __has_include(<entt/ext/stl/cstdint.hpp>)
# include <entt/ext/stl/cstdint.hpp>
#else
# include <cstdint>
namespace entt::stl {
using std::uint16_t;
using std::uint32_t;
using std::uint64_t;
using std::uint8_t;
} // namespace entt::stl
#endif
/*! @endcond */
#endif

View File

@@ -0,0 +1,55 @@
#ifndef ENTT_STL_FUNCTIONAL_HPP
#define ENTT_STL_FUNCTIONAL_HPP
/*! @cond ENTT_INTERNAL */
#if __has_include(<entt/ext/stl/functional.hpp>)
# include <entt/ext/stl/functional.hpp>
#else
# include <functional>
# include <version>
# include "../config/config.h"
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 defined(__cpp_lib_ranges)
# define ENTT_HAS_IDENTITY
namespace entt::stl {
using std::identity;
} // namespace entt::stl
# endif
# endif
# ifndef ENTT_HAS_IDENTITY
# include <utility>
namespace entt::stl {
struct identity {
using is_transparent = void;
template<typename Type>
[[nodiscard]] constexpr Type &&operator()(Type &&value) const noexcept {
return std::forward<Type>(value);
}
};
} // namespace entt::stl
# endif
#endif
/*! @endcond */
#undef ENTT_HAS_IDENTITY
#endif

18
include/entt/stl/ios.hpp Normal file
View File

@@ -0,0 +1,18 @@
#ifndef ENTT_STL_IOS_HPP
#define ENTT_STL_IOS_HPP
/*! @cond ENTT_INTERNAL */
#if __has_include(<entt/ext/stl/ios.hpp>)
# include <entt/ext/stl/ios.hpp>
#else
# include <ios>
namespace entt::stl {
using std::boolalpha;
} // namespace entt::stl
#endif
/*! @endcond */
#endif

View File

@@ -0,0 +1,110 @@
#ifndef ENTT_STL_ITERATOR_HPP
#define ENTT_STL_ITERATOR_HPP
/*! @cond ENTT_INTERNAL */
#if __has_include(<entt/ext/stl/iterator.hpp>)
# include <entt/ext/stl/iterator.hpp>
#else
# include <iterator>
# include <version>
# include "../config/config.h"
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;
using std::input_or_output_iterator;
using std::output_iterator;
using std::random_access_iterator;
using std::sentinel_for;
# endif
# endif
# ifndef ENTT_HAS_ITERATOR_CONCEPTS
# include <concepts>
# include <utility>
namespace internal {
template<typename It>
concept has_iterator_category = requires {
typename std::iterator_traits<It>::iterator_category;
};
template<typename It>
concept has_iterator_concept = has_iterator_category<It> && requires {
typename It::iterator_concept;
};
template<has_iterator_category It>
struct iterator_tag {
using type = typename std::iterator_traits<It>::iterator_category;
};
template<has_iterator_concept It>
struct iterator_tag<It> {
using type = typename It::iterator_concept;
};
template<typename It, typename Tag>
concept has_iterator_tag = std::derived_from<typename iterator_tag<It>::type, Tag>;
} // namespace internal
// Bare minimum definitions to support broken platforms like PS4.
// EnTT does not provide full featured definitions for iterator concepts.
template<typename It>
concept input_or_output_iterator = requires(It it) {
*it;
{ ++it } -> std::same_as<It &>;
it++;
};
template<typename It>
concept input_iterator = input_or_output_iterator<It> && internal::has_iterator_tag<It, std::input_iterator_tag>;
template<typename It, typename Type>
concept output_iterator = input_or_output_iterator<It> && requires(It it, Type &&value) {
*it++ = std::forward<Type>(value);
};
template<typename It>
concept forward_iterator = input_iterator<It> && internal::has_iterator_tag<It, std::forward_iterator_tag>;
template<typename It>
concept bidirectional_iterator = forward_iterator<It> && internal::has_iterator_tag<It, std::bidirectional_iterator_tag>;
template<typename It>
concept random_access_iterator = bidirectional_iterator<It> && internal::has_iterator_tag<It, std::random_access_iterator_tag>;
template<class Sentinel, typename It>
concept sentinel_for = input_or_output_iterator<It> && requires(Sentinel sentinel, It it) {
{ it == sentinel } -> std::same_as<bool>;
};
# endif
} // namespace entt::stl
#endif
/*! @endcond */
#undef ENTT_HAS_ITERATOR_CONCEPTS
#endif

View File

@@ -0,0 +1,18 @@
#ifndef ENTT_STL_LIMITS_HPP
#define ENTT_STL_LIMITS_HPP
/*! @cond ENTT_INTERNAL */
#if __has_include(<entt/ext/stl/limits.hpp>)
# include <entt/ext/stl/limits.hpp>
#else
# include <limits>
namespace entt::stl {
using std::numeric_limits;
} // namespace entt::stl
#endif
/*! @endcond */
#endif

View File

@@ -0,0 +1,74 @@
#ifndef ENTT_STL_MEMORY_HPP
#define ENTT_STL_MEMORY_HPP
/*! @cond ENTT_INTERNAL */
#if __has_include(<entt/ext/stl/memory.hpp>)
# include <entt/ext/stl/memory.hpp>
#else
# include <memory>
# include <version>
# include "../config/config.h"
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 defined(__cpp_lib_to_address)
# define ENTT_HAS_TO_ADDRESS
namespace entt::stl {
using std::to_address;
} // namespace entt::stl
# endif
# endif
# ifndef ENTT_HAS_TO_ADDRESS
# include <type_traits>
namespace entt::stl {
template<typename Type>
constexpr Type *to_address(Type *ptr) noexcept {
static_assert(!std::is_function_v<Type>, "Invalid type");
return ptr;
}
template<typename Type>
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->());
}
}
} // namespace entt::stl
# endif
#endif
/*! @endcond */
#undef ENTT_HAS_TO_ADDRESS
#endif

View File

@@ -0,0 +1,18 @@
#ifndef ENTT_STL_OSTREAM_HPP
#define ENTT_STL_OSTREAM_HPP
/*! @cond ENTT_INTERNAL */
#if __has_include(<entt/ext/stl/ostream.hpp>)
# include <entt/ext/stl/ostream.hpp>
#else
# include <ostream>
namespace entt::stl {
using std::ostream;
} // namespace entt::stl
#endif
/*! @endcond */
#endif

View File

@@ -0,0 +1,18 @@
#ifndef ENTT_STL_SSTREAM_HPP
#define ENTT_STL_SSTREAM_HPP
/*! @cond ENTT_INTERNAL */
#if __has_include(<entt/ext/stl/sstream.hpp>)
# include <entt/ext/stl/sstream.hpp>
#else
# include <sstream>
namespace entt::stl {
using std::stringstream;
} // namespace entt::stl
#endif
/*! @endcond */
#endif

View File

@@ -0,0 +1,18 @@
#ifndef ENTT_STL_STRING_HPP
#define ENTT_STL_STRING_HPP
/*! @cond ENTT_INTERNAL */
#if __has_include(<entt/ext/stl/string.hpp>)
# include <entt/ext/stl/string.hpp>
#else
# include <string>
namespace entt::stl {
using std::string;
} // namespace entt::stl
#endif
/*! @endcond */
#endif

View File

@@ -0,0 +1,19 @@
#ifndef ENTT_STL_STRING_VIEW_HPP
#define ENTT_STL_STRING_VIEW_HPP
/*! @cond ENTT_INTERNAL */
#if __has_include(<entt/ext/stl/string_view.hpp>)
# include <entt/ext/stl/string_view.hpp>
#else
# include <string_view>
namespace entt::stl {
using std::string_view;
using std::swap;
} // namespace entt::stl
#endif
/*! @endcond */
#endif

View File

@@ -0,0 +1,28 @@
#ifndef ENTT_STL_TUPLE_HPP
#define ENTT_STL_TUPLE_HPP
/*! @cond ENTT_INTERNAL */
#if __has_include(<entt/ext/stl/tuple.hpp>)
# include <entt/ext/stl/tuple.hpp>
#else
# include <tuple>
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
#endif
/*! @endcond */
#endif

View File

@@ -0,0 +1,70 @@
#ifndef ENTT_STL_TYPE_TRAITS_HPP
#define ENTT_STL_TYPE_TRAITS_HPP
/*! @cond ENTT_INTERNAL */
#if __has_include(<entt/ext/stl/type_traits.hpp>)
# include <entt/ext/stl/type_traits.hpp>
#else
# include <type_traits>
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::type_identity;
using std::underlying_type_t;
} // namespace entt::stl
#endif
/*! @endcond */
#endif

View File

@@ -0,0 +1,34 @@
#ifndef ENTT_STL_UTILITY_HPP
#define ENTT_STL_UTILITY_HPP
/*! @cond ENTT_INTERNAL */
#if __has_include(<entt/ext/stl/utility.hpp>)
# include <entt/ext/stl/utility.hpp>
#else
# include <utility>
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
#endif
/*! @endcond */
#endif

View File

@@ -0,0 +1,18 @@
#ifndef ENTT_STL_VECTOR_HPP
#define ENTT_STL_VECTOR_HPP
/*! @cond ENTT_INTERNAL */
#if __has_include(<entt/ext/stl/vector.hpp>)
# include <entt/ext/stl/vector.hpp>
#else
# include <vector>
namespace entt::stl {
using std::vector;
} // namespace entt::stl
#endif
/*! @endcond */
#endif