diff options
author | kosak <kosak@google.com> | 2014-01-29 06:41:44 +0000 |
---|---|---|
committer | kosak <kosak@google.com> | 2014-01-29 06:41:44 +0000 |
commit | b5c81098a8ccc25e313ffca56c911200b3591ea0 (patch) | |
tree | aec9b41c3d676f2105e41bd2f78b4a2ac48b27de /include/gmock/internal/gmock-internal-utils.h | |
parent | b93d0f10d5a1bab088223a57420ef599b26a5e0f (diff) | |
download | googletest-b5c81098a8ccc25e313ffca56c911200b3591ea0.tar.gz googletest-b5c81098a8ccc25e313ffca56c911200b3591ea0.tar.bz2 googletest-b5c81098a8ccc25e313ffca56c911200b3591ea0.zip |
Support mocking methods with move-only return types.
Diffstat (limited to 'include/gmock/internal/gmock-internal-utils.h')
-rw-r--r-- | include/gmock/internal/gmock-internal-utils.h | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/include/gmock/internal/gmock-internal-utils.h b/include/gmock/internal/gmock-internal-utils.h index e12b7d7d..2f530d4e 100644 --- a/include/gmock/internal/gmock-internal-utils.h +++ b/include/gmock/internal/gmock-internal-utils.h @@ -361,17 +361,30 @@ template <typename T> struct DecayArray<T[]> { typedef const T* type; }; -// Invalid<T>() returns an invalid value of type T. This is useful +// Disable MSVC warnings for infinite recursion, since in this case the +// the recursion is unreachable. +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable:4717) +#endif + +// Invalid<T>() is usable as an expression of type T, but will terminate +// the program with an assertion failure if actually run. This is useful // when a value of type T is needed for compilation, but the statement // will not really be executed (or we don't care if the statement // crashes). template <typename T> inline T Invalid() { - return const_cast<typename remove_reference<T>::type&>( - *static_cast<volatile typename remove_reference<T>::type*>(NULL)); + Assert(false, "", -1, "Internal error: attempt to return invalid value"); + // This statement is unreachable, and would never terminate even if it + // could be reached. It is provided only to placate compiler warnings + // about missing return statements. + return Invalid<T>(); } -template <> -inline void Invalid<void>() {} + +#ifdef _MSC_VER +# pragma warning(pop) +#endif // Given a raw type (i.e. having no top-level reference or const // modifier) RawContainer that's either an STL-style container or a |