Skip to content

Commit

Permalink
feat third_party: update Boost.PFR to 1.87
Browse files Browse the repository at this point in the history
Tests: протестировано CI
commit_hash:d63ac2c1e8d07e0736c3686db5070a1b9ba09d10
  • Loading branch information
apolukhin committed Dec 12, 2024
1 parent a35d234 commit 9bc33c5
Show file tree
Hide file tree
Showing 43 changed files with 541 additions and 234 deletions.
2 changes: 1 addition & 1 deletion .mapping.json
Original file line number Diff line number Diff line change
Expand Up @@ -3812,7 +3812,6 @@
"third_party/pfr/include/boost/pfr/config.hpp":"taxi/uservices/userver/third_party/pfr/include/boost/pfr/config.hpp",
"third_party/pfr/include/boost/pfr/core.hpp":"taxi/uservices/userver/third_party/pfr/include/boost/pfr/core.hpp",
"third_party/pfr/include/boost/pfr/core_name.hpp":"taxi/uservices/userver/third_party/pfr/include/boost/pfr/core_name.hpp",
"third_party/pfr/include/boost/pfr/detail/cast_to_layout_compatible.hpp":"taxi/uservices/userver/third_party/pfr/include/boost/pfr/detail/cast_to_layout_compatible.hpp",
"third_party/pfr/include/boost/pfr/detail/config.hpp":"taxi/uservices/userver/third_party/pfr/include/boost/pfr/detail/config.hpp",
"third_party/pfr/include/boost/pfr/detail/core.hpp":"taxi/uservices/userver/third_party/pfr/include/boost/pfr/detail/core.hpp",
"third_party/pfr/include/boost/pfr/detail/core14_classic.hpp":"taxi/uservices/userver/third_party/pfr/include/boost/pfr/detail/core14_classic.hpp",
Expand All @@ -3825,6 +3824,7 @@
"third_party/pfr/include/boost/pfr/detail/detectors.hpp":"taxi/uservices/userver/third_party/pfr/include/boost/pfr/detail/detectors.hpp",
"third_party/pfr/include/boost/pfr/detail/fake_object.hpp":"taxi/uservices/userver/third_party/pfr/include/boost/pfr/detail/fake_object.hpp",
"third_party/pfr/include/boost/pfr/detail/fields_count.hpp":"taxi/uservices/userver/third_party/pfr/include/boost/pfr/detail/fields_count.hpp",
"third_party/pfr/include/boost/pfr/detail/for_each_field.hpp":"taxi/uservices/userver/third_party/pfr/include/boost/pfr/detail/for_each_field.hpp",
"third_party/pfr/include/boost/pfr/detail/for_each_field_impl.hpp":"taxi/uservices/userver/third_party/pfr/include/boost/pfr/detail/for_each_field_impl.hpp",
"third_party/pfr/include/boost/pfr/detail/functional.hpp":"taxi/uservices/userver/third_party/pfr/include/boost/pfr/detail/functional.hpp",
"third_party/pfr/include/boost/pfr/detail/io.hpp":"taxi/uservices/userver/third_party/pfr/include/boost/pfr/detail/io.hpp",
Expand Down
2 changes: 1 addition & 1 deletion third_party/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This folder contains source codes from following open source projects:

* pfr: https://github.com/boostorg/pfr/releases/tag/2.2.0 with increased via `python misc/generate_cpp17.py 200 > include/boost/pfr/detail/core17_generated.hpp` fields count limit
* pfr: https://github.com/boostorg/pfr/releases/tag/boost-1.87.0
* moodycamel: https://github.com/cameron314/concurrentqueue/releases/tag/v1.0.4
* rapidjson: https://github.com/Tencent/rapidjson/commit/083f359f5c36198accc2b9360ce1e32a333231d9 with RAPIDJSON_HAS_STDSTRING defined in rapidjson.h
* date: https://github.com/HowardHinnant/date/tree/v3.0.1
Expand Down
2 changes: 1 addition & 1 deletion third_party/pfr/include/boost/pfr.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2016-2023 Antony Polukhin
// 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)
Expand Down
12 changes: 10 additions & 2 deletions third_party/pfr/include/boost/pfr/config.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2016-2023 Antony Polukhin
// Copyright (c) 2016-2024 Antony Polukhin
// Copyright (c) 2022 Denis Mikhailov
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
Expand Down Expand Up @@ -113,7 +113,7 @@


#ifndef BOOST_PFR_CORE_NAME_PARSING
# if defined(_MSC_VER)
# if defined(_MSC_VER) && !defined(__clang__)
# define BOOST_PFR_CORE_NAME_PARSING (sizeof("auto __cdecl boost::pfr::detail::name_of_field_impl<") - 1, sizeof(">(void) noexcept") - 1, backward("->"))
# elif defined(__clang__)
# define BOOST_PFR_CORE_NAME_PARSING (sizeof("auto boost::pfr::detail::name_of_field_impl() [MsvcWorkaround = ") - 1, sizeof("}]") - 1, backward("."))
Expand Down Expand Up @@ -145,4 +145,12 @@

#undef BOOST_PFR_NOT_SUPPORTED

#ifndef BOOST_PFR_BEGIN_MODULE_EXPORT
# define BOOST_PFR_BEGIN_MODULE_EXPORT
#endif

#ifndef BOOST_PFR_END_MODULE_EXPORT
# define BOOST_PFR_END_MODULE_EXPORT
#endif

#endif // BOOST_PFR_CONFIG_HPP
29 changes: 8 additions & 21 deletions third_party/pfr/include/boost/pfr/core.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2016-2023 Antony Polukhin
// 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)
Expand All @@ -13,7 +13,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/detail/for_each_field.hpp>
#include <boost/pfr/detail/make_integer_sequence.hpp>
#include <boost/pfr/detail/tie_from_structure_tuple.hpp>

Expand All @@ -29,6 +29,8 @@

namespace boost { namespace pfr {

BOOST_PFR_BEGIN_MODULE_EXPORT

/// \brief Returns reference or const reference to a field with index `I` in \aggregate `val`.
/// Overload taking the type `U` returns reference or const reference to a field
/// with provided type `U` in \aggregate `val` if there's only one field of such type in `val`.
Expand Down Expand Up @@ -140,7 +142,7 @@ using tuple_element_t = typename tuple_element<I, T>::type;
/// assert(get<0>(t) == 10);
/// \endcode
template <class T>
constexpr auto structure_to_tuple(const T& val) noexcept {
constexpr auto structure_to_tuple(const T& val) {
return detail::make_stdtuple_from_tietuple(
detail::tie_as_tuple(val),
detail::make_index_sequence< tuple_size_v<T> >()
Expand Down Expand Up @@ -221,24 +223,7 @@ constexpr auto structure_tie(T&&, std::enable_if_t< std::is_rvalue_reference<T&&
/// \endcode
template <class T, class F>
constexpr void for_each_field(T&& value, F&& func) {
constexpr std::size_t fields_count_val = boost::pfr::detail::fields_count<std::remove_reference_t<T>>();

::boost::pfr::detail::for_each_field_dispatcher(
value,
[f = std::forward<F>(func)](auto&& t) mutable {
// MSVC related workaround. Its lambdas do not capture constexprs.
constexpr std::size_t fields_count_val_in_lambda
= boost::pfr::detail::fields_count<std::remove_reference_t<T>>();

::boost::pfr::detail::for_each_field_impl(
t,
std::forward<F>(f),
detail::make_index_sequence<fields_count_val_in_lambda>{},
std::is_rvalue_reference<T&&>{}
);
},
detail::make_index_sequence<fields_count_val>{}
);
return ::boost::pfr::detail::for_each_field(std::forward<T>(value), std::forward<F>(func));
}

/// \brief std::tie-like function that allows assigning to tied values from aggregates.
Expand All @@ -260,6 +245,8 @@ constexpr detail::tie_from_structure_tuple<Elements...> tie_from_structure(Eleme
return detail::tie_from_structure_tuple<Elements...>(args...);
}

BOOST_PFR_END_MODULE_EXPORT

}} // namespace boost::pfr

#endif // BOOST_PFR_CORE_HPP
27 changes: 26 additions & 1 deletion third_party/pfr/include/boost/pfr/core_name.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@

namespace boost { namespace pfr {

BOOST_PFR_BEGIN_MODULE_EXPORT

/// \brief Returns name of a field with index `I` in \aggregate `T`.
///
/// \b Example:
Expand Down Expand Up @@ -82,7 +84,30 @@ names_as_array() noexcept {
);
}


/// Calls `func` for each field with its name of a `value`
///
/// \param func must have one of the following signatures:
/// * any_return_type func(std::string_view name, U&& field) // field of value is perfect forwarded to function
/// * any_return_type func(std::string_view name, U&& field, std::size_t i)
/// * any_return_type func(std::string_view name, U&& value, I i) // Here I is an `std::integral_constant<size_t, field_index>`
///
/// \param value To each field of this variable will be the `func` applied.
///
/// \b Example:
/// \code
/// struct Toto { int a; char c; };
/// Toto t {5, 'c'};
/// auto print = [](std::string_view name, const auto& value){ std::cout << "Name: " << name << " Value: " << value << std::endl; };
/// for_each_field_with_name(t, print);
/// \endcode
template <class T, class F>
constexpr void for_each_field_with_name(T&& value, F&& func) {
return boost::pfr::detail::for_each_field_with_name(std::forward<T>(value), std::forward<F>(func));
}

BOOST_PFR_END_MODULE_EXPORT

}} // namespace boost::pfr

#endif // BOOST_PFR_CORE_NAME_HPP

This file was deleted.

2 changes: 1 addition & 1 deletion third_party/pfr/include/boost/pfr/detail/config.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2016-2023 Antony Polukhin
// Copyright (c) 2016-2024 Antony Polukhin
// Copyright (c) 2022 Denis Mikhailov
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
Expand Down
2 changes: 1 addition & 1 deletion third_party/pfr/include/boost/pfr/detail/core.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2016-2023 Antony Polukhin
// 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)
Expand Down
6 changes: 5 additions & 1 deletion third_party/pfr/include/boost/pfr/detail/core14_classic.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2016-2023 Antony Polukhin
// 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)
Expand All @@ -9,8 +9,12 @@

#include <boost/pfr/detail/config.hpp>

#ifdef BOOST_PFR_HAS_STD_MODULE
import std;
#else
#include <type_traits>
#include <utility> // metaprogramming stuff
#endif

#include <boost/pfr/detail/sequence_tuple.hpp>
#include <boost/pfr/detail/offset_based_getter.hpp>
Expand Down
7 changes: 5 additions & 2 deletions third_party/pfr/include/boost/pfr/detail/core14_loophole.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2017-2018 Alexandr Poltavsky, Antony Polukhin.
// Copyright (c) 2019-2023 Antony Polukhin.
// Copyright (c) 2019-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)
Expand All @@ -24,10 +24,13 @@

#include <boost/pfr/detail/config.hpp>

#ifdef BOOST_PFR_HAS_STD_MODULE
import std;
#else
#include <type_traits>
#include <utility>
#endif

#include <boost/pfr/detail/cast_to_layout_compatible.hpp> // still needed for enums
#include <boost/pfr/detail/offset_based_getter.hpp>
#include <boost/pfr/detail/fields_count.hpp>
#include <boost/pfr/detail/make_flat_tuple_of_references.hpp>
Expand Down
2 changes: 1 addition & 1 deletion third_party/pfr/include/boost/pfr/detail/core17.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2016-2023 Antony Polukhin
// 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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2016-2023 Antony Polukhin
// Copyright (c) 2016-2024 Antony Polukhin
// Copyright (c) 2023 Denis Mikhailov
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
Expand All @@ -21,7 +21,12 @@

#include <boost/pfr/detail/sequence_tuple.hpp>
#include <boost/pfr/detail/size_t_.hpp>

#ifdef BOOST_PFR_HAS_STD_MODULE
import std;
#else
#include <type_traits> // for std::conditional_t, std::is_reference
#endif

namespace boost { namespace pfr { namespace detail {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ constexpr auto tie_as_names_tuple() noexcept {
return detail::sequence_tuple::make_sequence_tuple();
}


template <class T, class F>
constexpr void for_each_field_with_name(T&& /* value */, F&& /* func */) {
static_assert(
sizeof(T) && false,
"====================> Boost.PFR: Field's names extracting functionality requires C++20."
);
}

}}} // namespace boost::pfr::detail

#endif // BOOST_PFR_DETAIL_CORE_NAME14_DISABLED_HPP
Expand Down
Loading

0 comments on commit 9bc33c5

Please sign in to comment.