gmock-actions: make OnceAction public.
So that it can be referenced in conversion operators for actions that need to know the concrete return type. PiperOrigin-RevId: 447889344 Change-Id: I643d3298bc8effd08741282a956c221f9d67d378
This commit is contained in:
committed by
Copybara-Service
parent
bda85449f4
commit
6386897feb
@@ -322,16 +322,18 @@ struct is_callable_r_impl<void_t<call_result_t<F, Args...>>, R, F, Args...>
|
||||
template <typename R, typename F, typename... Args>
|
||||
using is_callable_r = is_callable_r_impl<void, R, F, Args...>;
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// Specialized for function types below.
|
||||
template <typename F>
|
||||
class OnceAction;
|
||||
|
||||
// An action that can only be used once.
|
||||
//
|
||||
// This is what is accepted by WillOnce, which doesn't require the underlying
|
||||
// action to be copy-constructible (only move-constructible), and promises to
|
||||
// invoke it as an rvalue reference. This allows the action to work with
|
||||
// move-only types like std::move_only_function in a type-safe manner.
|
||||
// This is accepted by WillOnce, which doesn't require the underlying action to
|
||||
// be copy-constructible (only move-constructible), and promises to invoke it as
|
||||
// an rvalue reference. This allows the action to work with move-only types like
|
||||
// std::move_only_function in a type-safe manner.
|
||||
//
|
||||
// For example:
|
||||
//
|
||||
@@ -501,8 +503,6 @@ class OnceAction<Result(Args...)> final {
|
||||
std::function<Result(Args...)> function_;
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
|
||||
// When an unexpected function call is encountered, Google Mock will
|
||||
// let it return a default value if the user has specified one for its
|
||||
// return type, or if the return type has a built-in default value;
|
||||
@@ -742,7 +742,7 @@ class Action<R(Args...)> {
|
||||
|
||||
// An action can be used as a OnceAction, since it's obviously safe to call it
|
||||
// once.
|
||||
operator internal::OnceAction<F>() const { // NOLINT
|
||||
operator OnceAction<F>() const { // NOLINT
|
||||
// Return a OnceAction-compatible callable that calls Perform with the
|
||||
// arguments it is provided. We could instead just return fun_, but then
|
||||
// we'd need to handle the IsDoDefault() case separately.
|
||||
|
||||
Reference in New Issue
Block a user