Replace std::size usage with std_size to avoid <iterator> include.

This commit is contained in:
Lukas Tenbrink
2025-10-03 20:02:38 +02:00
parent 6d33ad2917
commit 1db0a60dc0
40 changed files with 69 additions and 66 deletions

View File

@ -30,7 +30,7 @@
#include "error_list.h"
#include <iterator>
#include "core/typedefs.h"
const char *error_names[] = {
"OK", // OK
@ -84,4 +84,4 @@ const char *error_names[] = {
"Printer on fire", // ERR_PRINTER_ON_FIRE
};
static_assert(std::size(error_names) == ERR_MAX);
static_assert(std_size(error_names) == ERR_MAX);

View File

@ -415,7 +415,7 @@ static const _BuiltinActionDisplayName _builtin_action_display_names[] = {
};
String InputMap::get_builtin_display_name(const String &p_name) const {
constexpr int len = std::size(_builtin_action_display_names);
constexpr int len = std_size(_builtin_action_display_names);
for (int i = 0; i < len; i++) {
if (_builtin_action_display_names[i].name == p_name) {

View File

@ -445,7 +445,7 @@ class CharBuffer {
public:
_FORCE_INLINE_ CharBuffer() :
buffer(stack_buffer),
capacity(std::size(stack_buffer)) {
capacity(std_size(stack_buffer)) {
}
_FORCE_INLINE_ void push_back(char c) {

View File

@ -47,7 +47,7 @@ String ResourceUID::get_cache_file() {
}
static constexpr uint8_t uuid_characters[] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', '0', '1', '2', '3', '4', '5', '6', '7', '8' };
static constexpr uint32_t uuid_characters_element_count = std::size(uuid_characters);
static constexpr uint32_t uuid_characters_element_count = std_size(uuid_characters);
static constexpr uint8_t max_uuid_number_length = 13; // Max 0x7FFFFFFFFFFFFFFF (uid://d4n4ub6itg400) size is 13 characters.
String ResourceUID::id_to_text(ID p_id) const {

View File

@ -432,7 +432,7 @@ int Color::find_named_color(const String &p_name) {
}
int Color::get_named_color_count() {
return std::size(named_colors);
return std_size(named_colors);
}
String Color::get_named_color_name(int p_idx) {

View File

@ -34,14 +34,12 @@
#include "char_range.inc"
#include <iterator>
static constexpr char hex_char_table_upper[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
static constexpr char hex_char_table_lower[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
#define BSEARCH_CHAR_RANGE(m_array) \
int low = 0; \
int high = std::size(m_array) - 1; \
int high = std_size(m_array) - 1; \
int middle = (low + high) / 2; \
\
while (low <= high) { \

View File

@ -182,7 +182,7 @@ const char32_t *TranslationDomain::_get_accented_version(char32_t p_character) c
return nullptr;
}
for (unsigned int i = 0; i < std::size(_character_to_accented); i++) {
for (unsigned int i = 0; i < std_size(_character_to_accented); i++) {
if (_character_to_accented[i].character == p_character) {
return _character_to_accented[i].accented_character;
}

View File

@ -144,6 +144,12 @@ constexpr auto CLAMP(const T m_a, const T2 m_min, const T3 m_max) {
#define SWAP(m_x, m_y) std::swap((m_x), (m_y))
#endif // SWAP
// Like std::size, but without requiring any additional includes.
template <typename T, size_t SIZE>
constexpr size_t std_size(const T (&)[SIZE]) {
return SIZE;
}
/* Functions to handle powers of 2 and shifting. */
// Returns `true` if a positive integer is a power of 2, `false` otherwise.