summaryrefslogtreecommitdiffstats
path: root/Source/cmAlgorithms.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmAlgorithms.h')
-rw-r--r--Source/cmAlgorithms.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/Source/cmAlgorithms.h b/Source/cmAlgorithms.h
index 161a2cb..3dd5f95 100644
--- a/Source/cmAlgorithms.h
+++ b/Source/cmAlgorithms.h
@@ -237,12 +237,15 @@ typename Range::const_iterator cmRemoveIndices(Range& r, InputRange const& rem)
{
typename InputRange::const_iterator remIt = rem.begin();
- typename Range::iterator writer = r.begin() + *remIt;
+ typename Range::iterator writer = r.begin();
+ std::advance(writer, *remIt);
++remIt;
size_t count = 1;
for ( ; writer != r.end() && remIt != rem.end(); ++count, ++remIt)
{
- writer = ContainerAlgorithms::RemoveN(writer, r.begin() + *remIt, count);
+ typename Range::iterator pivot = r.begin();
+ std::advance(pivot, *remIt);
+ writer = ContainerAlgorithms::RemoveN(writer, pivot, count);
}
writer = ContainerAlgorithms::RemoveN(writer, r.end(), count);
return writer;