3232 return false ; \
3333} while (0 )
3434
35+ // FIXME: move this to a separate header file?
36+ #define RETURN_BY_REF_IF_COMPARED (a, b, member ) do { \
37+ if (a.member < b.member ) \
38+ *pResult = true ; \
39+ else if (b.member < a.member ) \
40+ *pResult = false ; \
41+ else \
42+ break ; \
43+ return true ; \
44+ } while (0 )
45+
3546
3647struct DefEvent {
3748 std::string fileName;
@@ -51,16 +62,26 @@ struct DefEvent {
5162 }
5263};
5364
54- inline bool operator <(const DefEvent &a, const DefEvent &b) {
55- RETURN_IF_COMPARED (a, b, fileName);
56- RETURN_IF_COMPARED (a, b, line);
57- RETURN_IF_COMPARED (a, b, column);
58- RETURN_IF_COMPARED (a, b, event);
59- RETURN_IF_COMPARED (a, b, msg);
60- RETURN_IF_COMPARED (a, b, verbosityLevel);
65+ inline bool cmpEvents (bool *pResult, const DefEvent &a, const DefEvent &b)
66+ {
67+ RETURN_BY_REF_IF_COMPARED (a, b, fileName);
68+ RETURN_BY_REF_IF_COMPARED (a, b, line);
69+ RETURN_BY_REF_IF_COMPARED (a, b, column);
70+ RETURN_BY_REF_IF_COMPARED (a, b, event);
71+ RETURN_BY_REF_IF_COMPARED (a, b, msg);
72+ RETURN_BY_REF_IF_COMPARED (a, b, verbosityLevel);
73+
74+ // incomparable events
6175 return false ;
6276}
6377
78+ inline bool operator <(const DefEvent &a, const DefEvent &b)
79+ {
80+ bool result;
81+ return cmpEvents (&result, a, b)
82+ && result;
83+ }
84+
6485typedef std::vector<DefEvent> TEvtList;
6586
6687struct Defect {
0 commit comments