aboutsummaryrefslogtreecommitdiffstats
path: root/include/gtest/gtest-printers.h
diff options
context:
space:
mode:
authorzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2011-03-05 08:04:01 +0000
committerzhanyong.wan <zhanyong.wan@861a406c-534a-0410-8894-cb66d6ee9925>2011-03-05 08:04:01 +0000
commit603533a0a4dcfc2ef33051b9ae8237568a19adc4 (patch)
tree38e1e22186034693ba63f609100fcd1d4cd6e368 /include/gtest/gtest-printers.h
parent66ac4909aea5c4dc9c43e6f11518c34049c6bd5e (diff)
downloadgoogletest-603533a0a4dcfc2ef33051b9ae8237568a19adc4.tar.gz
googletest-603533a0a4dcfc2ef33051b9ae8237568a19adc4.tar.bz2
googletest-603533a0a4dcfc2ef33051b9ae8237568a19adc4.zip
Fixes compatibility with Borland C++Builder. Original patch by Josh
Kelley. Simplified by Zhanyong Wan.
Diffstat (limited to 'include/gtest/gtest-printers.h')
-rw-r--r--include/gtest/gtest-printers.h28
1 files changed, 22 insertions, 6 deletions
diff --git a/include/gtest/gtest-printers.h b/include/gtest/gtest-printers.h
index 8ed6ec13..cbb809f9 100644
--- a/include/gtest/gtest-printers.h
+++ b/include/gtest/gtest-printers.h
@@ -308,7 +308,10 @@ void DefaultPrintTo(IsNotContainer /* dummy */,
} else {
// C++ doesn't allow casting from a function pointer to any object
// pointer.
- if (ImplicitlyConvertible<T*, const void*>::value) {
+ //
+ // IsTrue() silences warnings: "Condition is always true",
+ // "unreachable code".
+ if (IsTrue(ImplicitlyConvertible<T*, const void*>::value)) {
// T is not a function type. We just call << to print p,
// relying on ADL to pick up user-defined << for their pointer
// types, if any.
@@ -736,12 +739,25 @@ struct TuplePrefixPrinter<0> {
template <typename Tuple>
static void TersePrintPrefixToStrings(const Tuple&, Strings*) {}
};
+// We have to specialize the entire TuplePrefixPrinter<> class
+// template here, even though the definition of
+// TersePrintPrefixToStrings() is the same as the generic version, as
+// Borland C++ doesn't support specializing a method.
template <>
-template <typename Tuple>
-void TuplePrefixPrinter<1>::PrintPrefixTo(const Tuple& t, ::std::ostream* os) {
- UniversalPrinter<typename ::std::tr1::tuple_element<0, Tuple>::type>::
- Print(::std::tr1::get<0>(t), os);
-}
+struct TuplePrefixPrinter<1> {
+ template <typename Tuple>
+ static void PrintPrefixTo(const Tuple& t, ::std::ostream* os) {
+ UniversalPrinter<typename ::std::tr1::tuple_element<0, Tuple>::type>::
+ Print(::std::tr1::get<0>(t), os);
+ }
+
+ template <typename Tuple>
+ static void TersePrintPrefixToStrings(const Tuple& t, Strings* strings) {
+ ::std::stringstream ss;
+ UniversalTersePrint(::std::tr1::get<0>(t), &ss);
+ strings->push_back(ss.str());
+ }
+};
// Helper function for printing a tuple. T must be instantiated with
// a tuple type.