@@ -57,7 +57,7 @@ class msg : public decltype(Message()) {
5757 std::string comp_{};
5858 TLhs lhs_;
5959 TRhs rhs_;
60- bool result_{};
60+ bool result_{false };
6161};
6262
6363template <class TShouldError >
@@ -66,22 +66,10 @@ class op {
6666 class comp : public decltype (Message()) {
6767 public:
6868 explicit comp (const info& info, const TLhs& lhs) : info_{info}, lhs_{lhs} {
69- if (std::is_same<bool , TLhs>::value) {
70- result_ = internal::CmpHelperEQ (" " , " " , lhs_, true );
71- }
69+ set_result (lhs_);
7270 }
7371
74- ~comp () {
75- if (TShouldError::value && !followed_ &&
76- std::is_same<bool , TLhs>::value) {
77- const AssertionResult gtest_ar =
78- (internal::CmpHelperEQ (info_.expr .c_str (), " true" , lhs_, true ));
79- if (!gtest_ar) {
80- internal::AssertHelper (info_.failure , info_.file , info_.line ,
81- gtest_ar.failure_message ()) = *this ;
82- }
83- }
84- }
72+ ~comp () { assert_error (lhs_); }
8573
8674 template <class TRhs ,
8775 std::enable_if_t <std::is_floating_point<TLhs>::value ||
@@ -142,10 +130,31 @@ class op {
142130 operator bool () const { return result_; }
143131
144132 private:
133+ void set_result (const bool &) {
134+ result_ = internal::CmpHelperEQ (" " , " " , lhs_, true );
135+ }
136+
137+ template <class T >
138+ void set_result (const T&) {}
139+
140+ void assert_error (const bool &) {
141+ if (TShouldError::value && !followed_) {
142+ const AssertionResult gtest_ar =
143+ (internal::CmpHelperEQ (info_.expr .c_str (), " true" , lhs_, true ));
144+ if (!gtest_ar) {
145+ internal::AssertHelper (info_.failure , info_.file , info_.line ,
146+ gtest_ar.failure_message ()) = *this ;
147+ }
148+ }
149+ }
150+
151+ template <class T >
152+ void assert_error (const T&) {}
153+
145154 info info_{};
146155 TLhs lhs_{};
147156 mutable bool followed_{false };
148- bool result_{};
157+ bool result_{false };
149158 };
150159
151160 public:
0 commit comments