#pragma once #include "adminive/adapter.hpp" #include #if __has_include() #include #define ADMINIVE_BOOST_PFR_HAS_NAMES 1 #else #define ADMINIVE_BOOST_PFR_HAS_NAMES 0 #endif #include #include #include namespace adminive { template struct Boost_Pfr_Name_Adapter; namespace detail { template constexpr std::string_view pfr_name() noexcept { #if ADMINIVE_BOOST_PFR_HAS_NAMES return boost::pfr::get_name(); #else return Boost_Pfr_Name_Adapter::template name(); #endif } template decltype(auto) pfr_base_get(Derived& value) noexcept { constexpr std::size_t count = boost::pfr::tuple_size_v; if constexpr(Index < count) { return boost::pfr::get(static_cast(value)); } else { static_assert(sizeof...(Bases) != 0); return pfr_base_get(value); } } template decltype(auto) pfr_base_get(const Derived& value) noexcept { constexpr std::size_t count = boost::pfr::tuple_size_v; if constexpr(Index < count) { return boost::pfr::get(static_cast(value)); } else { static_assert(sizeof...(Bases) != 0); return pfr_base_get(value); } } template constexpr std::string_view pfr_base_name() noexcept { constexpr std::size_t count = boost::pfr::tuple_size_v; if constexpr(Index < count) { return pfr_name(); } else { static_assert(sizeof...(Bases) != 0); return pfr_base_name(); } } } template struct Boost_Pfr_Reflection_Adapter { static constexpr std::size_t field_count = boost::pfr::tuple_size_v; template static decltype(auto) get(T& value) noexcept { return boost::pfr::get(value); } template static decltype(auto) get(const T& value) noexcept { return boost::pfr::get(value); } template static constexpr std::string_view name() noexcept { return detail::pfr_name(); } }; template struct Boost_Pfr_Base_Reflection_Adapter { static_assert(sizeof...(Bases) != 0); static_assert((std::is_base_of_v && ...)); static constexpr std::size_t field_count = (boost::pfr::tuple_size_v + ... + 0); template static decltype(auto) get(Derived& value) noexcept { static_assert(Index < field_count); return detail::pfr_base_get(value); } template static decltype(auto) get(const Derived& value) noexcept { static_assert(Index < field_count); return detail::pfr_base_get(value); } template static constexpr std::string_view name() noexcept { static_assert(Index < field_count); return detail::pfr_base_name(); } }; } #undef ADMINIVE_BOOST_PFR_HAS_NAMES