summaryrefslogtreecommitdiffstats
path: root/include/gtest/internal/gtest-port.h
diff options
context:
space:
mode:
authorvladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2011-01-29 16:15:40 (GMT)
committervladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2011-01-29 16:15:40 (GMT)
commita198966dd349f446f0ab065e5576db7ac1e48e63 (patch)
tree99f9c54d9f958c874a64dcb13f3994ac399e44c1 /include/gtest/internal/gtest-port.h
parent48b1315108cdba8f37394aedb8098102ca00e8b9 (diff)
downloadgoogletest-a198966dd349f446f0ab065e5576db7ac1e48e63.zip
googletest-a198966dd349f446f0ab065e5576db7ac1e48e63.tar.gz
googletest-a198966dd349f446f0ab065e5576db7ac1e48e63.tar.bz2
Renames some internal functions to avoid name clashes.
Diffstat (limited to 'include/gtest/internal/gtest-port.h')
-rw-r--r--include/gtest/internal/gtest-port.h30
1 files changed, 19 insertions, 11 deletions
diff --git a/include/gtest/internal/gtest-port.h b/include/gtest/internal/gtest-port.h
index 900a41d..be2297e 100644
--- a/include/gtest/internal/gtest-port.h
+++ b/include/gtest/internal/gtest-port.h
@@ -919,25 +919,29 @@ inline void FlushInfoLog() { fflush(NULL); }
// INTERNAL IMPLEMENTATION - DO NOT USE IN USER CODE.
//
-// Use implicit_cast as a safe version of static_cast for upcasting in
+// Use ImplicitCast_ 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
+// const Foo*). When you use ImplicitCast_, the compiler checks that
+// the cast is safe. Such explicit ImplicitCast_s 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:
+// The syntax for using ImplicitCast_ is the same as for static_cast:
//
-// implicit_cast<ToType>(expr)
+// ImplicitCast_<ToType>(expr)
//
-// implicit_cast would have been part of the C++ standard library,
+// ImplicitCast_ 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.
+//
+// This relatively ugly name is intentional. It prevents clashes with
+// similar functions users may have (e.g., implicit_cast). The internal
+// namespace alone is not enough because the function can be found by ADL.
template<typename To>
-inline To implicit_cast(To x) { return x; }
+inline To ImplicitCast_(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
+// SuperclassOfFoo), it's fine to use ImplicitCast_<>, since upcasts
// always succeed. When you downcast (that is, cast a pointer from
// type Foo to type SubclassOfFoo), static_cast<> isn't safe, because
// how do you know the pointer is really of type SubclassOfFoo? It
@@ -953,15 +957,19 @@ inline To implicit_cast(To x) { return x; }
// if (dynamic_cast<Subclass1>(foo)) HandleASubclass1Object(foo);
// if (dynamic_cast<Subclass2>(foo)) HandleASubclass2Object(foo);
// You should design the code some other way not to need this.
-template<typename To, typename From> // use like this: down_cast<T*>(foo);
-inline To down_cast(From* f) { // so we only accept pointers
+//
+// This relatively ugly name is intentional. It prevents clashes with
+// similar functions users may have (e.g., down_cast). The internal
+// namespace alone is not enough because the function can be found by ADL.
+template<typename To, typename From> // use like this: DownCast_<T*>(foo);
+inline To DownCast_(From* f) { // so we only accept pointers
// Ensures that To is a sub-type of From *. This test is here only
// for compile-time type checking, and has no overhead in an
// optimized build at run-time, as it will be optimized away
// completely.
if (false) {
const To to = NULL;
- ::testing::internal::implicit_cast<From*>(to);
+ ::testing::internal::ImplicitCast_<From*>(to);
}
#if GTEST_HAS_RTTI