From de73d25e0b27f4bee2de116d19cab32800785d64 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 2 Oct 2015 14:56:07 +0200 Subject: 7.2 --- zen/stl_tools.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'zen/stl_tools.h') 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 #include +#include //enhancements for @@ -66,6 +67,7 @@ std::unique_ptr make_unique(Args&& ... args) { return std::unique_ptr(new template inline void vector_remove_if(V& vec, Predicate p) { + static_assert(IsSameType::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 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::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++); -- cgit