Add Utils::filtered as a wrapper around std::copy_if

Change-Id: I4a189581a4a7f42f880c47b91372d7e96d50655e
Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
This commit is contained in:
Eike Ziller
2015-10-14 13:15:09 +02:00
parent a447645422
commit 9b52d193a3

View File

@@ -337,6 +337,18 @@ auto transform(const SC &container, R (S::*p)() const)
>::call(container, p); >::call(container, p);
} }
//////////////////
// filtered
/////////////////
template<typename C, typename F>
C filtered(const C &container, F predicate)
{
C out;
std::copy_if(container.begin(), container.end(),
inserter(out), predicate);
return out;
}
////////////////// //////////////////
// sort // sort
///////////////// /////////////////