Skip to content

Commit

Permalink
try to fix error
Browse files Browse the repository at this point in the history
  • Loading branch information
p00f committed Oct 19, 2024
1 parent 69263f4 commit c491353
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions include/boost/pfr/detail/fields_count.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,20 +148,34 @@ struct ubiq_rref_base_asserting {
}
};

template <class T, std::size_t I0, std::size_t... I, class /*Enable*/ = std::enable_if_t<std::is_copy_constructible<T>::value>>
template <class T, std::size_t I0, std::size_t... I, class /*Enable*/ = std::enable_if_t<std::is_copy_constructible<T>::value and !std::is_aggregate_v<T>>>
constexpr auto assert_first_not_base(std::index_sequence<I0, I...>) noexcept
-> std::add_pointer_t<decltype(T{ ubiq_lref_base_asserting<T>{}, ubiq_lref_constructor{I}... })>
{
return nullptr;
}

template <class T, std::size_t I0, std::size_t... I, class /*Enable*/ = std::enable_if_t<!std::is_copy_constructible<T>::value>>
template <class T, std::size_t I0, std::size_t... I, class /*Enable*/ = std::enable_if_t<!std::is_copy_constructible<T>::value and !std::is_aggregate_v<T>>>
constexpr auto assert_first_not_base(std::index_sequence<I0, I...>) noexcept
-> std::add_pointer_t<decltype(T{ ubiq_rref_base_asserting<T>{}, ubiq_rref_constructor{I}... })>
{
return nullptr;
}

template <class T, std::size_t I0, std::size_t... I, class /*Enable*/ = std::enable_if_t<std::is_copy_constructible<T>::value and std::is_aggregate_v<T>>>
constexpr auto assert_first_not_base(std::index_sequence<I0, I...>) noexcept
-> std::add_pointer_t<decltype(T{ ubiq_lref_base_asserting<T>{}, {ubiq_lref_constructor{I}}... })>
{
return nullptr;
}

template <class T, std::size_t I0, std::size_t... I, class /*Enable*/ = std::enable_if_t<!std::is_copy_constructible<T>::value and std::is_aggregate_v<T>>>
constexpr auto assert_first_not_base(std::index_sequence<I0, I...>) noexcept
-> std::add_pointer_t<decltype(T{ ubiq_rref_base_asserting<T>{}, {ubiq_rref_constructor{I}}... })>
{
return nullptr;
}

template <class T>
constexpr void* assert_first_not_base(std::index_sequence<>) noexcept
{
Expand All @@ -180,14 +194,22 @@ constexpr auto assert_first_not_base(long) noexcept

///////////////////// Helpers for initializable detection
// Note that these take O(N) compile time and memory!
template <class T, std::size_t... I, class /*Enable*/ = std::enable_if_t<std::is_copy_constructible<T>::value>>
template <class T, std::size_t... I, class /*Enable*/ = std::enable_if_t<std::is_copy_constructible<T>::value and !std::is_aggregate_v<T>>>
constexpr auto enable_if_initializable_helper(std::index_sequence<I...>) noexcept
-> std::add_pointer_t<decltype(T{ubiq_lref_constructor{I}...})>;

template <class T, std::size_t... I, class /*Enable*/ = std::enable_if_t<!std::is_copy_constructible<T>::value>>
template <class T, std::size_t... I, class /*Enable*/ = std::enable_if_t<!std::is_copy_constructible<T>::value and !std::is_aggregate_v<T>>>
constexpr auto enable_if_initializable_helper(std::index_sequence<I...>) noexcept
-> std::add_pointer_t<decltype(T{ubiq_rref_constructor{I}...})>;

template <class T, std::size_t... I, class /*Enable*/ = std::enable_if_t<std::is_copy_constructible<T>::value and std::is_aggregate_v<T>>>
constexpr auto enable_if_initializable_helper(std::index_sequence<I...>) noexcept
-> std::add_pointer_t<decltype(T{{ubiq_lref_constructor{I}}...})>;

template <class T, std::size_t... I, class /*Enable*/ = std::enable_if_t<!std::is_copy_constructible<T>::value and std::is_aggregate_v<T>>>
constexpr auto enable_if_initializable_helper(std::index_sequence<I...>) noexcept
-> std::add_pointer_t<decltype(T{{ubiq_rref_constructor{I}}...})>;

template <class T, std::size_t N, class U = std::size_t, class /*Enable*/ = decltype(detail::enable_if_initializable_helper<T>(detail::make_index_sequence<N>()))>
using enable_if_initializable_helper_t = U;

Expand Down

0 comments on commit c491353

Please sign in to comment.