Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=bea74a0abf0357e99ece870d710fb0f33d79fe59
commit bea74a0abf0357e99ece870d710fb0f33d79fe59 Author: Michel Hermier <herm...@frugalware.org> Date: Wed Oct 22 07:51:49 2014 +0200 libpacman: Fix up operators so that the compiler find them. diff --git a/lib/libpacman/kernel/frefcounted.h b/lib/libpacman/kernel/frefcounted.h index 68f7a5e..71fef3a 100644 --- a/lib/libpacman/kernel/frefcounted.h +++ b/lib/libpacman/kernel/frefcounted.h @@ -160,7 +160,7 @@ namespace flib T *operator -> () const { - assert(*this); + assert(m_refcounted_ptr != nullptr); return get(); } @@ -177,43 +177,46 @@ namespace flib private: T *m_refcounted_ptr; }; -} -template <class T, class U> -bool operator == (const flib::refcounted_ptr<T> &lhs, const flib::refcounted_ptr<U> &rhs) -{ - return lhs.get() == rhs.get(); -} + template <class T, class U> + bool operator == (const refcounted_ptr<T> &lhs, const refcounted_ptr<U> &rhs) + { + return lhs.get() == rhs.get(); + } -template <class T> -bool operator == (const flib::refcounted_ptr<T> &lhs, std::nullptr_t rhs) -{ - return lhs.get() == rhs; -} + template <class T> + bool operator == (const refcounted_ptr<T> &lhs, std::nullptr_t rhs) + { + return lhs.get() == rhs; + } -template <class T> -bool operator == (std::nullptr_t lhs, const flib::refcounted_ptr<T> &rhs) -{ - return lhs == rhs.get(); -} + template <class T, class U> + bool operator != (const refcounted_ptr<T> &lhs, const refcounted_ptr<U> &rhs) + { + return lhs.get() != rhs.get(); + } -template <class T, class U> -bool operator != (const flib::refcounted_ptr<T> &lhs, const flib::refcounted_ptr<U> &rhs) -{ - return lhs.get() != rhs.get(); -} + template <class T> + bool operator != (const refcounted_ptr<T> &lhs, std::nullptr_t rhs) + { + return lhs.get() != rhs; + } +} // namespace flib -template <class T> -bool operator != (const flib::refcounted_ptr<T> &lhs, std::nullptr_t rhs) +namespace std { - return lhs.get() != rhs; -} + template <class T> + bool operator == (nullptr_t lhs, const flib::refcounted_ptr<T> &rhs) + { + return lhs == rhs.get(); + } -template <class T> -bool operator != (std::nullptr_t lhs, const flib::refcounted_ptr<T> &rhs) -{ - return lhs != rhs.get(); -} + template <class T> + bool operator != (nullptr_t lhs, const flib::refcounted_ptr<T> &rhs) + { + return lhs != rhs.get(); + } +} // namespace std #endif /* FREFCOUNTED_H */ diff --git a/lib/libpacman/package.cpp b/lib/libpacman/package.cpp index 3b447b3..52ba318 100644 --- a/lib/libpacman/package.cpp +++ b/lib/libpacman/package.cpp @@ -329,11 +329,6 @@ bool package::match(const pmdepend_t &depend) } } -bool less<package_ptr>::operator () (const package_ptr &pkg1, const package_ptr &pkg2) -{ - return pkg1 < pkg2; -} - typedef struct FPackageStrMatcher FPackageStrMatcher; struct FPackageStrMatcher @@ -407,17 +402,12 @@ const char *package_node::name() const return m_name; } -bool package_node_less::operator () (const package_node_ptr p1, const package_node_ptr p2) -{ - return strcmp(p1->name(), p2->name()) < 0; -} - -bool operator < (const libpacman::package_ptr &pkg1, const libpacman::package_ptr &pkg2) +bool libpacman::operator < (const libpacman::package_ptr &pkg1, const libpacman::package_ptr &pkg2) { return strcmp(pkg1->name(), pkg2->name()) < 0; } -bool operator < (const libpacman::package_node_ptr &pn1, const libpacman::package_node_ptr &pn2) +bool libpacman::operator < (const libpacman::package_node_ptr &pn1, const libpacman::package_node_ptr &pn2) { return strcmp(pn1->name(), pn2->name()) < 0; } diff --git a/lib/libpacman/package.h b/lib/libpacman/package.h index f8a6f4b..d8c40a7 100644 --- a/lib/libpacman/package.h +++ b/lib/libpacman/package.h @@ -178,15 +178,10 @@ public: }; typedef flib::refcounted_ptr<package> package_ptr; - template <class T> - struct less; - template <> - struct less<package_ptr> - { - bool operator () (const package_ptr &pkg1, const package_ptr &pkg2); - }; + bool operator < (const package_ptr &pkg1, const package_ptr &pkg2); + typedef FList<package_ptr> package_list; - typedef flib::set<libpacman::package_ptr, libpacman::less<package_ptr>> package_set; + typedef flib::set<libpacman::package_ptr> package_set; class PackageMatcher { @@ -219,11 +214,9 @@ private: }; typedef flib::refcounted_ptr<libpacman::package_node> package_node_ptr; - struct package_node_less - { - bool operator () (const package_node_ptr p1, const package_node_ptr p2); - }; - typedef flib::set<libpacman::package_node_ptr, package_node_less> package_node_set; + bool operator < (const package_node_ptr &pn1, const package_node_ptr &pn2); + + typedef flib::set<libpacman::package_node_ptr> package_node_set; class package_graph : package_node_set @@ -233,9 +226,6 @@ private: }; } // namespace libpacman -bool operator < (const libpacman::package_ptr &pkg1, const libpacman::package_ptr &pkg2); -bool operator < (const libpacman::package_node_ptr &pn1, const libpacman::package_node_ptr &pn2); - const libpacman::package_ptr _pacman_pkg_isin(const char *needle, const libpacman::package_list &haystack); #endif /* _PACMAN_PACKAGE_H */ _______________________________________________ Frugalware-git mailing list Frugalware-git@frugalware.org http://frugalware.org/mailman/listinfo/frugalware-git