aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-16 01:06:19 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-16 01:06:19 +0000
commitf671968e781b7843f522ccd60f74a2cfa60453c7 (patch)
tree863c37f1dfd2088f2dc5f846109e662d26e31dc2
parent40f2054c9e2d3b375e85fe793cef5a6f6c6911b5 (diff)
downloadpaludis-f671968e781b7843f522ccd60f74a2cfa60453c7.tar.gz
paludis-f671968e781b7843f522ccd60f74a2cfa60453c7.tar.xz
Implement EqualityComparisonTag + CompareByAllTag
-rw-r--r--paludis/util/smart_record.hh.m440
1 files changed, 29 insertions, 11 deletions
diff --git a/paludis/util/smart_record.hh.m4 b/paludis/util/smart_record.hh.m4
index ad0c649..ae5335d 100644
--- a/paludis/util/smart_record.hh.m4
+++ b/paludis/util/smart_record.hh.m4
@@ -524,16 +524,6 @@ forloop(`idx', `0', max_record_size, `
}
#endif
-#ifdef DOXYGEN
- /**
- * Do the comparison for a RecordBase.
- */
- template <typename Tag_, unsigned key_count_>
- struct DoFullCompareByAll
- {
- };
-
-#else
template <typename Tag_, unsigned key_count_>
struct DoFullCompareByAll;
@@ -563,7 +553,26 @@ forloop(`idy', `0', decr(`'idx`'), `
}
};
')
-#endif
+
+ template <typename Tag_, unsigned key_count_>
+ struct DoEqualCompareByAll;
+
+forloop(`idx', `1', max_record_size, `
+ template <typename Tag_>
+ struct DoEqualCompareByAll<Tag_, `'idx`'>
+ {
+ static bool do_compare(const RecordBase<Tag_, `'idx`'> * const a,
+ const RecordBase<Tag_, `'idx`'> * const b)
+ {
+forloop(`idy', `0', decr(`'idx`'), `
+ if (RecordKeyGetter<Tag_, `'idx`', `'idy`'>::do_get(*a) !=
+ RecordKeyGetter<Tag_, `'idx`', `'idy`'>::do_get(*b))
+ return false;
+')
+ return true;
+ }
+ };
+')
template <typename Tag_, unsigned key_count_>
int RecordComparisonBase<Tag_, key_count_, comparison_mode::FullComparisonTag,
@@ -574,6 +583,15 @@ forloop(`idy', `0', decr(`'idx`'), `
static_cast<const RecordBase<Tag_, key_count_> *>(this), &other);
}
+ template <typename Tag_, unsigned key_count_>
+ bool RecordComparisonBase<Tag_, key_count_, comparison_mode::EqualityComparisonTag,
+ comparison_method::SmartRecordCompareByAllTag>::compare(
+ const RecordBase<Tag_, key_count_> & other) const
+ {
+ return DoEqualCompareByAll<Tag_, key_count_>::do_compare(
+ static_cast<const RecordBase<Tag_, key_count_> *>(this), &other);
+ }
+
/**
* Do the comparison for a range of keys.
*/