template <typename Callable>

class StdFunctionAdaptor

Defined at line 508 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h

An adaptor that wraps a callable that is compatible with our signature and

being invoked as an rvalue reference so that it can be used as an

StdFunctionAdaptor. This throws away type safety, but that's fine because

this is only used by WillOnce, which we know calls at most once.

Once we have something like std::move_only_function from C++23, we can do

away with this.

Public Methods

template <typename F>
void StdFunctionAdaptor<Callable> (CallableTag , F && callable)

Defined at line 516 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h

template <typename... ArgRefs>
internal::call_result_t<Callable, ArgRefs...> operator() (ArgRefs &&... args)

Rather than explicitly returning Result, we return whatever the wrapped

callable returns. This allows for compatibility with existing uses like

the following, when the mocked function returns void:

EXPECT_CALL(mock_fn_, Call)

.WillOnce([

&

] {

[...]

return 0;

});

Such a callable can be turned into std::function

<void

()>. If we use an

explicit return type of Result here then it *doesn't* work with

std::function, because we'll get a "void function should not return a

value" error.

We need not worry about incompatible result types because the SFINAE on

OnceAction already checks this for us. std::is_invocable_r_v itself makes

the same allowance for void result types.

Defined at line 538 of file ../../third_party/googletest/src/googlemock/include/gmock/gmock-actions.h

Records