File indexing completed on 2025-01-18 09:43:32
0001
0002
0003
0004
0005
0006
0007 #ifndef BOOST_PFR_DETAIL_CORE17_HPP
0008 #define BOOST_PFR_DETAIL_CORE17_HPP
0009 #pragma once
0010
0011 #include <boost/pfr/detail/core17_generated.hpp>
0012 #include <boost/pfr/detail/fields_count.hpp>
0013 #include <boost/pfr/detail/for_each_field_impl.hpp>
0014 #include <boost/pfr/detail/rvalue_t.hpp>
0015
0016 namespace boost { namespace pfr { namespace detail {
0017
0018 #ifndef _MSC_VER
0019 struct do_not_define_std_tuple_size_for_me {
0020 bool test1 = true;
0021 };
0022
0023 template <class T>
0024 constexpr bool do_structured_bindings_work() noexcept {
0025 T val{};
0026 auto& [a] = val;
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 return a;
0041 }
0042
0043 static_assert(
0044 do_structured_bindings_work<do_not_define_std_tuple_size_for_me>(),
0045 "====================> Boost.PFR: Your compiler can not handle C++17 structured bindings. Read the above comments for workarounds."
0046 );
0047 #endif
0048
0049 template <class T>
0050 constexpr auto tie_as_tuple(T& val) noexcept {
0051 static_assert(
0052 !std::is_union<T>::value,
0053 "====================> Boost.PFR: For safety reasons it is forbidden to reflect unions. See `Reflection of unions` section in the docs for more info."
0054 );
0055 typedef size_t_<boost::pfr::detail::fields_count<T>()> fields_count_tag;
0056 return boost::pfr::detail::tie_as_tuple(val, fields_count_tag{});
0057 }
0058
0059 template <class T, class F, std::size_t... I>
0060 constexpr void for_each_field_dispatcher(T& t, F&& f, std::index_sequence<I...>) {
0061 static_assert(
0062 !std::is_union<T>::value,
0063 "====================> Boost.PFR: For safety reasons it is forbidden to reflect unions. See `Reflection of unions` section in the docs for more info."
0064 );
0065 std::forward<F>(f)(
0066 detail::tie_as_tuple(t)
0067 );
0068 }
0069
0070 }}}
0071
0072 #endif