File indexing completed on 2025-10-28 08:27:37
0001
0002
0003
0004
0005
0006 #ifndef BOOST_PFR_DETAIL_SIZE_ARRAY_HPP
0007 #define BOOST_PFR_DETAIL_SIZE_ARRAY_HPP
0008 #pragma once
0009
0010 #include <boost/pfr/detail/config.hpp>
0011
0012 #ifdef BOOST_PFR_HAS_STD_MODULE
0013 import std;
0014 #else
0015 #include <cstddef>
0016 #endif
0017
0018 namespace boost { namespace pfr { namespace detail {
0019
0020
0021 template <std::size_t N>
0022 struct size_array {
0023 typedef std::size_t type;
0024 std::size_t data[N];
0025
0026 static constexpr std::size_t size() noexcept { return N; }
0027
0028 constexpr std::size_t count_nonzeros() const noexcept {
0029 std::size_t count = 0;
0030 for (std::size_t i = 0; i < size(); ++i) {
0031 if (data[i]) {
0032 ++ count;
0033 }
0034 }
0035 return count;
0036 }
0037
0038 constexpr std::size_t count_from_opening_till_matching_parenthis_seq(std::size_t from, std::size_t opening_parenthis, std::size_t closing_parenthis) const noexcept {
0039 if (data[from] != opening_parenthis) {
0040 return 0;
0041 }
0042 std::size_t unclosed_parnthesis = 0;
0043 std::size_t count = 0;
0044 for (; ; ++from) {
0045 if (data[from] == opening_parenthis) {
0046 ++ unclosed_parnthesis;
0047 } else if (data[from] == closing_parenthis) {
0048 -- unclosed_parnthesis;
0049 }
0050 ++ count;
0051
0052 if (unclosed_parnthesis == 0) {
0053 return count;
0054 }
0055 }
0056
0057 return count;
0058 }
0059 };
0060
0061 template <>
0062 struct size_array<0> {
0063 typedef std::size_t type;
0064 std::size_t data[1];
0065
0066 static constexpr std::size_t size() noexcept { return 0; }
0067
0068 constexpr std::size_t count_nonzeros() const noexcept {
0069 return 0;
0070 }
0071 };
0072
0073 template <std::size_t I, std::size_t N>
0074 constexpr std::size_t get(const size_array<N>& a) noexcept {
0075 static_assert(I < N, "====================> Boost.PFR: Array index out of bounds");
0076 return a.data[I];
0077 }
0078
0079
0080
0081 }}}
0082
0083 #endif