Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=a05b2d00b449e86c3d47b17e2c2b6a7b6a83e894
commit a05b2d00b449e86c3d47b17e2c2b6a7b6a83e894 Author: Michel Hermier <herm...@frugalware.org> Date: Mon Oct 6 08:05:49 2014 +0200 libpacman: Add flib::mapped_traits (to implement key/value in a single structure). diff --git a/lib/libpacman/util/flist.h b/lib/libpacman/util/flist.h index 1b1062a..edaab92 100644 --- a/lib/libpacman/util/flist.h +++ b/lib/libpacman/util/flist.h @@ -41,6 +41,29 @@ namespace flib struct uncompared { }; + template <class T> + struct mapped_traits + { + typedef T mapped_type; + typedef T key_type; + typedef T value_type; + + static const key_type &key_of(const mapped_type &o) + { + return o; + } + + static value_type &value_of(mapped_type &o) + { + return o; + } + + static const value_type &value_of(const mapped_type &o) + { + return o; + } + }; + template <typename Iterable> struct iterable_traits { @@ -635,7 +658,7 @@ namespace flib { }; } -template <typename T, class Compare = flib::uncompared> +template <typename T, class Compare = flib::uncompared, class MappedTrais = flib::mapped_traits<T>> class FList : protected FCListItem { @@ -935,7 +958,7 @@ protected: template <class Data = value_type> iterator find_insertion_point(typename std::enable_if<std::is_same<flib::uncompared, Compare>::value, const Data &>::type data) { - return end(); + return last(); } template <class Data = value_type> _______________________________________________ Frugalware-git mailing list Frugalware-git@frugalware.org http://frugalware.org/mailman/listinfo/frugalware-git