From 8ce2f240dba5bdd0ca47ac25f16f140d8d1744fc Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Tue, 27 May 2014 18:04:02 -0700 Subject: Was the bug in my code or in the compiler? Who knows? --- src/compat/iter.hpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/compat/iter.hpp') diff --git a/src/compat/iter.hpp b/src/compat/iter.hpp index 659aca9..08c139e 100644 --- a/src/compat/iter.hpp +++ b/src/compat/iter.hpp @@ -95,10 +95,12 @@ IteratorPair> value_range(T b, T e) } -template +template class FilterIterator { + F filter; C *container; + using InnerIterator = decltype(std::begin(*container)); InnerIterator impl; public: @@ -112,8 +114,8 @@ public: } } - FilterIterator(C *c) - : container(c), impl(std::begin(*c)) + FilterIterator(C *c, F f) + : filter(f), container(c), impl(std::begin(*c)) { post_adv(); } @@ -142,10 +144,10 @@ bool is_truthy(T v) return v; } -template -IteratorPair> filter_iterator(C *c) +template)*, class C> +IteratorPair> filter_iterator(C *c, F f=is_truthy) { - return {FilterIterator(c), FilterIterator(c)}; + return {FilterIterator(c, f), FilterIterator(c, f)}; } #endif // TMWA_COMPAT_ITER_HPP -- cgit v1.2.3-70-g09d2