diff options
author | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2009-07-20 21:16:35 +0000 |
---|---|---|
committer | zhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386> | 2009-07-20 21:16:35 +0000 |
commit | 387bdd551d4a88383246841ac3f70324b8d42772 (patch) | |
tree | c7dd4842fadddd0671feb380be95eeba6ca6070a /include/gmock/gmock-generated-actions.h | |
parent | b5937dab6969ca4b1d8304cc8939ce16c1fb62e5 (diff) | |
download | googletest-387bdd551d4a88383246841ac3f70324b8d42772.tar.gz googletest-387bdd551d4a88383246841ac3f70324b8d42772.tar.bz2 googletest-387bdd551d4a88383246841ac3f70324b8d42772.zip |
Makes ByRef(x) printable as a reference to x.
Diffstat (limited to 'include/gmock/gmock-generated-actions.h')
-rw-r--r-- | include/gmock/gmock-generated-actions.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/gmock/gmock-generated-actions.h b/include/gmock/gmock-generated-actions.h index fa02faaa..c0097175 100644 --- a/include/gmock/gmock-generated-actions.h +++ b/include/gmock/gmock-generated-actions.h @@ -39,6 +39,7 @@ #define GMOCK_INCLUDE_GMOCK_GMOCK_GENERATED_ACTIONS_H_ #include <gmock/gmock-actions.h> +#include <gmock/gmock-printers.h> #include <gmock/internal/gmock-port.h> namespace testing { @@ -321,6 +322,9 @@ class InvokeMethodAction { const MethodPtr method_ptr_; }; +// TODO(wan@google.com): ReferenceWrapper and ByRef() are neither +// action-specific nor variadic. Move them to a better place. + // A ReferenceWrapper<T> object represents a reference to type T, // which can be either const or not. It can be explicitly converted // from, and implicitly converted to, a T&. Unlike a reference, @@ -341,6 +345,13 @@ class ReferenceWrapper { T* pointer_; }; +// Allows the expression ByRef(x) to be printed as a reference to x. +template <typename T> +void PrintTo(const ReferenceWrapper<T>& ref, ::std::ostream* os) { + T& value = ref; + UniversalPrinter<T&>::Print(value, os); +} + // CallableHelper has static methods for invoking "callables", // i.e. function pointers and functors. It uses overloading to // provide a uniform interface for invoking different kinds of |