File indexing completed on 2026-11-07 10:12:11
0001
0002
0003
0004
0005
0006
0007 #pragma once
0008
0009 #include <concepts>
0010 #include <cstddef>
0011 #include <stdexcept>
0012 #include <utility>
0013
0014 namespace covfie::utility {
0015 template <std::integral Index, std::integral Size>
0016 Index checked_size(Size size)
0017 {
0018 if (!std::in_range<Index>(size) || !std::in_range<std::size_t>(size)) {
0019 throw std::overflow_error("Array size is not representable.");
0020 }
0021 return static_cast<Index>(size);
0022 }
0023 }