From 957303d2f146bc9b12aaaa39c752212ca94dc4eb Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 7 Oct 2015 07:05:57 +0200 Subject: Add complete set of version comparison operators --- bpkg/package | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'bpkg/package') diff --git a/bpkg/package b/bpkg/package index ac0ac0f..12079f6 100644 --- a/bpkg/package +++ b/bpkg/package @@ -456,6 +456,15 @@ namespace bpkg template inline auto + operator!= (const T1& x, const T2& y) -> decltype (x.epoch != y.epoch) + { + return x.epoch != y.epoch || + x.canonical_upstream != y.canonical_upstream || + x.revision != y.revision; + } + + template + inline auto operator< (const T1& x, const T2& y) -> decltype (x.epoch < y.epoch) { return x.epoch < y.epoch || @@ -466,6 +475,16 @@ namespace bpkg template inline auto + operator<= (const T1& x, const T2& y) -> decltype (x.epoch <= y.epoch) + { + return x.epoch < y.epoch || + (x.epoch == y.epoch && x.canonical_upstream < y.canonical_upstream) || + (x.epoch == y.epoch && x.canonical_upstream == y.canonical_upstream && + x.revision <= y.revision); + } + + template + inline auto operator> (const T1& x, const T2& y) -> decltype (x.epoch > y.epoch) { return x.epoch > y.epoch || @@ -474,6 +493,16 @@ namespace bpkg x.revision > y.revision); } + template + inline auto + operator>= (const T1& x, const T2& y) -> decltype (x.epoch >= y.epoch) + { + return x.epoch > y.epoch || + (x.epoch == y.epoch && x.canonical_upstream > y.canonical_upstream) || + (x.epoch == y.epoch && x.canonical_upstream == y.canonical_upstream && + x.revision >= y.revision); + } + template inline auto order_by_version_desc (const T& x) -> //decltype ("ORDER BY" + x.epoch) -- cgit v1.1