diff --git a/boolinq/SkipWhileRangeTest.cpp b/boolinq/SkipWhileRangeTest.cpp index 17b1010..ec7fcb9 100644 --- a/boolinq/SkipWhileRangeTest.cpp +++ b/boolinq/SkipWhileRangeTest.cpp @@ -19,8 +19,6 @@ TEST(SkipWhileRange, ManyToMore) auto rng = from(src); auto dst = rng.skipWhile([](int it){return it < 0 || it > 10;}); - auto vec = dst.toVector(); - CheckRangeEqArray(dst, ans); } diff --git a/boolinq/boolinq.h b/boolinq/boolinq.h index 6b28af2..01e77df 100644 --- a/boolinq/boolinq.h +++ b/boolinq/boolinq.h @@ -192,19 +192,18 @@ namespace boolinq LinqObj > > skipWhile_i(std::function predicate) const { - auto enumerator = _enumerator; - - try - { - int i = 0; - while(predicate(TE(enumerator).nextObject(),i++)) - enumerator.nextObject(); - } - catch(EnumeratorEndException &){} - return Enumerator >([=](std::pair & pair)->T{ + if( 0 == pair.second ) + { + T t; + do + t = pair.first.nextObject(); + while (predicate(t,pair.second++)); + return t; + } + return pair.first.nextObject(); - }, std::make_pair(enumerator,0)); + }, std::make_pair(_enumerator,0)); } LinqObj > > skipWhile(std::function predicate) const