mirror of
https://github.com/Naios/continuable.git
synced 2026-02-16 23:29:48 +08:00
Remove the 42 in_place_tag workaround
This commit is contained in:
parent
bac986a23f
commit
64f91d8ce0
@ -73,9 +73,6 @@ public:
|
|||||||
template <std::size_t ArgCount>
|
template <std::size_t ArgCount>
|
||||||
struct async_increasing_int_sync_visitor
|
struct async_increasing_int_sync_visitor
|
||||||
: async_counter_base<async_increasing_int_sync_visitor<ArgCount>> {
|
: async_counter_base<async_increasing_int_sync_visitor<ArgCount>> {
|
||||||
explicit async_increasing_int_sync_visitor(int /*dummy*/) {
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator()(async_traverse_visit_tag, std::size_t i) {
|
bool operator()(async_traverse_visit_tag, std::size_t i) {
|
||||||
EXPECT_EQ(i, this->counter());
|
EXPECT_EQ(i, this->counter());
|
||||||
++this->counter();
|
++this->counter();
|
||||||
@ -103,8 +100,6 @@ struct async_increasing_int_sync_visitor
|
|||||||
template <std::size_t ArgCount>
|
template <std::size_t ArgCount>
|
||||||
struct async_increasing_int_visitor
|
struct async_increasing_int_visitor
|
||||||
: async_counter_base<async_increasing_int_visitor<ArgCount>> {
|
: async_counter_base<async_increasing_int_visitor<ArgCount>> {
|
||||||
explicit async_increasing_int_visitor(int /*dummy*/) {
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator()(async_traverse_visit_tag, std::size_t i) const {
|
bool operator()(async_traverse_visit_tag, std::size_t i) const {
|
||||||
EXPECT_EQ(i, this->counter());
|
EXPECT_EQ(i, this->counter());
|
||||||
@ -133,19 +128,16 @@ void test_async_traversal_base(Args&&... args) {
|
|||||||
// Test that every element is traversed in the correct order
|
// Test that every element is traversed in the correct order
|
||||||
// when we detach the control flow on every visit.
|
// when we detach the control flow on every visit.
|
||||||
{
|
{
|
||||||
auto result =
|
auto result = traverse_pack_async(
|
||||||
traverse_pack_async(async_traverse_in_place_tag<
|
async_increasing_int_sync_visitor<ArgCount>{}, args...);
|
||||||
async_increasing_int_sync_visitor<ArgCount>>{},
|
|
||||||
42, args...);
|
|
||||||
EXPECT_EQ(result->counter(), ArgCount + 1U);
|
EXPECT_EQ(result->counter(), ArgCount + 1U);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that every element is traversed in the correct order
|
// Test that every element is traversed in the correct order
|
||||||
// when we detach the control flow on every visit.
|
// when we detach the control flow on every visit.
|
||||||
{
|
{
|
||||||
auto result = traverse_pack_async(
|
auto result =
|
||||||
async_traverse_in_place_tag<async_increasing_int_visitor<ArgCount>>{},
|
traverse_pack_async(async_increasing_int_visitor<ArgCount>{}, args...);
|
||||||
42, args...);
|
|
||||||
EXPECT_EQ(result->counter(), ArgCount + 1U);
|
EXPECT_EQ(result->counter(), ArgCount + 1U);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -245,7 +237,9 @@ TEST(async_traversal_mixed_traversal, visit_vector_vector_tuple) {
|
|||||||
template <std::size_t ArgCount>
|
template <std::size_t ArgCount>
|
||||||
struct async_unique_sync_visitor
|
struct async_unique_sync_visitor
|
||||||
: async_counter_base<async_unique_sync_visitor<ArgCount>> {
|
: async_counter_base<async_unique_sync_visitor<ArgCount>> {
|
||||||
explicit async_unique_sync_visitor(int /*dummy*/) {
|
|
||||||
|
explicit async_unique_sync_visitor() = default;
|
||||||
|
explicit async_unique_sync_visitor(not_accepted_tag) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator()(async_traverse_visit_tag, std::unique_ptr<std::size_t>& i) {
|
bool operator()(async_traverse_visit_tag, std::unique_ptr<std::size_t>& i) {
|
||||||
@ -276,7 +270,9 @@ struct async_unique_sync_visitor
|
|||||||
template <std::size_t ArgCount>
|
template <std::size_t ArgCount>
|
||||||
struct async_unique_visitor
|
struct async_unique_visitor
|
||||||
: async_counter_base<async_unique_visitor<ArgCount>> {
|
: async_counter_base<async_unique_visitor<ArgCount>> {
|
||||||
explicit async_unique_visitor(int /*dummy*/) {
|
|
||||||
|
explicit async_unique_visitor() = default;
|
||||||
|
explicit async_unique_visitor(not_accepted_tag) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator()(async_traverse_visit_tag,
|
bool operator()(async_traverse_visit_tag,
|
||||||
@ -310,22 +306,19 @@ constexpr auto of(T i) {
|
|||||||
|
|
||||||
TEST(async_traverse_in_place, construct_inplace_sync) {
|
TEST(async_traverse_in_place, construct_inplace_sync) {
|
||||||
auto result = traverse_pack_async(
|
auto result = traverse_pack_async(
|
||||||
async_traverse_in_place_tag<async_unique_sync_visitor<4>>{}, 42, of(0),
|
async_traverse_in_place_tag<async_unique_sync_visitor<4>>{},
|
||||||
of(1), of(2), of(3));
|
not_accepted_tag{}, of(0), of(1), of(2), of(3));
|
||||||
EXPECT_EQ(result->counter(), 5U);
|
EXPECT_EQ(result->counter(), 5U);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(async_traverse_in_place, construct_inplace_async) {
|
TEST(async_traverse_in_place, construct_inplace_async) {
|
||||||
auto result = traverse_pack_async(
|
auto result = traverse_pack_async(
|
||||||
async_traverse_in_place_tag<async_unique_visitor<4>>{}, 42, of(0), of(1),
|
async_traverse_in_place_tag<async_unique_visitor<4>>{},
|
||||||
of(2), of(3));
|
not_accepted_tag{}, of(0), of(1), of(2), of(3));
|
||||||
EXPECT_EQ(result->counter(), 5U);
|
EXPECT_EQ(result->counter(), 5U);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct invalidate_visitor : async_counter_base<invalidate_visitor> {
|
struct invalidate_visitor : async_counter_base<invalidate_visitor> {
|
||||||
explicit invalidate_visitor(int /*dummy*/) {
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator()(async_traverse_visit_tag, std::shared_ptr<int>& i) const {
|
bool operator()(async_traverse_visit_tag, std::shared_ptr<int>& i) const {
|
||||||
EXPECT_EQ(*i, 22);
|
EXPECT_EQ(*i, 22);
|
||||||
return false;
|
return false;
|
||||||
@ -353,8 +346,7 @@ struct invalidate_visitor : async_counter_base<invalidate_visitor> {
|
|||||||
TEST(async_complete_invalidation, check_whether_frame_released) {
|
TEST(async_complete_invalidation, check_whether_frame_released) {
|
||||||
auto value = std::make_shared<int>(22);
|
auto value = std::make_shared<int>(22);
|
||||||
|
|
||||||
auto frame = traverse_pack_async(
|
auto frame = traverse_pack_async(invalidate_visitor{}, value);
|
||||||
async_traverse_in_place_tag<invalidate_visitor>{}, 42, value);
|
|
||||||
|
|
||||||
EXPECT_EQ(value.use_count(), 1L);
|
EXPECT_EQ(value.use_count(), 1L);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user