Skip to content

Commit

Permalink
better balanced binary search
Browse files Browse the repository at this point in the history
  • Loading branch information
apolukhin committed Oct 15, 2024
1 parent d67495d commit f800b72
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/boost/pfr/detail/fields_count.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,15 @@ constexpr std::size_t fields_count_binary_search(detail::multi_element_range, in

template <class T, std::size_t Begin, std::size_t Last>
constexpr auto fields_count_binary_search(detail::multi_element_range, long) noexcept
-> detail::enable_if_initializable_helper_t<T, (Begin + Last) / 2 + 1>
-> detail::enable_if_initializable_helper_t<T, (Begin + Last + 1) / 2>
{
constexpr std::size_t next_v = (Begin + Last) / 2 + 1;
constexpr std::size_t next_v = (Begin + Last + 1) / 2;
return detail::fields_count_binary_search<T, next_v, Last>(detail::is_one_element_range<next_v, Last>{}, 1L);
}

template <class T, std::size_t Begin, std::size_t Last>
constexpr std::size_t fields_count_binary_search(detail::multi_element_range, int) noexcept {
constexpr std::size_t next_v = (Begin + Last) / 2;
constexpr std::size_t next_v = (Begin + Last + 1) / 2 - 1;
return detail::fields_count_binary_search<T, Begin, next_v>(detail::is_one_element_range<Begin, next_v>{}, 1L);
}

Expand Down

0 comments on commit f800b72

Please sign in to comment.