From 6b4f6de10f4d9eda28cf140ed0014ace734e924b Mon Sep 17 00:00:00 2001 From: Denis Blank Date: Fri, 8 Mar 2019 18:23:55 +0100 Subject: [PATCH] Use the work erased type directly in release builds * So this behaviour aligns to the one used in continuable_base and promise_base. --- include/continuable/continuable-types.hpp | 14 +------------ include/continuable/detail/other/erasure.hpp | 20 +++++++++++++++++++ .../single/test-continuable-erasure.cpp | 4 ++-- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/include/continuable/continuable-types.hpp b/include/continuable/continuable-types.hpp index 6da0416..5a6ca6a 100644 --- a/include/continuable/continuable-types.hpp +++ b/include/continuable/continuable-types.hpp @@ -89,19 +89,7 @@ using promise = promise_base, // /// callable object which is callable with a `void()` signature. /// /// \since 4.0.0 -class work : public fu2::unique_function { -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::unique_function; - using fu2::unique_function::operator=; - using fu2::unique_function::operator(); -}; +using work = detail::erasure::work; /// \} } // namespace cti diff --git a/include/continuable/detail/other/erasure.hpp b/include/continuable/detail/other/erasure.hpp index a1bbe79..6b83bfd 100644 --- a/include/continuable/detail/other/erasure.hpp +++ b/include/continuable/detail/other/erasure.hpp @@ -177,6 +177,26 @@ public: } }; #endif + +using work_erasure_t = fu2::unique_function; + +#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 diff --git a/test/unit-test/single/test-continuable-erasure.cpp b/test/unit-test/single/test-continuable-erasure.cpp index 90c80a2..3347782 100644 --- a/test/unit-test/single/test-continuable-erasure.cpp +++ b/test/unit-test/single/test-continuable-erasure.cpp @@ -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); }