mirror of
https://github.com/Naios/continuable.git
synced 2026-02-16 23:29:48 +08:00
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:
parent
fdd9a061c4
commit
6b4f6de10f
@ -89,19 +89,7 @@ using promise = promise_base<detail::erasure::callback<Args...>, //
|
|||||||
/// callable object which is callable with a `void()` signature.
|
/// callable object which is callable with a `void()` signature.
|
||||||
///
|
///
|
||||||
/// \since 4.0.0
|
/// \since 4.0.0
|
||||||
class work : public fu2::unique_function<void()> {
|
using work = detail::erasure::work;
|
||||||
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();
|
|
||||||
};
|
|
||||||
/// \}
|
/// \}
|
||||||
} // namespace cti
|
} // namespace cti
|
||||||
|
|
||||||
|
|||||||
@ -177,6 +177,26 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#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 erasure
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace cti
|
} // namespace cti
|
||||||
|
|||||||
@ -69,7 +69,7 @@ TEST(single_erasure_test, is_constructible_from_work) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ASSERT_FALSE(flag);
|
ASSERT_FALSE(flag);
|
||||||
mywork();
|
std::move(mywork)();
|
||||||
ASSERT_TRUE(flag);
|
ASSERT_TRUE(flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,6 +84,6 @@ TEST(single_erasure_test, is_assignable_from_work) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ASSERT_FALSE(flag);
|
ASSERT_FALSE(flag);
|
||||||
mywork();
|
std::move(mywork)();
|
||||||
ASSERT_TRUE(flag);
|
ASSERT_TRUE(flag);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user