22 using namespace folly;
26 int v_, copied_, moved_;
27 Widget(
int v) : v_(v), copied_(0), moved_(0) {}
28 Widget(
const Widget& other)
29 : v_(other.v_), copied_(other.copied_ + 1), moved_(other.moved_) {}
31 : v_(other.v_), copied_(other.copied_), moved_(other.moved_ + 1) {}
32 Widget& operator=(
const Widget& ) {
33 throw std::logic_error(
"unexpected copy assignment");
35 Widget& operator=(Widget&& ) {
36 throw std::logic_error(
"unexpected move assignment");
40 struct CountedWidget : Widget {
41 static std::vector<Widget*> instances_;
43 CountedWidget(
int v) : Widget(v) {
44 instances_.push_back(
this);
46 CountedWidget(
const CountedWidget& other) : Widget(other) {
47 instances_.push_back(
this);
49 CountedWidget(CountedWidget&& other)
noexcept(false)
53 instances_.push_back(
this);
62 CountedWidget& operator=(
const CountedWidget&) =
delete;
63 CountedWidget& operator=(CountedWidget&&) =
delete;
66 auto iter = std::find(instances_.begin(), instances_.end(),
this);
68 instances_.erase(iter);
72 std::vector<Widget*> CountedWidget::instances_;
75 TEST(Then, tryConstructor) {
83 auto future = makeFuture<Widget>(23);
89 TEST(Then, tryConstRValueReference) {
90 auto future = makeFuture<Widget>(23).then([](
const Try<Widget>&&
t) {
98 TEST(Then, tryRValueReference) {
99 auto future = makeFuture<Widget>(23).then([](
Try<Widget>&&
t) {
107 TEST(Then, tryConstLValueReference) {
108 auto future = makeFuture<Widget>(23).then([](
const Try<Widget>&
t) {
117 auto future = makeFuture<Widget>(23).then([](
Try<Widget> t) {
126 auto future = makeFuture<Widget>(23).then([](
const Try<Widget> t) {
134 TEST(Then, constRValueReference) {
135 auto future = makeFuture<Widget>(23).then([](
const Widget&& w) {
144 auto future = makeFuture<Widget>(23).then([](Widget&& w) {
152 TEST(Then, constLValueReference) {
153 auto future = makeFuture<Widget>(23).then([](
const Widget& w) {
162 auto future = makeFuture<Widget>(23).then([](Widget w) {
171 auto future = makeFuture<Widget>(23).then([](
const Widget w) {
179 TEST(Then, objectAliveDuringImmediateNoParamContinuation) {
180 auto f = makeFuture<CountedWidget>(23);
184 EXPECT_EQ(CountedWidget::instances_[0]->v_, 23);
190 TEST(Then, objectAliveDuringDeferredNoParamContinuation) {
195 EXPECT_EQ(CountedWidget::instances_[0]->v_, 23);
198 p.setValue(CountedWidget{23});
202 TEST(Then, voidThenShouldPropagateExceptions) {
204 EXPECT_TRUE(makeFuture<int>(std::runtime_error(
"err")).then().hasException());
#define EXPECT_EQ(val1, val2)
constexpr detail::Map< Move > move
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
constexpr auto size(C const &c) -> decltype(c.size())
#define EXPECT_TRUE(condition)
uint64_t value(const typename LockFreeRingBuffer< T, Atom >::Cursor &rbcursor)
#define EXPECT_FALSE(condition)
TEST(SequencedExecutor, CPUThreadPoolExecutor)
Future< typename std::decay< T >::type > makeFuture(T &&t)