Skip to content

Commit

Permalink
Merge pull request #3195 from Inujel:fix-3194
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 398271948
  • Loading branch information
dinord committed Sep 23, 2021
2 parents 09074c1 + 9614d8c commit e4717df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
17 changes: 7 additions & 10 deletions googlemock/include/gmock/gmock-matchers.h
Original file line number Diff line number Diff line change
Expand Up @@ -2425,7 +2425,6 @@ class ContainerEqMatcher {
typedef internal::StlContainerView<
typename std::remove_const<LhsContainer>::type>
LhsView;
typedef typename LhsView::type LhsStlContainer;
StlContainerReference lhs_stl_container = LhsView::ConstReference(lhs);
if (lhs_stl_container == expected_)
return true;
Expand All @@ -2434,8 +2433,7 @@ class ContainerEqMatcher {
if (os != nullptr) {
// Something is different. Check for extra values first.
bool printed_header = false;
for (typename LhsStlContainer::const_iterator it =
lhs_stl_container.begin();
for (auto it = lhs_stl_container.begin();
it != lhs_stl_container.end(); ++it) {
if (internal::ArrayAwareFind(expected_.begin(), expected_.end(), *it) ==
expected_.end()) {
Expand All @@ -2451,7 +2449,7 @@ class ContainerEqMatcher {

// Now check for missing values.
bool printed_header2 = false;
for (typename StlContainer::const_iterator it = expected_.begin();
for (auto it = expected_.begin();
it != expected_.end(); ++it) {
if (internal::ArrayAwareFind(
lhs_stl_container.begin(), lhs_stl_container.end(), *it) ==
Expand Down Expand Up @@ -2635,8 +2633,8 @@ class PointwiseMatcher {
return false;
}

typename LhsStlContainer::const_iterator left = lhs_stl_container.begin();
typename RhsStlContainer::const_iterator right = rhs_.begin();
auto left = lhs_stl_container.begin();
auto right = rhs_.begin();
for (size_t i = 0; i != actual_size; ++i, ++left, ++right) {
if (listener->IsInterested()) {
StringMatchResultListener inner_listener;
Expand Down Expand Up @@ -2699,7 +2697,7 @@ class QuantifierMatcherImpl : public MatcherInterface<Container> {
MatchResultListener* listener) const {
StlContainerReference stl_container = View::ConstReference(container);
size_t i = 0;
for (typename StlContainer::const_iterator it = stl_container.begin();
for (auto it = stl_container.begin();
it != stl_container.end(); ++it, ++i) {
StringMatchResultListener inner_listener;
const bool matches = inner_matcher_.MatchAndExplain(*it, &inner_listener);
Expand Down Expand Up @@ -3400,7 +3398,7 @@ class ElementsAreMatcherImpl : public MatcherInterface<Container> {
// explanations[i] is the explanation of the element at index i.
::std::vector<std::string> explanations(count());
StlContainerReference stl_container = View::ConstReference(container);
typename StlContainer::const_iterator it = stl_container.begin();
auto it = stl_container.begin();
size_t exam_pos = 0;
bool mismatch_found = false; // Have we found a mismatched element yet?

Expand Down Expand Up @@ -3593,7 +3591,6 @@ class UnorderedElementsAreMatcherImpl
typedef internal::StlContainerView<RawContainer> View;
typedef typename View::type StlContainer;
typedef typename View::const_reference StlContainerReference;
typedef typename StlContainer::const_iterator StlContainerConstIterator;
typedef typename StlContainer::value_type Element;

template <typename InputIter>
Expand Down Expand Up @@ -4760,7 +4757,7 @@ UnorderedPointwise(const Tuple2Matcher& tuple2_matcher,

// Create a matcher for each element in rhs_container.
::std::vector<internal::BoundSecondMatcher<Tuple2Matcher, Second> > matchers;
for (typename RhsStlContainer::const_iterator it = rhs_stl_container.begin();
for (auto it = rhs_stl_container.begin();
it != rhs_stl_container.end(); ++it) {
matchers.push_back(
internal::MatcherBindSecond(tuple2_matcher, *it));
Expand Down
2 changes: 1 addition & 1 deletion googletest/src/gtest-internal-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ inline int CountIf(const Container& c, Predicate predicate) {
// Implemented as an explicit loop since std::count_if() in libCstd on
// Solaris has a non-standard signature.
int count = 0;
for (typename Container::const_iterator it = c.begin(); it != c.end(); ++it) {
for (auto it = c.begin(); it != c.end(); ++it) {
if (predicate(*it))
++count;
}
Expand Down

0 comments on commit e4717df

Please sign in to comment.