aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitsune Ral <Kitsune-Ral@users.sf.net>2016-08-22 11:51:24 +0900
committerKitsune Ral <Kitsune-Ral@users.sf.net>2016-08-22 16:19:48 +0900
commitcccd82a5f6cd74ffbec5d2fb5eac2ed9be64e531 (patch)
tree9308420b074d6ad59add8390703eb47dcaf38c8a
parent2ffb390231ee0793339f92d765495c59f8d84629 (diff)
downloadlibquotient-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.h8
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();
}
);