diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2024-05-26 15:30:15 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-05-26 15:30:15 +0200 |
commit | 82ab34aa83463179339eb8382edf1c22cacdad61 (patch) | |
tree | 3d02aaa7458a4f00e38527c7cfe0f8559398b5d5 /src | |
parent | c3bebd8c3263d67f3b66cab7437bc24f5ea724c8 (diff) |
use array_size instead of std::size/arraySize
Diffstat (limited to 'src')
-rw-r--r-- | src/anim-atlas.cpp | 3 | ||||
-rw-r--r-- | src/search-astar.cpp | 3 | ||||
-rw-r--r-- | src/search-cache.cpp | 3 | ||||
-rw-r--r-- | src/search.cpp | 3 | ||||
-rw-r--r-- | src/timer.cpp | 6 | ||||
-rw-r--r-- | src/wall-atlas.cpp | 3 | ||||
-rw-r--r-- | src/wall-atlas.hpp | 3 |
7 files changed, 15 insertions, 9 deletions
diff --git a/src/anim-atlas.cpp b/src/anim-atlas.cpp index 6509a494..cff16798 100644 --- a/src/anim-atlas.cpp +++ b/src/anim-atlas.cpp @@ -1,6 +1,7 @@ #include "anim-atlas.hpp" #include "shaders/shader.hpp" #include "compat/assert.hpp" +#include "compat/array-size.hpp" #include "compat/exception.hpp" #include <Corrade/Containers/BitArrayView.h> #include <Corrade/Containers/StridedArrayView.h> @@ -12,7 +13,7 @@ namespace floormat { static constexpr const char name_array[][3] = { "n", "ne", "e", "se", "s", "sw", "w", "nw", }; static constexpr inline auto rot_count = size_t(rotation_COUNT); -static_assert(std::size(name_array) == rot_count); +static_assert(array_size(name_array) == rot_count); static_assert(rot_count == 8); uint8_t anim_atlas::rotation_to_index(StringView name) diff --git a/src/search-astar.cpp b/src/search-astar.cpp index af82ce90..3215cee7 100644 --- a/src/search-astar.cpp +++ b/src/search-astar.cpp @@ -6,6 +6,7 @@ #include "object.hpp" #include "world.hpp" #include "point.inl" +#include "compat/array-size.hpp" #include "compat/format.hpp" #include "compat/vector-wrapper.hpp" #include "compat/heap.hpp" @@ -388,7 +389,7 @@ path_search_result astar::Dijkstra(world& w, const point from, const point to, } if (len) { - len = Math::min(len, std::size(buf)-1); + len = Math::min(len, array_size(buf)-1); std::fwrite(buf, len, 1, stdout); std::fflush(stdout); } diff --git a/src/search-cache.cpp b/src/search-cache.cpp index dd73601f..cd83888b 100644 --- a/src/search-cache.cpp +++ b/src/search-cache.cpp @@ -2,6 +2,7 @@ #include "search-constants.hpp" #include "point.hpp" #include "world.hpp" +#include "compat/array-size.hpp" #include <bitset> namespace floormat::Search { @@ -18,7 +19,7 @@ struct cache::chunk_cache x *= i; return x; }(); - static constexpr size_t rank = arraySize(dimensions); + static constexpr size_t rank = array_size(dimensions); struct index { uint32_t value = 0; }; class chunk* chunk = nullptr; diff --git a/src/search.cpp b/src/search.cpp index af32e7a3..68ec0cce 100644 --- a/src/search.cpp +++ b/src/search.cpp @@ -6,6 +6,7 @@ #include "world.hpp" #include "pass-mode.hpp" #include "RTree-search.hpp" +#include "compat/array-size.hpp" #include "compat/function2.hpp" #include <bit> @@ -76,7 +77,7 @@ bool path_search::is_passable_(chunk* c0, const std::array<chunk*, 8>& neighbors if (c2) { - static_assert(std::size(world::neighbor_offsets) == 8); + static_assert(array_size(world::neighbor_offsets) == 8); constexpr auto chunk_size = iTILE_SIZE2 * TILE_MAX_DIM; const auto off = Vector2(nb)*Vector2(chunk_size); const auto min_ = min - off, max_ = max - off; diff --git a/src/timer.cpp b/src/timer.cpp index ad78f383..4fdab61d 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -72,16 +72,16 @@ float Time::to_milliseconds(const Ns& ts) noexcept const char* format_datetime_to_string(char (&buf)[fm_DATETIME_BUF_SIZE]) { constexpr const char* fmt = "%a, %d %b %Y %H:%M:%S."; - constexpr size_t fmtsize = std::size("Thu 01 Mon 197000 00:00:00."); + constexpr size_t fmtsize = array_size("Thu 01 Mon 197000 00:00:00."); static_assert(static_array_size<decltype(buf)> - fmtsize == 4); const auto t = SystemClock::now(); const auto ms = duration_cast<Millis>(t.time_since_epoch()) % 1000; const auto time = SystemClock::to_time_t(t); const auto* tm = std::localtime(&time); - auto len = std::strftime(buf, std::size(buf), fmt, tm); + auto len = std::strftime(buf, array_size(buf), fmt, tm); fm_assert(len > 0 && len <= fmtsize); auto len2 = std::sprintf(buf + len, "%03u", unsigned{ms.count()}); - fm_assert(len2 > 0 && len + (size_t)len2 < std::size(buf)); + fm_assert(len2 > 0 && len + (size_t)len2 < array_size(buf)); return buf; } diff --git a/src/wall-atlas.cpp b/src/wall-atlas.cpp index 8ea687e4..991e1b45 100644 --- a/src/wall-atlas.cpp +++ b/src/wall-atlas.cpp @@ -1,5 +1,6 @@ #include "wall-atlas.hpp" #include "tile-constants.hpp" +#include "compat/array-size.hpp" #include "compat/exception.hpp" #include <utility> #include <Corrade/Containers/StridedArrayView.h> @@ -21,7 +22,7 @@ uint8_t direction_index_from_name(StringView s) noexcept(false) StringView direction_index_to_name(size_t i) noexcept(false) { - fm_soft_assert(i < arraySize(wall_atlas::directions)); + fm_soft_assert(i < array_size(wall_atlas::directions)); return wall_atlas::directions[i].name; } diff --git a/src/wall-atlas.hpp b/src/wall-atlas.hpp index afd75f37..5cf4f244 100644 --- a/src/wall-atlas.hpp +++ b/src/wall-atlas.hpp @@ -3,6 +3,7 @@ #include "src/pass-mode.hpp" #include "wall-defs.hpp" #include "compat/defs.hpp" +#include "compat/array-size.hpp" #include <array> #include <Corrade/Containers/Array.h> #include <Corrade/Containers/String.h> @@ -57,7 +58,7 @@ struct Direction { "top"_s, &Direction::top, Group_::top }, { "corner"_s, &Direction::corner, Group_::corner }, }; - static_assert(std::size(groups) == (size_t)Group_::COUNT); + static_assert(array_size(groups) == (size_t)Group_::COUNT); static constexpr inline member_tuple groups_for_draw[] = { { "wall"_s, &Direction::wall, Group_::wall }, |