4040#define GOOGLETEST_INCLUDE_GTEST_GTEST_MATCHERS_H_
4141
4242#include < atomic>
43+ #include < functional>
4344#include < memory>
4445#include < ostream>
4546#include < string>
@@ -106,13 +107,13 @@ class MatchResultListener {
106107 MatchResultListener& operator =(const MatchResultListener&) = delete ;
107108};
108109
109- inline MatchResultListener::~MatchResultListener () {}
110+ inline MatchResultListener::~MatchResultListener () = default ;
110111
111112// An instance of a subclass of this knows how to describe itself as a
112113// matcher.
113114class GTEST_API_ MatcherDescriberInterface {
114115 public:
115- virtual ~MatcherDescriberInterface () {}
116+ virtual ~MatcherDescriberInterface () = default ;
116117
117118 // Describes this matcher to an ostream. The function should print
118119 // a verb phrase that describes the property a value matching this
@@ -178,43 +179,6 @@ class MatcherInterface : public MatcherDescriberInterface {
178179
179180namespace internal {
180181
181- struct AnyEq {
182- template <typename A, typename B>
183- bool operator ()(const A& a, const B& b) const {
184- return a == b;
185- }
186- };
187- struct AnyNe {
188- template <typename A, typename B>
189- bool operator ()(const A& a, const B& b) const {
190- return a != b;
191- }
192- };
193- struct AnyLt {
194- template <typename A, typename B>
195- bool operator ()(const A& a, const B& b) const {
196- return a < b;
197- }
198- };
199- struct AnyGt {
200- template <typename A, typename B>
201- bool operator ()(const A& a, const B& b) const {
202- return a > b;
203- }
204- };
205- struct AnyLe {
206- template <typename A, typename B>
207- bool operator ()(const A& a, const B& b) const {
208- return a <= b;
209- }
210- };
211- struct AnyGe {
212- template <typename A, typename B>
213- bool operator ()(const A& a, const B& b) const {
214- return a >= b;
215- }
216- };
217-
218182// A match result listener that ignores the explanation.
219183class DummyMatchResultListener : public MatchResultListener {
220184 public:
@@ -530,7 +494,7 @@ template <>
530494class GTEST_API_ Matcher<const std::string&>
531495 : public internal::MatcherBase<const std::string&> {
532496 public:
533- Matcher () {}
497+ Matcher () = default ;
534498
535499 explicit Matcher (const MatcherInterface<const std::string&>* impl)
536500 : internal::MatcherBase<const std::string&>(impl) {}
@@ -552,7 +516,7 @@ template <>
552516class GTEST_API_ Matcher<std::string>
553517 : public internal::MatcherBase<std::string> {
554518 public:
555- Matcher () {}
519+ Matcher () = default ;
556520
557521 explicit Matcher (const MatcherInterface<const std::string&>* impl)
558522 : internal::MatcherBase<std::string>(impl) {}
@@ -580,7 +544,7 @@ template <>
580544class GTEST_API_ Matcher<const internal::StringView&>
581545 : public internal::MatcherBase<const internal::StringView&> {
582546 public:
583- Matcher () {}
547+ Matcher () = default ;
584548
585549 explicit Matcher (const MatcherInterface<const internal::StringView&>* impl)
586550 : internal::MatcherBase<const internal::StringView&>(impl) {}
@@ -606,7 +570,7 @@ template <>
606570class GTEST_API_ Matcher<internal::StringView>
607571 : public internal::MatcherBase<internal::StringView> {
608572 public:
609- Matcher () {}
573+ Matcher () = default ;
610574
611575 explicit Matcher (const MatcherInterface<const internal::StringView&>* impl)
612576 : internal::MatcherBase<internal::StringView>(impl) {}
@@ -758,50 +722,53 @@ class ComparisonBase {
758722};
759723
760724template <typename Rhs>
761- class EqMatcher : public ComparisonBase <EqMatcher<Rhs>, Rhs, AnyEq > {
725+ class EqMatcher : public ComparisonBase <EqMatcher<Rhs>, Rhs, std::equal_to<> > {
762726 public:
763727 explicit EqMatcher (const Rhs& rhs)
764- : ComparisonBase<EqMatcher<Rhs>, Rhs, AnyEq >(rhs) {}
728+ : ComparisonBase<EqMatcher<Rhs>, Rhs, std::equal_to<> >(rhs) {}
765729 static const char * Desc () { return " is equal to" ; }
766730 static const char * NegatedDesc () { return " isn't equal to" ; }
767731};
768732template <typename Rhs>
769- class NeMatcher : public ComparisonBase <NeMatcher<Rhs>, Rhs, AnyNe> {
733+ class NeMatcher
734+ : public ComparisonBase<NeMatcher<Rhs>, Rhs, std::not_equal_to<>> {
770735 public:
771736 explicit NeMatcher (const Rhs& rhs)
772- : ComparisonBase<NeMatcher<Rhs>, Rhs, AnyNe >(rhs) {}
737+ : ComparisonBase<NeMatcher<Rhs>, Rhs, std::not_equal_to<> >(rhs) {}
773738 static const char * Desc () { return " isn't equal to" ; }
774739 static const char * NegatedDesc () { return " is equal to" ; }
775740};
776741template <typename Rhs>
777- class LtMatcher : public ComparisonBase <LtMatcher<Rhs>, Rhs, AnyLt > {
742+ class LtMatcher : public ComparisonBase <LtMatcher<Rhs>, Rhs, std::less<> > {
778743 public:
779744 explicit LtMatcher (const Rhs& rhs)
780- : ComparisonBase<LtMatcher<Rhs>, Rhs, AnyLt >(rhs) {}
745+ : ComparisonBase<LtMatcher<Rhs>, Rhs, std::less<> >(rhs) {}
781746 static const char * Desc () { return " is <" ; }
782747 static const char * NegatedDesc () { return " isn't <" ; }
783748};
784749template <typename Rhs>
785- class GtMatcher : public ComparisonBase <GtMatcher<Rhs>, Rhs, AnyGt > {
750+ class GtMatcher : public ComparisonBase <GtMatcher<Rhs>, Rhs, std::greater<> > {
786751 public:
787752 explicit GtMatcher (const Rhs& rhs)
788- : ComparisonBase<GtMatcher<Rhs>, Rhs, AnyGt >(rhs) {}
753+ : ComparisonBase<GtMatcher<Rhs>, Rhs, std::greater<> >(rhs) {}
789754 static const char * Desc () { return " is >" ; }
790755 static const char * NegatedDesc () { return " isn't >" ; }
791756};
792757template <typename Rhs>
793- class LeMatcher : public ComparisonBase <LeMatcher<Rhs>, Rhs, AnyLe> {
758+ class LeMatcher
759+ : public ComparisonBase<LeMatcher<Rhs>, Rhs, std::less_equal<>> {
794760 public:
795761 explicit LeMatcher (const Rhs& rhs)
796- : ComparisonBase<LeMatcher<Rhs>, Rhs, AnyLe >(rhs) {}
762+ : ComparisonBase<LeMatcher<Rhs>, Rhs, std::less_equal<> >(rhs) {}
797763 static const char * Desc () { return " is <=" ; }
798764 static const char * NegatedDesc () { return " isn't <=" ; }
799765};
800766template <typename Rhs>
801- class GeMatcher : public ComparisonBase <GeMatcher<Rhs>, Rhs, AnyGe> {
767+ class GeMatcher
768+ : public ComparisonBase<GeMatcher<Rhs>, Rhs, std::greater_equal<>> {
802769 public:
803770 explicit GeMatcher (const Rhs& rhs)
804- : ComparisonBase<GeMatcher<Rhs>, Rhs, AnyGe >(rhs) {}
771+ : ComparisonBase<GeMatcher<Rhs>, Rhs, std::greater_equal<> >(rhs) {}
805772 static const char * Desc () { return " is >=" ; }
806773 static const char * NegatedDesc () { return " isn't >=" ; }
807774};
0 commit comments