Add enable_if guards for forwarding constructors.

This commit is contained in:
levlam 2021-10-29 15:05:28 +03:00
parent 05b59cc63b
commit b5060687cc
3 changed files with 6 additions and 3 deletions

View File

@ -135,7 +135,7 @@ class LambdaPromise : public PromiseInterface<ValueT> {
, on_fail_(use_ok_as_fail ? OnFail::Ok : OnFail::Fail)
, has_lambda_(true) {
}
template <class FromOkT>
template <class FromOkT, std::enable_if_t<!std::is_same<std::decay_t<FromOkT>, LambdaPromise>::value, int> = 0>
LambdaPromise(FromOkT &&ok) : LambdaPromise(std::forward<FromOkT>(ok), Ignore(), true) {
}
@ -307,7 +307,7 @@ class Promise {
}
Promise(SafePromise<T> &&other);
Promise &operator=(SafePromise<T> &&other);
template <class F>
template <class F, std::enable_if_t<!std::is_same<std::decay_t<F>, Promise>::value, int> = 0>
Promise(F &&f) : promise_(promise_interface_ptr<T>(std::forward<F>(f))) {
}

View File

@ -97,7 +97,7 @@ class LambdaEvent final : public CustomEvent {
LOG(FATAL) << "Not supported";
return nullptr;
}
template <class FromLambdaT>
template <class FromLambdaT, std::enable_if_t<!std::is_same<std::decay_t<FromLambdaT>, LambdaEvent>::value, int> = 0>
explicit LambdaEvent(FromLambdaT &&lambda) : f_(std::forward<FromLambdaT>(lambda)) {
}

View File

@ -31,6 +31,9 @@ class optional {
}
optional &operator=(const optional &other) {
if (this == &other) {
return *this;
}
if (other) {
impl_ = Result<T>(other.value());
} else {