Skip to content

Commit

Permalink
inline fields_count_compiler_limitation_next into fields_count_upper_…
Browse files Browse the repository at this point in the history
…bound_loose
  • Loading branch information
apolukhin committed Oct 14, 2024
1 parent d67495d commit 0744a2a
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions include/boost/pfr/detail/fields_count.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import std;
#else
#include <climits> // CHAR_BIT
#include <cstdint> // SIZE_MAX
#include <type_traits>
#include <utility> // metaprogramming stuff
#endif
Expand Down Expand Up @@ -210,19 +209,14 @@ using is_one_element_range = std::integral_constant<bool, Begin == Last>;
using multi_element_range = std::false_type;
using one_element_range = std::true_type;

///////////////////// Fields count next expected compiler limitation
constexpr std::size_t fields_count_compiler_limitation_next(std::size_t n) noexcept {
#if defined(_MSC_VER) && (_MSC_VER <= 1920)
if (n < 1024)
return 1024;
#endif
return SIZE_MAX;
}

///////////////////// Fields count upper bound based on sizeof(T)
template <class T>
constexpr std::size_t fields_count_upper_bound_loose() noexcept {
#if defined(_MSC_VER) && (_MSC_VER <= 1920)
return (sizeof(T) * CHAR_BIT > 1024) ? 1024 : sizeof(T) * CHAR_BIT;
#else
return sizeof(T) * CHAR_BIT;
#endif
}

///////////////////// Fields count binary search.
Expand Down Expand Up @@ -272,8 +266,7 @@ template <class T, std::size_t Begin, std::size_t N>
constexpr auto fields_count_upper_bound(long, int) noexcept
-> detail::enable_if_initializable_helper_t<T, N>
{
constexpr std::size_t next_optimal = Begin + (N - Begin) * 2;
constexpr std::size_t next = detail::min_of_size_t(next_optimal, detail::fields_count_compiler_limitation_next(N));
constexpr std::size_t next = Begin + (N - Begin) * 2;
return detail::fields_count_upper_bound<T, Begin, next>(1L, 1L);
}

Expand Down

0 comments on commit 0744a2a

Please sign in to comment.