Skip to content

Commit fbf514c

Browse files
Add a drop function for ranget
This is useful for advancing the range without having to manipulate the private `begin_value` field.
1 parent a57d53c commit fbf514c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/util/range.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,18 @@ struct ranget final
341341
return begin_value == end_value;
342342
}
343343

344+
/// Drop the first \p count elements.
345+
/// If the range has fewer elements, drops everything.
346+
void drop(std::size_t count)
347+
{
348+
std::size_t i = 0;
349+
while(i < count && begin_value != end_value)
350+
{
351+
++begin_value;
352+
++i;
353+
}
354+
}
355+
344356
iteratort begin() const
345357
{
346358
return begin_value;

0 commit comments

Comments
 (0)