Skip to content

Commit df1544b

Browse files
Abseil Teamcopybara-github
authored andcommitted
Avoid creating std::vector<const T> in UnorderedElementsAreArrayMatcher 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
1 parent 62df7bd commit df1544b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

googlemock/include/gmock/gmock-matchers.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@ class SomeOfArrayMatcher {
15231523
}
15241524

15251525
private:
1526-
const ::std::vector<T> matchers_;
1526+
const std::vector<std::remove_const_t<T>> matchers_;
15271527
};
15281528

15291529
template <typename T>
@@ -3805,7 +3805,7 @@ class UnorderedElementsAreArrayMatcher {
38053805

38063806
private:
38073807
UnorderedMatcherRequire::Flags match_flags_;
3808-
::std::vector<T> matchers_;
3808+
std::vector<std::remove_const_t<T>> matchers_;
38093809
};
38103810

38113811
// Implements ElementsAreArray().
@@ -3826,7 +3826,7 @@ class ElementsAreArrayMatcher {
38263826
}
38273827

38283828
private:
3829-
const ::std::vector<T> matchers_;
3829+
const std::vector<std::remove_const_t<T>> matchers_;
38303830
};
38313831

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

47944794
// Supports the Pointwise(m, {a, b, c}) syntax.
47954795
template <typename TupleMatcher, typename T>
4796-
inline internal::PointwiseMatcher<TupleMatcher, std::vector<T>> Pointwise(
4797-
const TupleMatcher& tuple_matcher, std::initializer_list<T> rhs) {
4798-
return Pointwise(tuple_matcher, std::vector<T>(rhs));
4796+
inline internal::PointwiseMatcher<TupleMatcher,
4797+
std::vector<std::remove_const_t<T>>>
4798+
Pointwise(const TupleMatcher& tuple_matcher, std::initializer_list<T> rhs) {
4799+
return Pointwise(tuple_matcher, std::vector<std::remove_const_t<T>>(rhs));
47994800
}
48004801

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

0 commit comments

Comments
 (0)