diff options
author | kosak <kosak@google.com> | 2014-01-13 22:28:01 +0000 |
---|---|---|
committer | kosak <kosak@google.com> | 2014-01-13 22:28:01 +0000 |
commit | b93d0f10d5a1bab088223a57420ef599b26a5e0f (patch) | |
tree | 87ef35fe99962b8de504902528d8be44a58b1450 /include | |
parent | 04ce8521f481d857db1aa00a206278759b9b0381 (diff) | |
download | googletest-b93d0f10d5a1bab088223a57420ef599b26a5e0f.tar.gz googletest-b93d0f10d5a1bab088223a57420ef599b26a5e0f.tar.bz2 googletest-b93d0f10d5a1bab088223a57420ef599b26a5e0f.zip |
Make Google Mock build cleanly on Visual Studio 2010, 2012, 2013.
Diffstat (limited to 'include')
-rw-r--r-- | include/gmock/gmock-more-actions.h | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/include/gmock/gmock-more-actions.h b/include/gmock/gmock-more-actions.h index fc5e5ca8..73b9deae 100644 --- a/include/gmock/gmock-more-actions.h +++ b/include/gmock/gmock-more-actions.h @@ -87,6 +87,20 @@ class InvokeMethodAction { GTEST_DISALLOW_ASSIGN_(InvokeMethodAction); }; +// An internal replacement for std::copy which mimics its behavior. This is +// necessary because Visual Studio deprecates ::std::copy, issuing warning 4996. +// However Visual Studio 2010 and later do not honor #pragmas which disable that +// warning. +template<typename InputIterator, typename OutputIterator> +inline OutputIterator CopyElements(InputIterator first, + InputIterator last, + OutputIterator output) { + for (; first != last; ++first, ++output) { + *output = *first; + } + return output; +} + } // namespace internal // Various overloads for Invoke(). @@ -185,15 +199,11 @@ ACTION_TEMPLATE(SetArgReferee, ACTION_TEMPLATE(SetArrayArgument, HAS_1_TEMPLATE_PARAMS(int, k), AND_2_VALUE_PARAMS(first, last)) { - // Microsoft compiler deprecates ::std::copy, so we want to suppress warning - // 4996 (Function call with parameters that may be unsafe) there. + // Visual Studio deprecates ::std::copy, so we use our own copy in that case. #ifdef _MSC_VER -# pragma warning(push) // Saves the current warning state. -# pragma warning(disable:4996) // Temporarily disables warning 4996. -#endif + internal::CopyElements(first, last, ::std::tr1::get<k>(args)); +#else ::std::copy(first, last, ::std::tr1::get<k>(args)); -#ifdef _MSC_VER -# pragma warning(pop) // Restores the warning state. #endif } |