aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2009-11-24 20:23:18 +0000
committerzhanyong.wan <zhanyong.wan@8415998a-534a-0410-bf83-d39667b30386>2009-11-24 20:23:18 +0000
commit19eb9e9e3d4d5a4f0eee786d7664ca0e45137390 (patch)
treef28c91fcdbbac205124a68b4e5f9641d05288d07 /include
parente56daa7de1d85c35d1cdc252b500ab276b5c1c9c (diff)
downloadgoogletest-19eb9e9e3d4d5a4f0eee786d7664ca0e45137390.tar.gz
googletest-19eb9e9e3d4d5a4f0eee786d7664ca0e45137390.tar.bz2
googletest-19eb9e9e3d4d5a4f0eee786d7664ca0e45137390.zip
Pulls in gtest r344; improves implicit_cast (by Zhanyong Wan); makes the Python tests work on Windows (by Vlad Losev); adds run_tests.py (by Vlad Losev).
Diffstat (limited to 'include')
-rw-r--r--include/gmock/internal/gmock-port.h40
1 files changed, 12 insertions, 28 deletions
diff --git a/include/gmock/internal/gmock-port.h b/include/gmock/internal/gmock-port.h
index 1bd455b2..0cff73fe 100644
--- a/include/gmock/internal/gmock-port.h
+++ b/include/gmock/internal/gmock-port.h
@@ -81,39 +81,22 @@ namespace internal {
#error "At least Visual C++ 2003 (7.1) is required to compile Google Mock."
#endif
-// Use implicit_cast as a safe version of static_cast or const_cast
-// for upcasting in the type hierarchy (i.e. casting a pointer to Foo
-// to a pointer to SuperclassOfFoo or casting a pointer to Foo to
-// a const pointer to Foo).
-// When you use implicit_cast, the compiler checks that the cast is safe.
-// Such explicit implicit_casts are necessary in surprisingly many
-// situations where C++ demands an exact type match instead of an
-// argument type convertable to a target type.
-//
-// The From type can be inferred, so the preferred syntax for using
-// implicit_cast is the same as for static_cast etc.:
+// Use implicit_cast as a safe version of static_cast for upcasting in
+// the type hierarchy (e.g. casting a Foo* to a SuperclassOfFoo* or a
+// const Foo*). When you use implicit_cast, the compiler checks that
+// the cast is safe. Such explicit implicit_casts are necessary in
+// surprisingly many situations where C++ demands an exact type match
+// instead of an argument type convertable to a target type.
+//
+// The syntax for using implicit_cast is the same as for static_cast:
//
// implicit_cast<ToType>(expr)
//
// implicit_cast would have been part of the C++ standard library,
// 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(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
+template<typename To>
+inline To implicit_cast(To x) { return x; }
// When you upcast (that is, cast a pointer from type Foo to type
// SuperclassOfFoo), it's fine to use implicit_cast<>, since upcasts
@@ -139,7 +122,8 @@ inline To down_cast(From* f) { // so we only accept pointers
// optimized build at run-time, as it will be optimized away
// completely.
if (false) {
- implicit_cast<From*, To>(0);
+ const To to = NULL;
+ implicit_cast<From*>(to);
}
#if GTEST_HAS_RTTI