From d766e6d0d70bd19768bc1d5cd8586c4bbd2c1dc0 Mon Sep 17 00:00:00 2001 From: sfgeller18 Date: Mon, 4 Nov 2024 21:03:59 -0800 Subject: [PATCH] Changed Template I for compatibility w/ (see mod_README.md) --- googletest/include/gtest/gtest-printers.h | 20 +++++++------- .../include/gtest/internal/gtest-internal.h | 26 +++++++++---------- .../include/gtest/internal/gtest-param-util.h | 26 +++++++++---------- mod_README.md | 14 ++++++++++ 4 files changed, 50 insertions(+), 36 deletions(-) create mode 100644 mod_README.md diff --git a/googletest/include/gtest/gtest-printers.h b/googletest/include/gtest/gtest-printers.h index b2822bcd..403a18ac 100644 --- a/googletest/include/gtest/gtest-printers.h +++ b/googletest/include/gtest/gtest-printers.h @@ -788,17 +788,17 @@ template void PrintTupleTo(const T&, std::integral_constant, ::std::ostream*) {} -template -void PrintTupleTo(const T& t, std::integral_constant, +template +void PrintTupleTo(const T& t, std::integral_constant, ::std::ostream* os) { - PrintTupleTo(t, std::integral_constant(), os); + PrintTupleTo(t, std::integral_constant(), os); GTEST_INTENTIONAL_CONST_COND_PUSH_() - if (I > 1) { + if (__I > 1) { GTEST_INTENTIONAL_CONST_COND_POP_() *os << ", "; } - UniversalPrinter::type>::Print( - std::get(t), os); + UniversalPrinter::type>::Print( + std::get<__I - 1>(t), os); } template @@ -1155,14 +1155,14 @@ typedef ::std::vector<::std::string> Strings; template void TersePrintPrefixToStrings(const Tuple&, std::integral_constant, Strings*) {} -template +template void TersePrintPrefixToStrings(const Tuple& t, - std::integral_constant, + std::integral_constant, Strings* strings) { - TersePrintPrefixToStrings(t, std::integral_constant(), + TersePrintPrefixToStrings(t, std::integral_constant(), strings); ::std::stringstream ss; - UniversalTersePrint(std::get(t), &ss); + UniversalTersePrint(std::get<__I - 1>(t), &ss); strings->push_back(ss.str()); } diff --git a/googletest/include/gtest/internal/gtest-internal.h b/googletest/include/gtest/internal/gtest-internal.h index 7e55dc60..062a14f4 100644 --- a/googletest/include/gtest/internal/gtest-internal.h +++ b/googletest/include/gtest/internal/gtest-internal.h @@ -1144,14 +1144,14 @@ struct Ignore { template struct ElemFromListImpl; -template -struct ElemFromListImpl> { +template +struct ElemFromListImpl> { // We make Ignore a template to solve a problem with MSVC. // A non-template Ignore would work fine with `decltype(Ignore(I))...`, but // MSVC doesn't understand how to deal with that pack expansion. // Use `0 * I` to have a single instantiation of Ignore. template - static R Apply(Ignore<0 * I>..., R (*)(), ...); + static R Apply(Ignore<0 * __I>..., R (*)(), ...); }; template @@ -1165,12 +1165,12 @@ struct FlatTupleConstructTag {}; template class FlatTuple; -template +template struct FlatTupleElemBase; -template -struct FlatTupleElemBase, I> { - using value_type = typename ElemFromList::type; +template +struct FlatTupleElemBase, __I> { + using value_type = typename ElemFromList<__I, T...>::type; FlatTupleElemBase() = default; template explicit FlatTupleElemBase(FlatTupleConstructTag, Arg&& t) @@ -1191,14 +1191,14 @@ struct FlatTupleBase, std::index_sequence> : FlatTupleElemBase, Idx>(FlatTupleConstructTag{}, std::forward(args))... {} - template - const typename ElemFromList::type& Get() const { - return FlatTupleElemBase, I>::value; + template + const typename ElemFromList<__I, T...>::type& Get() const { + return FlatTupleElemBase, __I>::value; } - template - typename ElemFromList::type& Get() { - return FlatTupleElemBase, I>::value; + template + typename ElemFromList<__I, T...>::type& Get() { + return FlatTupleElemBase, __I>::value; } template diff --git a/googletest/include/gtest/internal/gtest-param-util.h b/googletest/include/gtest/internal/gtest-param-util.h index cc7ea531..f5d97371 100644 --- a/googletest/include/gtest/internal/gtest-param-util.h +++ b/googletest/include/gtest/internal/gtest-param-util.h @@ -811,9 +811,9 @@ class ValueArray { } private: - template - std::vector MakeVector(std::index_sequence) const { - return std::vector{static_cast(v_.template Get())...}; + template + std::vector MakeVector(std::index_sequence<__I...>) const { + return std::vector{static_cast(v_.template Get<__I>())...}; } FlatTuple v_; @@ -838,19 +838,19 @@ class CartesianProductGenerator return new Iterator(this, generators_, true); } - private: - template +private: + template class IteratorImpl; - template - class IteratorImpl> + template + class IteratorImpl> : public ParamIteratorInterface { public: IteratorImpl(const ParamGeneratorInterface* base, const std::tuple...>& generators, bool is_end) : base_(base), - begin_(std::get(generators).begin()...), - end_(std::get(generators).end()...), + begin_(std::get<__I>(generators).begin()...), + end_(std::get<__I>(generators).end()...), current_(is_end ? end_ : begin_) { ComputeCurrentValue(); } @@ -891,8 +891,8 @@ class CartesianProductGenerator bool same = true; bool dummy[] = { - (same = same && std::get(current_) == - std::get(typed_other->current_))...}; + (same = same && std::get<__I>(current_) == + std::get<__I>(typed_other->current_))...}; (void)dummy; return same; } @@ -916,12 +916,12 @@ class CartesianProductGenerator void ComputeCurrentValue() { if (!AtEnd()) - current_value_ = std::make_shared(*std::get(current_)...); + current_value_ = std::make_shared(*std::get<__I>(current_)...); } bool AtEnd() const { bool at_end = false; bool dummy[] = { - (at_end = at_end || std::get(current_) == std::get(end_))...}; + (at_end = at_end || std::get<__I>(current_) == std::get<__I>(end_))...}; (void)dummy; return at_end; } diff --git a/mod_README.md b/mod_README.md new file mode 100644 index 00000000..b9225c10 --- /dev/null +++ b/mod_README.md @@ -0,0 +1,14 @@ +**Problem:** Gtest currently interferes w/ std::complex as complex.h uses a define for I already. + +**Modifcation:** all **I** template names renamed to **__I** (can use whatever you want, just put a placeholder I figured wouldn’t cause interference) at following locations: + +**include/internal/gtest-internal.h**: +- lines 1147-1204 + +**include/gtest-printers.h**: +- PrintTupleTo (l.791-802) +- TersePrintPrefixToStrings (l.1159-1167) + +**include/internal/gtest-param-util.h**: +- MakeVector (l.814-817) +- IteratorImpl (l.841-936) \ No newline at end of file