diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2016-08-22 11:51:24 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2016-08-22 16:19:48 +0900 |
commit | cccd82a5f6cd74ffbec5d2fb5eac2ed9be64e531 (patch) | |
tree | 9308420b074d6ad59add8390703eb47dcaf38c8a | |
parent | 2ffb390231ee0793339f92d765495c59f8d84629 (diff) | |
download | libquotient-cccd82a5f6cd74ffbec5d2fb5eac2ed9be64e531.tar.gz libquotient-cccd82a5f6cd74ffbec5d2fb5eac2ed9be64e531.zip |
findInsertionPos: allow usage with polymorphic types
Basically, this commit allows the inserted item type to be different from those in the container, as in findInsertionPos(baseTypeContainer, derivedTypeItem). Of course both types should still provide timestamp() for comparison.
-rw-r--r-- | events/event.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/events/event.h b/events/event.h index a009aa99..72d26208 100644 --- a/events/event.h +++ b/events/event.h @@ -65,12 +65,12 @@ namespace QMatrixClient * @return an iterator to an item with the earliest timestamp after * the one of 'item'; or timeline.end(), if all events are earlier */ - template <class ItemT, template <typename> class ContT> - typename ContT<ItemT *>::iterator - findInsertionPos(ContT<ItemT *> & timeline, const ItemT *item) + template <class ItemT, class ContT> + typename ContT::iterator + findInsertionPos(ContT & timeline, const ItemT *item) { return std::lower_bound (timeline.begin(), timeline.end(), item, - [](const ItemT * a, const ItemT * b) { + [](const typename ContT::value_type a, const ItemT * b) { return a->timestamp() < b->timestamp(); } ); |