123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- #ifndef BOOST_PFR_DETAIL_CORE17_HPP
- #define BOOST_PFR_DETAIL_CORE17_HPP
- #pragma once
- #include <boost/pfr/detail/core17_generated.hpp>
- #include <boost/pfr/detail/fields_count.hpp>
- #include <boost/pfr/detail/for_each_field_impl.hpp>
- #include <boost/pfr/detail/rvalue_t.hpp>
- namespace boost { namespace pfr { namespace detail {
- #ifndef _MSC_VER
- struct do_not_define_std_tuple_size_for_me {
- bool test1 = true;
- };
- template <class T>
- constexpr bool do_structured_bindings_work() noexcept {
- T val{};
- auto& [a] = val;
-
- return a;
- }
- static_assert(
- do_structured_bindings_work<do_not_define_std_tuple_size_for_me>(),
- "====================> Boost.PFR: Your compiler can not handle C++17 structured bindings. Read the above comments for workarounds."
- );
- #endif
- template <class T>
- constexpr auto tie_as_tuple(T& val) noexcept {
- static_assert(
- !std::is_union<T>::value,
- "====================> Boost.PFR: For safety reasons it is forbidden to reflect unions. See `Reflection of unions` section in the docs for more info."
- );
- typedef size_t_<boost::pfr::detail::fields_count<T>()> fields_count_tag;
- return boost::pfr::detail::tie_as_tuple(val, fields_count_tag{});
- }
- template <class T, class F, std::size_t... I>
- constexpr void for_each_field_dispatcher(T& t, F&& f, std::index_sequence<I...>) {
- static_assert(
- !std::is_union<T>::value,
- "====================> Boost.PFR: For safety reasons it is forbidden to reflect unions. See `Reflection of unions` section in the docs for more info."
- );
- std::forward<F>(f)(
- detail::tie_as_tuple(t)
- );
- }
- }}}
- #endif
|