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

Fixes for C++20

This commit is contained in:
Antony Polukhin
2020-07-06 18:07:40 +03:00
parent d6e44dde8f
commit c3ccb7a525
3 changed files with 12 additions and 28 deletions

View File

@@ -44,6 +44,16 @@ static_assert(
);
#endif // #ifndef _MSC_VER
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>
void for_each_field_dispatcher(T& t, F&& f, std::index_sequence<I...>) {
static_assert(

View File

@@ -14,13 +14,12 @@
#pragma once
#include <boost/pfr/detail/config.hpp>
#include <boost/pfr/detail/size_t_.hpp>
#if !BOOST_PFR_USE_CPP17
# error C++17 is required for this header.
#endif
#include <boost/pfr/detail/sequence_tuple.hpp>
#include <boost/pfr/detail/size_t_.hpp>
#include <boost/pfr/detail/fields_count.hpp>
namespace boost { namespace pfr { namespace detail {
@@ -1026,18 +1025,6 @@ constexpr auto tie_as_tuple(T& val, size_t_<100>) noexcept {
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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_<fields_count<T>()> fields_count_tag;
return boost::pfr::detail::tie_as_tuple(val, fields_count_tag{});
}
}}} // namespace boost::pfr::detail
#endif // BOOST_PFR_DETAIL_CORE17_GENERATED_HPP

View File

@@ -29,13 +29,12 @@ PROLOGUE = """// Copyright (c) 2016-2020 Antony Polukhin
#pragma once
#include <boost/pfr/detail/config.hpp>
#include <boost/pfr/detail/size_t_.hpp>
#if !BOOST_PFR_USE_CPP17
# error C++17 is required for this header.
#endif
#include <boost/pfr/detail/sequence_tuple.hpp>
#include <boost/pfr/detail/size_t_.hpp>
#include <boost/pfr/detail/fields_count.hpp>
namespace boost { namespace pfr { namespace detail {
@@ -66,18 +65,6 @@ constexpr auto tie_as_tuple(T& val, size_t_<1>, std::enable_if_t<!std::is_class<
############################################################################################################################
EPILOGUE = """
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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_<fields_count<T>()> fields_count_tag;
return boost::pfr::detail::tie_as_tuple(val, fields_count_tag{});
}
}}} // namespace boost::pfr::detail
#endif // BOOST_PFR_DETAIL_CORE17_GENERATED_HPP