From 2c70eb437e1ea5dfe98510d4a9b745ca5fbfbb6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6=20Fahlke?= <jorrit@jorrit.de> Date: Tue, 30 Sep 2014 18:05:38 +0200 Subject: [PATCH] [testBidirectionalIterator] Fix to not try to decrement the begin iterator. --- dune/common/test/iteratortest.hh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dune/common/test/iteratortest.hh b/dune/common/test/iteratortest.hh index 9b858ca8f..e457c32f5 100644 --- a/dune/common/test/iteratortest.hh +++ b/dune/common/test/iteratortest.hh @@ -91,10 +91,11 @@ template<class Iter, class Opt> int testBidirectionalIterator(Iter begin, Iter end, Opt opt) { testForwardIterator(begin, end, opt); - Iter tbegin=--begin; - Iter tend=--end; - for(; tbegin!=tend; --tend) - opt(*tend); + for(Iter it = end; it != begin; ) + { + --it; + opt(*it); + } typename Iter::difference_type size = std::distance(begin, end); srand(300); @@ -105,8 +106,8 @@ int testBidirectionalIterator(Iter begin, Iter end, Opt opt) { int index = static_cast<int>(size*(rand()/(RAND_MAX+1.0))); int backwards=size-index; - tbegin=begin; - tend=end; + Iter tbegin = begin; + Iter tend = end; for(int j=0; j < index; j++) ++tbegin; for(int j=0; j < backwards; j++) --tend; -- GitLab