Use the work erased type directly in release builds

* So this behaviour aligns to the one used in continuable_base and promise_base.
This commit is contained in:
Denis Blank 2019-03-08 18:23:55 +01:00
parent fdd9a061c4
commit 6b4f6de10f
3 changed files with 23 additions and 15 deletions

View File

@ -89,19 +89,7 @@ using promise = promise_base<detail::erasure::callback<Args...>, //
/// callable object which is callable with a `void()` signature.
///
/// \since 4.0.0
class work : public fu2::unique_function<void()> {
public:
work() = default;
~work() = default;
work(work const&) = delete;
work(work&&) = default;
work& operator=(work const&) = delete;
work& operator=(work&&) = default;
using fu2::unique_function<void()>::unique_function;
using fu2::unique_function<void()>::operator=;
using fu2::unique_function<void()>::operator();
};
using work = detail::erasure::work;
/// \}
} // namespace cti

View File

@ -177,6 +177,26 @@ public:
}
};
#endif
using work_erasure_t = fu2::unique_function<void()>;
#ifdef CONTINUABLE_HAS_IMMEDIATE_TYPES
using work = work_erasure_t;
#else
class work : public work_erasure_t {
public:
work() = default;
~work() = default;
work(work const&) = delete;
work(work&&) = default;
work& operator=(work const&) = delete;
work& operator=(work&&) = default;
using work_erasure_t::work_erasure_t;
using work_erasure_t::operator=;
using work_erasure_t::operator();
};
#endif // CONTINUABLE_HAS_IMMEDIATE_TYPES
} // namespace erasure
} // namespace detail
} // namespace cti

View File

@ -69,7 +69,7 @@ TEST(single_erasure_test, is_constructible_from_work) {
});
ASSERT_FALSE(flag);
mywork();
std::move(mywork)();
ASSERT_TRUE(flag);
}
@ -84,6 +84,6 @@ TEST(single_erasure_test, is_assignable_from_work) {
};
ASSERT_FALSE(flag);
mywork();
std::move(mywork)();
ASSERT_TRUE(flag);
}