summaryrefslogtreecommitdiff
path: root/zen/stl_tools.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2015-10-02 14:56:07 +0200
committerDaniel Wilhelm <daniel@wili.li>2015-10-02 14:56:07 +0200
commitde73d25e0b27f4bee2de116d19cab32800785d64 (patch)
tree21de1736d12a92223ad04c02a5b0826d77e5e71c /zen/stl_tools.h
parent7.1 (diff)
downloadFreeFileSync-de73d25e0b27f4bee2de116d19cab32800785d64.tar.gz
FreeFileSync-de73d25e0b27f4bee2de116d19cab32800785d64.tar.bz2
FreeFileSync-de73d25e0b27f4bee2de116d19cab32800785d64.zip
7.2
Diffstat (limited to 'zen/stl_tools.h')
-rw-r--r--zen/stl_tools.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/zen/stl_tools.h b/zen/stl_tools.h
index d2d4ee1a..bd76e264 100644
--- a/zen/stl_tools.h
+++ b/zen/stl_tools.h
@@ -9,6 +9,7 @@
#include <memory>
#include <algorithm>
+#include <zen/type_tools.h>
//enhancements for <algorithm>
@@ -66,6 +67,7 @@ std::unique_ptr<T> make_unique(Args&& ... args) { return std::unique_ptr<T>(new
template <class V, class Predicate> inline
void vector_remove_if(V& vec, Predicate p)
{
+ static_assert(IsSameType<typename std::iterator_traits<typename V::iterator>::iterator_category, std::random_access_iterator_tag>::value, "poor man's check for vector");
vec.erase(std::remove_if(vec.begin(), vec.end(), p), vec.end());
}
@@ -87,6 +89,9 @@ void set_append(V& s, const W& s2)
template <class S, class Predicate> inline
void set_remove_if(S& set, Predicate p)
{
+ //function compiles and fails (if we're lucky) not before runtime for std::vector!!!
+ static_assert(!IsSameType<typename std::iterator_traits<typename S::iterator>::iterator_category, std::random_access_iterator_tag>::value, "poor man's check for non-vector");
+
for (auto iter = set.begin(); iter != set.end();)
if (p(*iter))
set.erase(iter++);
bgstack15