// Copyright (c) 2016-2024 Antony Polukhin // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_PFR_DETAIL_CORE17_HPP #define BOOST_PFR_DETAIL_CORE17_HPP #pragma once #include #include #include #include namespace boost { namespace pfr { namespace detail { #ifndef _MSC_VER // MSVC fails to compile the following code, but compiles the structured bindings in core17_generated.hpp struct do_not_define_std_tuple_size_for_me { bool test1 = true; }; template constexpr bool do_structured_bindings_work() noexcept { // ******************************************* IN CASE OF ERROR READ THE FOLLOWING LINES IN boost/pfr/detail/core17.hpp FILE: T val{}; auto& [a] = val; // ******************************************* IN CASE OF ERROR READ THE FOLLOWING LINES IN boost/pfr/detail/core17.hpp FILE: /**************************************************************************** * * It looks like your compiler or Standard Library can not handle C++17 * structured bindings. * * Workaround: Define BOOST_PFR_USE_CPP17 to 0 * It will disable the C++17 features for Boost.PFR library. * * Sorry for the inconvenience caused. * ****************************************************************************/ return a; } static_assert( do_structured_bindings_work(), "====================> Boost.PFR: Your compiler can not handle C++17 structured bindings. Read the above comments for workarounds." ); #endif // #ifndef _MSC_VER template constexpr auto tie_as_tuple(T& val) noexcept { static_assert( !std::is_union::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_()> fields_count_tag; return boost::pfr::detail::tie_as_tuple(val, fields_count_tag{}); } template constexpr void for_each_field_dispatcher(T& t, F&& f, std::index_sequence) { static_assert( !std::is_union::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)( detail::tie_as_tuple(t) ); } }}} // namespace boost::pfr::detail #endif // BOOST_PFR_DETAIL_CORE17_HPP