mirror of
https://github.com/Naios/continuable.git
synced 2026-02-12 21:29:48 +08:00
Fix the mapping when empty spreads are involved
This commit is contained in:
parent
860ae778bc
commit
c4cdb3c3b0
@ -461,11 +461,11 @@ using std::disjunction;
|
|||||||
namespace detail {
|
namespace detail {
|
||||||
/// Declares a C++14 polyfill for C++17 std::disjunction.
|
/// Declares a C++14 polyfill for C++17 std::disjunction.
|
||||||
template <typename Args, typename = void_t<>>
|
template <typename Args, typename = void_t<>>
|
||||||
struct disjunction_impl : std::common_type<std::false_type> {};
|
struct disjunction_impl : std::common_type<std::true_type> {};
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
struct disjunction_impl<identity<Args...>,
|
struct disjunction_impl<identity<Args...>,
|
||||||
void_t<std::enable_if_t<bool(Args::value)>...>>
|
void_t<std::enable_if_t<!bool(Args::value)>...>>
|
||||||
: std::common_type<std::true_type> {};
|
: std::common_type<std::false_type> {};
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
|
|||||||
@ -770,3 +770,31 @@ TEST(traversal_prio, prioritize_mapping) {
|
|||||||
|
|
||||||
EXPECT_EQ(res, 4);
|
EXPECT_EQ(res, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct flat_tupelizing_tag1 {};
|
||||||
|
struct flat_tupelizing_tag2 {};
|
||||||
|
|
||||||
|
struct flat_tupelizing_mapper {
|
||||||
|
auto operator()(flat_tupelizing_tag1) {
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
auto operator()(flat_tupelizing_tag2) {
|
||||||
|
return spread_this();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST(traversal_regressions, flat_tupelizing) {
|
||||||
|
{
|
||||||
|
std::tuple<int> result =
|
||||||
|
map_pack(flat_tupelizing_mapper{}, flat_tupelizing_tag1{},
|
||||||
|
flat_tupelizing_tag2{});
|
||||||
|
EXPECT_EQ(std::get<0>(result), 7);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
std::tuple<int> result = map_pack(
|
||||||
|
flat_tupelizing_mapper{},
|
||||||
|
std::make_tuple(flat_tupelizing_tag1{}, flat_tupelizing_tag2{}));
|
||||||
|
EXPECT_EQ(std::get<0>(result), 7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user