mirror of
https://github.com/boostorg/pfr.git
synced 2026-01-19 04:22:13 +00:00
Reduce instantiations count by dropping some of the rvalue overloads of internal methods; reduce detail stuff used for public functions; reduced includes count
This commit is contained in:
@@ -15,7 +15,6 @@
|
||||
#include <boost/pfr/detail/sequence_tuple.hpp>
|
||||
#include <boost/pfr/detail/cast_to_layout_compatible.hpp>
|
||||
#include <boost/pfr/detail/fields_count.hpp>
|
||||
#include <boost/pfr/detail/for_each_field_impl.hpp>
|
||||
#include <boost/pfr/detail/make_flat_tuple_of_references.hpp>
|
||||
#include <boost/pfr/detail/size_array.hpp>
|
||||
|
||||
@@ -528,24 +527,34 @@ constexpr bool is_flat_refelectable(std::index_sequence<I...>) noexcept {
|
||||
template <class T>
|
||||
auto tie_as_flat_tuple(T&& val) noexcept {
|
||||
typedef internal_tuple_with_same_alignment_t<std::remove_reference_t<T>> tuple_type;
|
||||
auto&& t = cast_to_layout_compatible<tuple_type>(std::forward<T>(val));
|
||||
return make_flat_tuple_of_references(std::forward<decltype(t)>(t), size_t_<0>{}, size_t_<tuple_type::size_v>{});
|
||||
auto& t = cast_to_layout_compatible<tuple_type>(std::forward<T>(val));
|
||||
return make_flat_tuple_of_references(t, size_t_<0>{}, size_t_<tuple_type::size_v>{});
|
||||
}
|
||||
|
||||
#if !BOOST_PFR_USE_CPP17
|
||||
|
||||
template <class T>
|
||||
auto tie_as_tuple(T&& val) noexcept {
|
||||
typedef std::remove_reference_t<T> type;
|
||||
auto tie_as_tuple(T& val) noexcept {
|
||||
typedef T type;
|
||||
static_assert(
|
||||
boost::pfr::detail::is_flat_refelectable<type>( std::make_index_sequence<fields_count<type>()>{} ),
|
||||
"Not possible in C++14 to represent that type without loosing information. Use boost::pfr::flat_ version, or change type definition, or enable C++17"
|
||||
);
|
||||
return tie_as_flat_tuple(std::forward<T>(val));
|
||||
return tie_as_flat_tuple(val);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
using tie_as_tuple_t = decltype( ::boost::pfr::detail::tie_as_tuple(std::declval<T&>()) );
|
||||
|
||||
auto tie_as_tuple(const T& val) noexcept {
|
||||
typedef T type;
|
||||
static_assert(
|
||||
boost::pfr::detail::is_flat_refelectable<type>( std::make_index_sequence<fields_count<type>()>{} ),
|
||||
"Not possible in C++14 to represent that type without loosing information. Use boost::pfr::flat_ version, or change type definition, or enable C++17"
|
||||
);
|
||||
return tie_as_flat_tuple(val);
|
||||
}
|
||||
|
||||
#endif // #if !BOOST_PFR_USE_CPP17
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -609,9 +618,9 @@ void for_each_field_in_depth(T&& t, F&& f, std::index_sequence<I0, I...>, identi
|
||||
|
||||
template <class T, class F, class... Fields>
|
||||
void for_each_field_in_depth(T&& t, F&& f, std::index_sequence<>, identity<Fields>...) {
|
||||
auto&& tuple = cast_to_layout_compatible< ::boost::pfr::detail::sequence_tuple::tuple<Fields...> >(std::forward<T>(t));
|
||||
auto& tuple = cast_to_layout_compatible< ::boost::pfr::detail::sequence_tuple::tuple<Fields...> >(std::forward<T>(t));
|
||||
std::forward<F>(f)(
|
||||
make_flat_tuple_of_references(std::forward<decltype(tuple)>(tuple), size_t_<0>{}, size_t_<sizeof...(Fields)>{})
|
||||
make_flat_tuple_of_references(tuple, size_t_<0>{}, size_t_<sizeof...(Fields)>{})
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <boost/pfr/detail/cast_to_layout_compatible.hpp>
|
||||
#include <boost/pfr/detail/fields_count.hpp>
|
||||
#include <boost/pfr/detail/flatten_tuple_recursively.hpp>
|
||||
#include <boost/pfr/detail/for_each_field_impl.hpp>
|
||||
#include <boost/pfr/detail/make_flat_tuple_of_references.hpp>
|
||||
#include <boost/pfr/detail/sequence_tuple.hpp>
|
||||
|
||||
@@ -123,10 +122,6 @@ auto tie_as_flat_tuple(T& t) {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
using tie_as_tuple_t = decltype( ::boost::pfr::detail::tie_as_tuple(std::declval<T&>()) );
|
||||
|
||||
}}} // namespace boost::pfr::detail
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
@@ -1038,9 +1038,6 @@ constexpr auto tie_as_tuple(T& val) noexcept {
|
||||
return boost::pfr::detail::tie_as_tuple(val, fields_count_tag{});
|
||||
}
|
||||
|
||||
template <class T>
|
||||
using tie_as_tuple_t = decltype( ::boost::pfr::detail::tie_as_tuple(std::declval<T&>()) );
|
||||
|
||||
}}} // namespace boost::pfr::detail
|
||||
|
||||
#endif // BOOST_PFR_DETAIL_CORE17_GENERATED_HPP
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
|
||||
namespace boost { namespace pfr { namespace detail {
|
||||
|
||||
template <std::size_t Index>
|
||||
using size_t_ = std::integral_constant<std::size_t, Index >;
|
||||
|
||||
template <class T, class F, class I, class = decltype(std::declval<F>()(std::declval<T>(), I{}))>
|
||||
void for_each_field_impl(T&& v, F&& f, I i, long) {
|
||||
std::forward<F>(f)(std::forward<T>(v), i);
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#include <boost/pfr/detail/sequence_tuple.hpp>
|
||||
#include <boost/pfr/detail/stdtuple.hpp>
|
||||
#include <boost/pfr/detail/for_each_field_impl.hpp>
|
||||
|
||||
#include <boost/pfr/precise/tuple_size.hpp>
|
||||
#if BOOST_PFR_USE_CPP17
|
||||
@@ -59,7 +60,7 @@ constexpr decltype(auto) get(T& val) noexcept {
|
||||
/// std::vector< boost::pfr::tuple_element<0, my_structure>::type > v;
|
||||
/// \endcode
|
||||
template <std::size_t I, class T>
|
||||
using tuple_element = detail::sequence_tuple::tuple_element<I, detail::tie_as_tuple_t<T> >;
|
||||
using tuple_element = detail::sequence_tuple::tuple_element<I, decltype( ::boost::pfr::detail::tie_as_tuple(std::declval<T&>()) ) >;
|
||||
|
||||
|
||||
/// \brief Type of a field with index `I` in aggregate `T`.
|
||||
@@ -89,11 +90,9 @@ using tuple_element_t = typename tuple_element<I, T>::type;
|
||||
/// \endcode
|
||||
template <class T>
|
||||
constexpr auto structure_to_tuple(const T& val) noexcept {
|
||||
typedef detail::tie_as_tuple_t<T> internal_tuple_t;
|
||||
|
||||
return detail::make_stdtuple_from_tietuple(
|
||||
detail::tie_as_tuple(val),
|
||||
std::make_index_sequence< internal_tuple_t::size_v >()
|
||||
std::make_index_sequence< tuple_size_v<T> >()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -113,11 +112,9 @@ constexpr auto structure_to_tuple(const T& val) noexcept {
|
||||
/// \endcode
|
||||
template <class T>
|
||||
constexpr auto structure_tie(T& val) noexcept {
|
||||
typedef detail::tie_as_tuple_t<T> internal_tuple_t;
|
||||
|
||||
return detail::make_stdtiedtuple_from_tietuple(
|
||||
detail::tie_as_tuple(val),
|
||||
std::make_index_sequence< internal_tuple_t::size_v >()
|
||||
std::make_index_sequence< tuple_size_v<T> >()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,11 @@
|
||||
#include <boost/pfr/detail/config.hpp>
|
||||
|
||||
#include <boost/pfr/detail/functional.hpp>
|
||||
#include <boost/pfr/flat/core.hpp>
|
||||
#if BOOST_PFR_USE_CPP17
|
||||
# include <boost/pfr/detail/core17.hpp>
|
||||
#else
|
||||
# include <boost/pfr/detail/core14.hpp>
|
||||
#endif
|
||||
|
||||
/// \file boost/pfr/functors.hpp
|
||||
/// Contains functors that are close to the Standard Library ones.
|
||||
|
||||
@@ -78,9 +78,6 @@ constexpr auto tie_as_tuple(T& val) noexcept {
|
||||
return boost::pfr::detail::tie_as_tuple(val, fields_count_tag{});
|
||||
}
|
||||
|
||||
template <class T>
|
||||
using tie_as_tuple_t = decltype( ::boost::pfr::detail::tie_as_tuple(std::declval<T&>()) );
|
||||
|
||||
}}} // namespace boost::pfr::detail
|
||||
|
||||
#endif // BOOST_PFR_DETAIL_CORE17_GENERATED_HPP
|
||||
|
||||
Reference in New Issue
Block a user