Skip to content

Commit

Permalink
Avoid creating std::vector<const T> in UnorderedElementsAreArrayMatch…
Browse files Browse the repository at this point in the history
…er and others.

std::vector<const T> for trivially relocatable types is not allowed by C++ and is rejected by libc++ starting from llvm/llvm-project@4e112e5
PiperOrigin-RevId: 686487841
Change-Id: I3c90c7c0a6e8e23ffa5ebd1702a3f30ebc4a702f
  • Loading branch information
Abseil Team authored and copybara-github committed Oct 16, 2024
1 parent 62df7bd commit df1544b
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions googlemock/include/gmock/gmock-matchers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1523,7 +1523,7 @@ class SomeOfArrayMatcher {
}

private:
const ::std::vector<T> matchers_;
const std::vector<std::remove_const_t<T>> matchers_;
};

template <typename T>
Expand Down Expand Up @@ -3805,7 +3805,7 @@ class UnorderedElementsAreArrayMatcher {

private:
UnorderedMatcherRequire::Flags match_flags_;
::std::vector<T> matchers_;
std::vector<std::remove_const_t<T>> matchers_;
};

// Implements ElementsAreArray().
Expand All @@ -3826,7 +3826,7 @@ class ElementsAreArrayMatcher {
}

private:
const ::std::vector<T> matchers_;
const std::vector<std::remove_const_t<T>> matchers_;
};

// Given a 2-tuple matcher tm of type Tuple2Matcher and a value second
Expand Down Expand Up @@ -4793,9 +4793,10 @@ Pointwise(const TupleMatcher& tuple_matcher, const Container& rhs) {

// Supports the Pointwise(m, {a, b, c}) syntax.
template <typename TupleMatcher, typename T>
inline internal::PointwiseMatcher<TupleMatcher, std::vector<T>> Pointwise(
const TupleMatcher& tuple_matcher, std::initializer_list<T> rhs) {
return Pointwise(tuple_matcher, std::vector<T>(rhs));
inline internal::PointwiseMatcher<TupleMatcher,
std::vector<std::remove_const_t<T>>>
Pointwise(const TupleMatcher& tuple_matcher, std::initializer_list<T> rhs) {
return Pointwise(tuple_matcher, std::vector<std::remove_const_t<T>>(rhs));
}

// UnorderedPointwise(pair_matcher, rhs) matches an STL-style
Expand Down

0 comments on commit df1544b

Please sign in to comment.