diff options
| author | Stanislaw Halik <sthalik@misaki.pl> | 2024-05-06 13:30:17 +0200 |
|---|---|---|
| committer | Stanislaw Halik <sthalik@misaki.pl> | 2024-05-06 13:37:15 +0200 |
| commit | 3534cd206bedef5ea75302d9abf879b15d1df89c (patch) | |
| tree | 977f646ae1282ff7f539d2a524d1e354bfcf465d /compat/array-size.hpp | |
| parent | 4d6f747c4b8287e042363264a47265848ca2d92c (diff) | |
test: speed up compile time
Removes implicit includes to <windows.h> and <cr/StringView.h> from all
files.
Goes from 30 to 20 seconds.
Diffstat (limited to 'compat/array-size.hpp')
| -rw-r--r-- | compat/array-size.hpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/compat/array-size.hpp b/compat/array-size.hpp new file mode 100644 index 00000000..ca545898 --- /dev/null +++ b/compat/array-size.hpp @@ -0,0 +1,19 @@ +#pragma once +#include <array> + +namespace floormat::detail { + +template<typename T> struct array_size_; // todo! replace usages of arraySize & std::size +template<typename T, size_t N> struct array_size_<T(&)[N]> : std::integral_constant<size_t, N> {}; +template<typename T, size_t N> struct array_size_<T[N]> : std::integral_constant<size_t, N> {}; +template<typename T, size_t N> struct array_size_<std::array<T, N>> : std::integral_constant<size_t, N> {}; +template<typename T, size_t N> struct array_size_<StaticArray<N, T>> : std::integral_constant<size_t, N> {}; + +} // namespace floormat::detail + +namespace floormat { + +template<typename T> constexpr inline size_t static_array_size = detail::array_size_<T>::value; +template<typename T> constexpr inline size_t array_size(const T&) noexcept { return detail::array_size_<T>::value; } + +} // namespace floormat |
