Skip to content

Commit

Permalink
Add missing lvalue-qualified overloads for operator().
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskohlhoff committed Jul 14, 2021
1 parent 7d59c35 commit 0935d56
Showing 1 changed file with 59 additions and 1 deletion.
60 changes: 59 additions & 1 deletion asio/include/asio/experimental/deferred.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ struct deferred_noop
void operator()(ASIO_MOVE_ARG(Args)...) ASIO_RVALUE_REF_QUAL
{
}

#if defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS)
/// No effect.
template <typename... Args>
decltype(auto) operator()(ASIO_MOVE_ARG(Args)...) const &
{
}
#endif // defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS)
};

#if !defined(GENERATING_DOCUMENTATION)
Expand Down Expand Up @@ -135,6 +143,16 @@ class deferred_function
ASIO_MOVE_CAST(Args)(args)...);
}

#if defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS)
template <typename... Args>
decltype(auto) operator()(
ASIO_MOVE_ARG(Args)... args) const &
{
return deferred_function(*this)(
ASIO_MOVE_CAST(Args)(args)...);
}
#endif // defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS)

//private:
Function function_;
};
Expand Down Expand Up @@ -192,6 +210,16 @@ class ASIO_NODISCARD deferred_values
ASIO_MOVE_CAST(CompletionToken)(token),
std::index_sequence_for<Values...>());
}

#if defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS)
template <ASIO_COMPLETION_TOKEN_FOR(void(Values...)) CompletionToken>
decltype(auto) operator()(
ASIO_MOVE_ARG(CompletionToken) token) const &
{
return deferred_values(*this)(
ASIO_MOVE_CAST(CompletionToken)(token));
}
#endif // defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS)
};

#if !defined(GENERATING_DOCUMENTATION)
Expand Down Expand Up @@ -241,6 +269,16 @@ class ASIO_NODISCARD deferred_async_operation
ASIO_MOVE_CAST(CompletionToken)(token),
std::index_sequence_for<InitArgs...>());
}

#if defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS)
template <ASIO_COMPLETION_TOKEN_FOR(Signature) CompletionToken>
decltype(auto) operator()(
ASIO_MOVE_ARG(CompletionToken) token) const &
{
return deferred_async_operation(*this)(
ASIO_MOVE_CAST(CompletionToken)(token));
}
#endif // defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS)
};

#if !defined(GENERATING_DOCUMENTATION)
Expand Down Expand Up @@ -270,13 +308,24 @@ class ASIO_NODISCARD deferred_sequence
}

template <ASIO_COMPLETION_TOKEN_FOR(signature) CompletionToken>
decltype(auto) operator()(ASIO_MOVE_ARG(CompletionToken) token)
decltype(auto) operator()(
ASIO_MOVE_ARG(CompletionToken) token) ASIO_RVALUE_REF_QUAL
{
return asio::async_initiate<CompletionToken, signature>(
initiate(), token, ASIO_MOVE_OR_LVALUE(Head)(head_),
ASIO_MOVE_OR_LVALUE(Tail)(tail_));
}

#if defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS)
template <ASIO_COMPLETION_TOKEN_FOR(signature) CompletionToken>
decltype(auto) operator()(
ASIO_MOVE_ARG(CompletionToken) token) const &
{
return deferred_sequence(*this)(
ASIO_MOVE_CAST(CompletionToken)(token));
}
#endif // defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS)

private:
struct initiate
{
Expand Down Expand Up @@ -335,6 +384,15 @@ class ASIO_NODISCARD deferred_conditional
}
}

#if defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS)
template <typename... Args>
auto operator()(ASIO_MOVE_ARG(Args)... args) const &
{
return deferred_conditional(*this)(
ASIO_MOVE_CAST(Args)(args)...);
}
#endif // defined(ASIO_HAS_REF_QUALIFIED_FUNCTIONS)

/// Set the true branch of the conditional.
template <typename T>
deferred_conditional<T, OnFalse> then(T on_true,
Expand Down

0 comments on commit 0935d56

Please sign in to comment.