diff options
Diffstat (limited to 'googlemock/include/gmock/gmock-more-actions.h')
-rw-r--r-- | googlemock/include/gmock/gmock-more-actions.h | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/googlemock/include/gmock/gmock-more-actions.h b/googlemock/include/gmock/gmock-more-actions.h index 148ac01..e341d47 100644 --- a/googlemock/include/gmock/gmock-more-actions.h +++ b/googlemock/include/gmock/gmock-more-actions.h @@ -526,9 +526,10 @@ GMOCK_INTERNAL_LIST_##value_params)){}) \ GMOCK_ACTION_CLASS_(name, value_params)(const GMOCK_ACTION_CLASS_( \ name, value_params) &) noexcept GMOCK_INTERNAL_DEFN_COPY_ \ - ##value_params GMOCK_ACTION_CLASS_(name, value_params)( \ - GMOCK_ACTION_CLASS_(name, value_params) &&) noexcept \ - GMOCK_INTERNAL_DEFN_COPY_##value_params template <typename F> \ + ##value_params \ + GMOCK_ACTION_CLASS_(name, value_params)(GMOCK_ACTION_CLASS_( \ + name, value_params) &&) noexcept GMOCK_INTERNAL_DEFN_COPY_ \ + ##value_params template <typename F> \ operator ::testing::Action<F>() const { \ return GMOCK_PP_IF( \ GMOCK_PP_IS_EMPTY(GMOCK_INTERNAL_COUNT_##value_params), \ @@ -582,10 +583,7 @@ namespace testing { // the macro definition, as the warnings are generated when the macro // is expanded and macro expansion cannot contain #pragma. Therefore // we suppress them here. -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable : 4100) -#endif +GTEST_DISABLE_MSC_WARNINGS_PUSH_(4100) namespace internal { @@ -594,21 +592,22 @@ namespace internal { // Overloads for other custom-callables are provided in the // internal/custom/gmock-generated-actions.h header. template <typename F, typename... Args> -auto InvokeArgument(F f, Args... args) -> decltype(f(args...)) { - return f(args...); +auto InvokeArgument(F &&f, + Args... args) -> decltype(std::forward<F>(f)(args...)) { + return std::forward<F>(f)(args...); } template <std::size_t index, typename... Params> struct InvokeArgumentAction { template <typename... Args, typename = typename std::enable_if<(index < sizeof...(Args))>::type> - auto operator()(Args&&... args) const -> decltype(internal::InvokeArgument( + auto operator()(Args &&...args) const -> decltype(internal::InvokeArgument( std::get<index>(std::forward_as_tuple(std::forward<Args>(args)...)), - std::declval<const Params&>()...)) { - internal::FlatTuple<Args&&...> args_tuple(FlatTupleConstructTag{}, - std::forward<Args>(args)...); - return params.Apply([&](const Params&... unpacked_params) { - auto&& callable = args_tuple.template Get<index>(); + std::declval<const Params &>()...)) { + internal::FlatTuple<Args &&...> args_tuple(FlatTupleConstructTag{}, + std::forward<Args>(args)...); + return params.Apply([&](const Params &...unpacked_params) { + auto &&callable = std::move(args_tuple.template Get<index>()); return internal::InvokeArgument( std::forward<decltype(callable)>(callable), unpacked_params...); }); @@ -648,14 +647,12 @@ struct InvokeArgumentAction { // later. template <std::size_t index, typename... Params> internal::InvokeArgumentAction<index, typename std::decay<Params>::type...> -InvokeArgument(Params&&... params) { +InvokeArgument(Params &&...params) { return {internal::FlatTuple<typename std::decay<Params>::type...>( internal::FlatTupleConstructTag{}, std::forward<Params>(params)...)}; } -#ifdef _MSC_VER -#pragma warning(pop) -#endif +GTEST_DISABLE_MSC_WARNINGS_POP_() // 4100 } // namespace testing |