linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #05803
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2968: another remove_if
------------------------------------------------------------
revno: 2968
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Thu 2012-06-28 19:44:32 +0200
message:
another remove_if
modified:
dcpp/Util.h
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'dcpp/Util.h'
--- dcpp/Util.h 2012-03-11 18:06:18 +0000
+++ dcpp/Util.h 2012-06-28 17:44:32 +0000
@@ -27,6 +27,7 @@
#include <map>
#include <boost/range/algorithm/find_if.hpp>
+#include <boost/range/algorithm/remove_if.hpp>
#ifdef _WIN32
@@ -48,7 +49,6 @@
namespace dcpp {
-using boost::find_if;
using std::map;
#define LIT(x) x, (sizeof(x)-1)
@@ -394,12 +394,9 @@
template<typename T>
static T& intersect(T& t1, const T& t2) {
- for(auto i = t1.begin(); i != t1.end();) {
- if(find_if(t2, [&](const typename T::value_type &v) { return v == *i; }) == t2.end())
- i = t1.erase(i);
- else
- ++i;
- }
+ boost::remove_if(t1, [&](const typename T::value_type& v1) {
+ return boost::find_if(t2, [&](const typename T::value_type& v2) { return v2 == v1; }) == t2.end();
+ });
return t1;
}