From 01eb8253196672c969a39587e90b49321a182428 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:19:14 +0200 Subject: 5.1 --- zen/stl_tools.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'zen/stl_tools.h') diff --git a/zen/stl_tools.h b/zen/stl_tools.h index 03a10f96..e9fe149a 100644 --- a/zen/stl_tools.h +++ b/zen/stl_tools.h @@ -9,6 +9,7 @@ #define STL_TOOLS_HEADER_84567184321434 #include +#include #if defined _MSC_VER && _MSC_VER <= 1600 #include #include @@ -111,17 +112,14 @@ ForwardIterator binary_search(ForwardIterator first, ForwardIterator last, const template inline BidirectionalIterator find_last(const BidirectionalIterator first, BidirectionalIterator last, const T& value) { - //reverse iteration: 1. check 2. decrement 3. evaluate - const BidirectionalIterator iterNotFound = last; - for (;;) //VS 2010 doesn't like "while (true)" + for (BidirectionalIterator iter = last; iter != first;) //reverse iteration: 1. check 2. decrement 3. evaluate { - if (last == first) - return iterNotFound; - --last; + --iter; // - if (*last == value) - return last; + if (*iter == value) + return iter; } + return last; } -- cgit