Skip to content

Commit d1d28c0

Browse files
committed
Merge pull request #111223 from Ivorforce/remove-iterator-include
Replace `std::size` usage with `std_size` to avoid `<iterator>` include.
2 parents 93a5f4f + 1db0a60 commit d1d28c0

39 files changed

+67
-66
lines changed

core/error/error_list.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
#include "error_list.h"
3232

33-
#include <iterator>
33+
#include "core/typedefs.h"
3434

3535
const char *error_names[] = {
3636
"OK", // OK
@@ -84,4 +84,4 @@ const char *error_names[] = {
8484
"Printer on fire", // ERR_PRINTER_ON_FIRE
8585
};
8686

87-
static_assert(std::size(error_names) == ERR_MAX);
87+
static_assert(std_size(error_names) == ERR_MAX);

core/input/input_map.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ static const _BuiltinActionDisplayName _builtin_action_display_names[] = {
415415
};
416416

417417
String InputMap::get_builtin_display_name(const String &p_name) const {
418-
constexpr int len = std::size(_builtin_action_display_names);
418+
constexpr int len = std_size(_builtin_action_display_names);
419419

420420
for (int i = 0; i < len; i++) {
421421
if (_builtin_action_display_names[i].name == p_name) {

core/io/file_access.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ class CharBuffer {
445445
public:
446446
_FORCE_INLINE_ CharBuffer() :
447447
buffer(stack_buffer),
448-
capacity(std::size(stack_buffer)) {
448+
capacity(std_size(stack_buffer)) {
449449
}
450450

451451
_FORCE_INLINE_ void push_back(char c) {

core/io/resource_uid.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ String ResourceUID::get_cache_file() {
4747
}
4848

4949
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' };
50-
static constexpr uint32_t uuid_characters_element_count = std::size(uuid_characters);
50+
static constexpr uint32_t uuid_characters_element_count = std_size(uuid_characters);
5151
static constexpr uint8_t max_uuid_number_length = 13; // Max 0x7FFFFFFFFFFFFFFF (uid://d4n4ub6itg400) size is 13 characters.
5252

5353
String ResourceUID::id_to_text(ID p_id) const {

core/math/color.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ int Color::find_named_color(const String &p_name) {
432432
}
433433

434434
int Color::get_named_color_count() {
435-
return std::size(named_colors);
435+
return std_size(named_colors);
436436
}
437437

438438
String Color::get_named_color_name(int p_idx) {

core/string/char_utils.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,12 @@
3434

3535
#include "char_range.inc"
3636

37-
#include <iterator>
38-
3937
static constexpr char hex_char_table_upper[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
4038
static constexpr char hex_char_table_lower[16] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
4139

4240
#define BSEARCH_CHAR_RANGE(m_array) \
4341
int low = 0; \
44-
int high = std::size(m_array) - 1; \
42+
int high = std_size(m_array) - 1; \
4543
int middle = (low + high) / 2; \
4644
\
4745
while (low <= high) { \

core/string/translation_domain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ const char32_t *TranslationDomain::_get_accented_version(char32_t p_character) c
182182
return nullptr;
183183
}
184184

185-
for (unsigned int i = 0; i < std::size(_character_to_accented); i++) {
185+
for (unsigned int i = 0; i < std_size(_character_to_accented); i++) {
186186
if (_character_to_accented[i].character == p_character) {
187187
return _character_to_accented[i].accented_character;
188188
}

core/typedefs.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,12 @@ constexpr auto CLAMP(const T m_a, const T2 m_min, const T3 m_max) {
144144
#define SWAP(m_x, m_y) std::swap((m_x), (m_y))
145145
#endif // SWAP
146146

147+
// Like std::size, but without requiring any additional includes.
148+
template <typename T, size_t SIZE>
149+
constexpr size_t std_size(const T (&)[SIZE]) {
150+
return SIZE;
151+
}
152+
147153
/* Functions to handle powers of 2 and shifting. */
148154

149155
// Returns `true` if a positive integer is a power of 2, `false` otherwise.

drivers/d3d12/rendering_context_driver_d3d12.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252

5353
using Microsoft::WRL::ComPtr;
5454

55-
#define ARRAY_SIZE(a) std::size(a)
55+
#define ARRAY_SIZE(a) std_size(a)
5656

5757
class RenderingContextDriverD3D12 : public RenderingContextDriver {
5858
ComPtr<ID3D12DeviceFactory> device_factory;

drivers/gles3/rasterizer_scene_gles3.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3896,7 +3896,7 @@ void RasterizerSceneGLES3::_render_uv2(const PagedArray<RenderGeometryInstance *
38963896
GL_COLOR_ATTACHMENT2,
38973897
GL_COLOR_ATTACHMENT3
38983898
};
3899-
glDrawBuffers(std::size(draw_buffers), draw_buffers);
3899+
glDrawBuffers(std_size(draw_buffers), draw_buffers);
39003900

39013901
glClearColor(0.0, 0.0, 0.0, 0.0);
39023902
RasterizerGLES3::clear_depth(0.0);

0 commit comments

Comments
 (0)