// // Created by Stepan Usatiuk on 13.04.2023. // #ifndef SEMBACKUP_HELPFULASSERT_H #define SEMBACKUP_HELPFULASSERT_H #include #include #include #include #include #include "../../src/Exception.h" template> class HelpfulAssert { public: bool operator()(const T &lhs, const T &rhs) { if (!comp()(lhs, rhs)) { std::stringstream out; if constexpr (has_print_op::value) { out << "Expected lhs to compare to " << rhs << std::endl; out << "But lhs is " << lhs << std::endl; } else { out << "Error comparing!" << std::endl; } throw Exception(out.str()); } return true; } private: template struct has_print_op : std::false_type {}; template struct has_print_op() << std::declval())>> : std::true_type {}; }; #endif//SEMBACKUP_HELPFULASSERT_H