Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:42:25

0001 // Copyright (c) 2016-2025 Antony Polukhin
0002 //
0003 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0004 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0005 
0006 #ifndef BOOST_PFR_DETAIL_FOR_EACH_FIELD_HPP
0007 #define BOOST_PFR_DETAIL_FOR_EACH_FIELD_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 <type_traits>      // metaprogramming stuff
0016 #endif
0017 
0018 #include <boost/pfr/detail/core.hpp>
0019 #include <boost/pfr/detail/fields_count.hpp>
0020 #include <boost/pfr/detail/for_each_field_impl.hpp>
0021 #include <boost/pfr/detail/make_integer_sequence.hpp>
0022 
0023 namespace boost { namespace pfr { namespace detail {
0024 
0025 template <class T, class F>
0026 constexpr void for_each_field(T&& value, F&& func) {
0027     constexpr std::size_t fields_count_val = boost::pfr::detail::fields_count<std::remove_reference_t<T>>();
0028 
0029     ::boost::pfr::detail::for_each_field_dispatcher(
0030         value,
0031         [f = std::forward<F>(func)](auto&& t) mutable {
0032             // MSVC related workaround. Its lambdas do not capture constexprs.
0033             constexpr std::size_t fields_count_val_in_lambda
0034                 = boost::pfr::detail::fields_count<std::remove_reference_t<T>>();
0035 
0036             ::boost::pfr::detail::for_each_field_impl(
0037                 t,
0038                 std::forward<F>(f),
0039                 detail::make_index_sequence<fields_count_val_in_lambda>{},
0040                 std::is_rvalue_reference<T&&>{}
0041             );
0042         },
0043         detail::make_index_sequence<fields_count_val>{}
0044     );
0045 }
0046 
0047 }}} // namespace boost::pfr::detail
0048 
0049 
0050 #endif // BOOST_PFR_DETAIL_FOR_EACH_FIELD_HPP