1#include "gtest/gtest.h"
29TEST(TransformSender, transform_sender_moves_once) {
31 using functor_t = std::identity;
37 const auto sndr = stdexec::then(
38 stdexec::then(stdexec::then(stdexec::just(counter_t{}), functor_t{}), functor_t{}), functor_t{});
40 ASSERT_EQ(counter_t::default_constructions, 1);
41 ASSERT_EQ(counter_t::destructions, 4);
42 ASSERT_EQ(counter_t::copy_constructions, 0);
43 ASSERT_EQ(counter_t::copy_assignments, 0);
44 ASSERT_EQ(counter_t::move_constructions, 4);
45 ASSERT_EQ(counter_t::move_assignments, 0);
51 const auto opstate = stdexec::connect(
52 stdexec::then(stdexec::then(stdexec::then(stdexec::just(counter_t{}), functor_t{}), functor_t{}), functor_t{}),
55 ASSERT_EQ(counter_t::default_constructions, 1);
56 ASSERT_EQ(counter_t::destructions, 5);
57 ASSERT_EQ(counter_t::copy_constructions, 0);
58 ASSERT_EQ(counter_t::copy_assignments, 0);
59 ASSERT_EQ(counter_t::move_constructions, 5);
60 ASSERT_EQ(counter_t::move_assignments, 0);
67 counter_t::counters counts{};
71 return counts.constructions == 1 && counts.destructions == 2 && counts.copy_constructions == 0
72 && counts.copy_assignments == 0 && counts.move_constructions == 2 && counts.move_assignments == 0;
consteval bool test_transform_sender_moves_once()
Similar to Tests::Utils::Functors::Counter, but the internal counters are not atomic.
Count construction, move/copy construction, move/copy assignment and destruction atomically on host.
A receiver that can handle all completions and does nothing with them.