diff options
Diffstat (limited to 'googlemock/include/gmock/gmock-spec-builders.h')
-rw-r--r-- | googlemock/include/gmock/gmock-spec-builders.h | 50 |
1 files changed, 24 insertions, 26 deletions
diff --git a/googlemock/include/gmock/gmock-spec-builders.h b/googlemock/include/gmock/gmock-spec-builders.h index c8e864c..849bc92 100644 --- a/googlemock/include/gmock/gmock-spec-builders.h +++ b/googlemock/include/gmock/gmock-spec-builders.h @@ -65,6 +65,7 @@ #include <set> #include <sstream> #include <string> +#include <utility> #include <vector> #include "gmock/gmock-actions.h" #include "gmock/gmock-cardinalities.h" @@ -1184,9 +1185,10 @@ class TypedExpectation : public ExpectationBase { Log(kWarning, ss.str(), 1); } - return count <= action_count ? - *static_cast<const Action<F>*>(untyped_actions_[count - 1]) : - repeated_action(); + return count <= action_count + ? *static_cast<const Action<F>*>( + untyped_actions_[static_cast<size_t>(count - 1)]) + : repeated_action(); } // Given the arguments of a mock function call, if the call will @@ -1319,13 +1321,13 @@ class ReferenceOrValueWrapper { public: // Constructs a wrapper from the given value/reference. explicit ReferenceOrValueWrapper(T value) - : value_(::testing::internal::move(value)) { + : value_(std::move(value)) { } // Unwraps and returns the underlying value/reference, exactly as // originally passed. The behavior of calling this more than once on // the same object is unspecified. - T Unwrap() { return ::testing::internal::move(value_); } + T Unwrap() { return std::move(value_); } // Provides nondestructive access to the underlying value/reference. // Always returns a const reference (more precisely, @@ -1400,27 +1402,26 @@ class ActionResultHolder : public UntypedActionResultHolderBase { template <typename F> static ActionResultHolder* PerformDefaultAction( const FunctionMockerBase<F>* func_mocker, - typename RvalueRef<typename Function<F>::ArgumentTuple>::type args, + typename Function<F>::ArgumentTuple&& args, const std::string& call_description) { return new ActionResultHolder(Wrapper(func_mocker->PerformDefaultAction( - internal::move(args), call_description))); + std::move(args), call_description))); } // Performs the given action and returns the result in a new-ed // ActionResultHolder. template <typename F> static ActionResultHolder* PerformAction( - const Action<F>& action, - typename RvalueRef<typename Function<F>::ArgumentTuple>::type args) { + const Action<F>& action, typename Function<F>::ArgumentTuple&& args) { return new ActionResultHolder( - Wrapper(action.Perform(internal::move(args)))); + Wrapper(action.Perform(std::move(args)))); } private: typedef ReferenceOrValueWrapper<T> Wrapper; explicit ActionResultHolder(Wrapper result) - : result_(::testing::internal::move(result)) { + : result_(std::move(result)) { } Wrapper result_; @@ -1441,9 +1442,9 @@ class ActionResultHolder<void> : public UntypedActionResultHolderBase { template <typename F> static ActionResultHolder* PerformDefaultAction( const FunctionMockerBase<F>* func_mocker, - typename RvalueRef<typename Function<F>::ArgumentTuple>::type args, + typename Function<F>::ArgumentTuple&& args, const std::string& call_description) { - func_mocker->PerformDefaultAction(internal::move(args), call_description); + func_mocker->PerformDefaultAction(std::move(args), call_description); return new ActionResultHolder; } @@ -1451,9 +1452,8 @@ class ActionResultHolder<void> : public UntypedActionResultHolderBase { // ActionResultHolder*. template <typename F> static ActionResultHolder* PerformAction( - const Action<F>& action, - typename RvalueRef<typename Function<F>::ArgumentTuple>::type args) { - action.Perform(internal::move(args)); + const Action<F>& action, typename Function<F>::ArgumentTuple&& args) { + action.Perform(std::move(args)); return new ActionResultHolder; } @@ -1508,13 +1508,12 @@ class FunctionMockerBase : public UntypedFunctionMockerBase { // mutable state of this object, and thus can be called concurrently // without locking. // L = * - Result PerformDefaultAction( - typename RvalueRef<typename Function<F>::ArgumentTuple>::type args, - const std::string& call_description) const { + Result PerformDefaultAction(typename Function<F>::ArgumentTuple&& args, + const std::string& call_description) const { const OnCallSpec<F>* const spec = this->FindOnCallSpec(args); if (spec != nullptr) { - return spec->GetAction().Perform(internal::move(args)); + return spec->GetAction().Perform(std::move(args)); } const std::string message = call_description + @@ -1539,7 +1538,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase { void* untyped_args, // must point to an ArgumentTuple const std::string& call_description) const { ArgumentTuple* args = static_cast<ArgumentTuple*>(untyped_args); - return ResultHolder::PerformDefaultAction(this, internal::move(*args), + return ResultHolder::PerformDefaultAction(this, std::move(*args), call_description); } @@ -1553,7 +1552,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase { // action deletes the mock object (and thus deletes itself). const Action<F> action = *static_cast<const Action<F>*>(untyped_action); ArgumentTuple* args = static_cast<ArgumentTuple*>(untyped_args); - return ResultHolder::PerformAction(action, internal::move(*args)); + return ResultHolder::PerformAction(action, std::move(*args)); } // Implements UntypedFunctionMockerBase::ClearDefaultActionsLocked(): @@ -1593,8 +1592,7 @@ class FunctionMockerBase : public UntypedFunctionMockerBase { // Returns the result of invoking this mock function with the given // arguments. This function can be safely called from multiple // threads concurrently. - Result InvokeWith( - typename RvalueRef<typename Function<F>::ArgumentTuple>::type args) + Result InvokeWith(typename Function<F>::ArgumentTuple&& args) GTEST_LOCK_EXCLUDED_(g_gmock_mutex) { // const_cast is required since in C++98 we still pass ArgumentTuple around // by const& instead of rvalue reference. @@ -1762,12 +1760,12 @@ class FunctionMockerBase : public UntypedFunctionMockerBase { ::std::ostream* why) const GTEST_EXCLUSIVE_LOCK_REQUIRED_(g_gmock_mutex) { g_gmock_mutex.AssertHeld(); - const int count = static_cast<int>(untyped_expectations_.size()); + const size_t count = untyped_expectations_.size(); *why << "Google Mock tried the following " << count << " " << (count == 1 ? "expectation, but it didn't match" : "expectations, but none matched") << ":\n"; - for (int i = 0; i < count; i++) { + for (size_t i = 0; i < count; i++) { TypedExpectation<F>* const expectation = static_cast<TypedExpectation<F>*>(untyped_expectations_[i].get()); *why << "\n"; |