template <typename Result, typename... Args>

class OnceAction

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

An action that can only be used once.

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:

// Assume we have some API that needs to accept a unique pointer to some

// non-copyable object Foo.

void AcceptUniquePointer(std::unique_ptr

<Foo

> foo);

// We can define an action that provides a Foo to that API. Because It

// has to give away its unique pointer, it must not be called more than

// once, so its call operator is

&

&

-qualified.

struct ProvideFoo {

std::unique_ptr

<Foo

> foo;

void operator()()

&

&

{

AcceptUniquePointer(std::move(Foo));

}

};

// This action can be used with WillOnce.

EXPECT_CALL(mock, Call)

.WillOnce(ProvideFoo{std::make_unique

<Foo

>(...)});

// But a call to WillRepeatedly will fail to compile. This is correct,

// since the action cannot correctly be used repeatedly.

EXPECT_CALL(mock, Call)

.WillRepeatedly(ProvideFoo{std::make_unique

<Foo

>(...)});

A less-contrived example would be an action that returns an arbitrary type,

whose

&

&

-qualified call operator is capable of dealing with move-only types.

Public Methods

template <typename Callable, typename std::enable_if<
                                    internal::conjunction<
                                        // Teach clang on macOS that we're not talking about a
                                        // copy/move constructor here. Otherwise it gets confused
                                        // when checking the is_constructible requirement of our
                                        // traits above.
                                        internal::negation<std::is_same<
                                            OnceAction, typename std::decay<Callable>::type>>,
                                        IsDirectlyCompatible<Callable>>  //
                                    ::value,
                                    int>::type = 0>
void OnceAction<Result (Args...)> (Callable && callable)

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

template <typename Callable, typename std::enable_if<
                                    internal::conjunction<
                                        // Teach clang on macOS that we're not talking about a
                                        // copy/move constructor here. Otherwise it gets confused
                                        // when checking the is_constructible requirement of our
                                        // traits above.
                                        internal::negation<std::is_same<
                                            OnceAction, typename std::decay<Callable>::type>>,
                                        // Exclude callables for which the overload above works.
                                        // We'd rather provide the arguments if possible.
                                        internal::negation<IsDirectlyCompatible<Callable>>,
                                        IsCompatibleAfterIgnoringArguments<Callable>>::value,
                                    int>::type = 0>
void OnceAction<Result (Args...)> (Callable && callable)

Exclude callables for which the overload above works.

We'd rather provide the arguments if possible.

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

void OnceAction<Result (Args...)> (const OnceAction<Result (Args...)> & )

We are naturally copyable because we store only an std::function, but

semantically we should not be copyable.

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

OnceAction<Result (Args...)> & operator= (const OnceAction<Result (Args...)> & )

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

void OnceAction<Result (Args...)> (OnceAction<Result (Args...)> && )

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

Result Call (Args... args)

Invoke the underlying action callable with which we were constructed,

handing it the supplied arguments.

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

Records