diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-02-09 19:10:38 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-02-10 17:25:59 +0200 |
commit | ae301626ddd8288bd58d67dfb7b2a660740001b0 (patch) | |
tree | 939e004b56b56032d196b8174503802fd2447138 | |
parent | 5c2d2601fcc69617eaf95ac7b7d5b18d39f196bd (diff) |
Implement ==, != operators for dependency class
-rw-r--r-- | brep/package | 6 | ||||
-rw-r--r-- | brep/package.cxx | 12 | ||||
-rw-r--r-- | tests/load/driver.cxx | 36 |
3 files changed, 18 insertions, 36 deletions
diff --git a/brep/package b/brep/package index e23dfd6..5360623 100644 --- a/brep/package +++ b/brep/package @@ -315,6 +315,12 @@ namespace brep std::ostream& operator<< (std::ostream&, const dependency&); + bool + operator== (const dependency&, const dependency&); + + bool + operator!= (const dependency&, const dependency&); + #pragma db value class dependency_alternatives: public vector<dependency> { diff --git a/brep/package.cxx b/brep/package.cxx index cb7ab46..7bdc3c7 100644 --- a/brep/package.cxx +++ b/brep/package.cxx @@ -37,6 +37,18 @@ namespace brep return o; } + bool + operator== (const dependency& x, const dependency& y) + { + return x.name () == y.name () && x.constraint == y.constraint; + } + + bool + operator!= (const dependency& x, const dependency& y) + { + return !(x == y); + } + // package // package:: diff --git a/tests/load/driver.cxx b/tests/load/driver.cxx index 006f14c..539c50d 100644 --- a/tests/load/driver.cxx +++ b/tests/load/driver.cxx @@ -25,42 +25,6 @@ using namespace odb::core; using namespace butl; using namespace brep; -// @@ Rather add this to optional in libbutl! See: -// -// http://en.cppreference.com/w/cpp/experimental/optional/operator_cmp - -namespace butl -{ - template <typename T> - static inline auto - operator== (const optional<T>& a, const optional<T>& b) -> - decltype (*a == *b) - { - return !a == !b && (!a || *a == *b); - } -} - -// @@ Add it to libbpkg/libbrep rather! -// -namespace bpkg -{ - static inline bool - operator== (const dependency_constraint& a, const dependency_constraint& b) - { - return a.min_version == b.min_version && a.max_version == b.max_version && - a.min_open == b.min_open && a.max_open == b.max_open; - } -} - -namespace brep -{ - static inline bool - operator== (const dependency& a, const dependency& b) - { - return a.name () == b.name () && a.constraint == b.constraint; - } -} - static bool check_location (shared_ptr<package>& p) { |