2
0
mirror of https://github.com/boostorg/pfr.git synced 2026-01-19 04:22:13 +00:00

Update core14_classic.hpp

This commit is contained in:
Denis Mikhailov
2022-07-20 15:27:28 +06:00
committed by GitHub
parent 8a8b5bc8d3
commit ba10f9bc94

View File

@@ -599,13 +599,20 @@ struct ubiq_constructor_constexpr_copy {
/////////////////////
template <class T, std::size_t... I>
struct is_constexpr_aggregate_initializable { // TODO: try to fix it
template <T = T{ ubiq_constructor_constexpr_copy{I}... } >
struct is_constexpr_aggregate_initializable {
template<class T2, std::size_t... I2>
static constexpr void* constexpr_aggregate_initializer() {
const auto t = T2{ ubiq_constructor_constexpr_copy{I2}... };
(void)t;
return nullptr;
}
template <void* = constexpr_aggregate_initializer<T, I...>() >
static std::true_type test(long) noexcept;
static std::false_type test(...) noexcept;
static constexpr decltype( test(0) ) value{};
static constexpr bool value = decltype(test(0)){};
};
@@ -676,16 +683,7 @@ void for_each_field_dispatcher(T& t, F&& f, std::index_sequence<I...>) {
!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."
);
/// Compile time error at this point means that you have called `for_each_field` or some other non-flat function or operator for a
/// type that is not constexpr aggregate initializable.
///
/// Make sure that all the fields of your type have constexpr default construtors and trivial destructors.
/// Or compile in C++17 mode.
constexpr T tmp{ ubiq_constructor_constexpr_copy{I}... };
(void)tmp;
//static_assert(is_constexpr_aggregate_initializable<T, I...>::value, "====================> Boost.PFR: T must be a constexpr initializable type");
static_assert(is_constexpr_aggregate_initializable<T, I...>::value, "====================> Boost.PFR: T must be a constexpr initializable type");
constexpr bool is_flat_refelectable_val = detail::is_flat_refelectable<T>( std::index_sequence<I...>{} );
detail::for_each_field_dispatcher_1(