Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-07 10:12:11

0001 /*
0002  * SPDX-PackageName: "covfie, a part of the ACTS project"
0003  * SPDX-FileCopyrightText: 2026 CERN
0004  * SPDX-License-Identifier: MPL-2.0
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 }