aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@theqtcompany.com>2015-10-23 12:42:23 +0200
committerTobias Hunger <tobias.hunger@theqtcompany.com>2015-10-23 11:53:49 +0000
commit4df436f61a8e2c2f0702090cb4d2a7b57a4e0f9a (patch)
treeb9902ae6c6614f33e44bcffd787c15379e93a8c0
parentd18b8507c10ff5c26e66dc8f0448443f65cf8847 (diff)
Algorithm: Make filtered accept a member function pointer
Change-Id: Ib71da93b3893ffb3309d00d7ce2dc803ff0eb4b4 Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
-rw-r--r--src/libs/utils/algorithm.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libs/utils/algorithm.h b/src/libs/utils/algorithm.h
index 9b4a5752f0..810b6c3502 100644
--- a/src/libs/utils/algorithm.h
+++ b/src/libs/utils/algorithm.h
@@ -349,6 +349,16 @@ C filtered(const C &container, F predicate)
return out;
}
+template<typename C, typename R, typename S>
+Q_REQUIRED_RESULT
+C filtered(const C &container, R (S::*predicate)() const)
+{
+ C out;
+ std::copy_if(container.begin(), container.end(),
+ inserter(out), std::mem_fn(predicate));
+ return out;
+}
+
//////////////////
// sort
/////////////////