stl: std::uint8/16/32/64_t

This commit is contained in:
skypjack
2026-04-10 10:08:40 +02:00
parent 6b9f69d0e5
commit e929304ed4
11 changed files with 28 additions and 23 deletions

View File

@@ -43,10 +43,10 @@
#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

@@ -6,6 +6,7 @@
#include "../config/config.h"
#include "../core/concepts.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/cstdint.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "fwd.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,

View File

@@ -8,7 +8,7 @@
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. */

View File

@@ -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;
};

View File

@@ -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;

View File

@@ -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. */

View File

@@ -13,6 +13,7 @@
#include "../core/utility.hpp"
#include "../stl/array.hpp"
#include "../stl/cstddef.hpp"
#include "../stl/cstdint.hpp"
#include "../stl/type_traits.hpp"
#include "../stl/utility.hpp"
#include "../stl/vector.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,

View File

@@ -10,13 +10,13 @@ template<typename, typename = std::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>>
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

@@ -70,7 +70,7 @@ struct process_adaptor;
*/
template<typename Delta, typename Allocator>
class basic_process: public std::enable_shared_from_this<basic_process<Delta, Allocator>> {
enum class state : std::uint8_t {
enum class state : stl::uint8_t {
idle = 0,
running,
paused,

View File

@@ -6,7 +6,10 @@
/*! @cond ENTT_INTERNAL */
namespace entt::stl {
using std::size_t;
using std::uint16_t;
using std::uint32_t;
using std::uint64_t;
using std::uint8_t;
} // namespace entt::stl
/*! @endcond */

View File

@@ -56,7 +56,7 @@ 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>()) {
@@ -66,7 +66,7 @@ static void present_element(const meta_any &obj, OnEntity on_entity) {
} 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>());
}