diff options
author | vladlosev <vladlosev@8415998a-534a-0410-bf83-d39667b30386> | 2009-11-18 00:12:05 +0000 |
---|---|---|
committer | vladlosev <vladlosev@8415998a-534a-0410-bf83-d39667b30386> | 2009-11-18 00:12:05 +0000 |
commit | 201ac161919b2c7f464b4f966a4f1a1a2379c486 (patch) | |
tree | 295fb41b053b7332b9f49c90535d668b33668313 /include/gmock/internal/gmock-port.h | |
parent | a070cbd91c2a8bfe7caed64e31387312a1c5df5a (diff) | |
download | googletest-201ac161919b2c7f464b4f966a4f1a1a2379c486.tar.gz googletest-201ac161919b2c7f464b4f966a4f1a1a2379c486.tar.bz2 googletest-201ac161919b2c7f464b4f966a4f1a1a2379c486.zip |
Enables gmock's implicit_cast to work with source types that have a non-const conversion operator (by Zhanyong Wan).
Diffstat (limited to 'include/gmock/internal/gmock-port.h')
-rw-r--r-- | include/gmock/internal/gmock-port.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/include/gmock/internal/gmock-port.h b/include/gmock/internal/gmock-port.h index 0263491e..1bd455b2 100644 --- a/include/gmock/internal/gmock-port.h +++ b/include/gmock/internal/gmock-port.h @@ -99,9 +99,21 @@ namespace internal { // but the proposal was submitted too late. It will probably make // its way into the language in the future. template<typename To, typename From> -inline To implicit_cast(From const &f) { +inline To implicit_cast(const From& f) { return f; } +// Nokia's compiler can't tell which version of implicit_cast to use when +// the source is a const, causing the compilation to fail with the error +// "ambiguous access to overloaded function". So we only support the const +// version of implicit_cast on Symbian. +#if !GTEST_OS_SYMBIAN +// This overload is needed in case the From type has a non-const type +// conversion operator to type To. +template<typename To, typename From> +inline To implicit_cast(From& f) { + return f; +} +#endif // When you upcast (that is, cast a pointer from type Foo to type // SuperclassOfFoo), it's fine to use implicit_cast<>, since upcasts |