Add implementation for Promise type-traits functions.
This commit is contained in:
parent
4791fb6a2a
commit
f1707c8b4d
@ -184,23 +184,33 @@ class SafePromise;
|
|||||||
template <class T = Unit>
|
template <class T = Unit>
|
||||||
class Promise;
|
class Promise;
|
||||||
|
|
||||||
constexpr std::false_type is_promise_interface(...);
|
constexpr inline std::false_type is_promise_interface(...) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
constexpr std::true_type is_promise_interface(const PromiseInterface<T> &promise);
|
constexpr std::true_type is_promise_interface(const PromiseInterface<T> &promise) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
constexpr std::true_type is_promise_interface(const Promise<T> &promise);
|
constexpr std::true_type is_promise_interface(const Promise<T> &promise) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
template <class F>
|
template <class F>
|
||||||
constexpr bool is_promise_interface() {
|
constexpr bool is_promise_interface() {
|
||||||
return decltype(is_promise_interface(std::declval<F>()))::value;
|
return decltype(is_promise_interface(std::declval<F>()))::value;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr std::false_type is_promise_interface_ptr(...);
|
constexpr inline std::false_type is_promise_interface_ptr(...) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
constexpr std::true_type is_promise_interface_ptr(const unique_ptr<T> &promise);
|
constexpr std::true_type is_promise_interface_ptr(const unique_ptr<T> &promise) {
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
template <class F>
|
template <class F>
|
||||||
constexpr bool is_promise_interface_ptr() {
|
constexpr bool is_promise_interface_ptr() {
|
||||||
@ -231,6 +241,7 @@ template <class T, class F, std::enable_if_t<is_promise_interface_ptr<F>(), bool
|
|||||||
auto promise_interface_ptr(F &&f) {
|
auto promise_interface_ptr(F &&f) {
|
||||||
return std::forward<F>(f);
|
return std::forward<F>(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T, class F, std::enable_if_t<!is_promise_interface_ptr<F>(), bool> from_promise_interface = false>
|
template <class T, class F, std::enable_if_t<!is_promise_interface_ptr<F>(), bool> from_promise_interface = false>
|
||||||
auto promise_interface_ptr(F &&f) {
|
auto promise_interface_ptr(F &&f) {
|
||||||
return td::make_unique<std::decay_t<decltype(promise_interface<T>(std::forward<F>(f)))>>(
|
return td::make_unique<std::decay_t<decltype(promise_interface<T>(std::forward<F>(f)))>>(
|
||||||
|
Loading…
Reference in New Issue
Block a user