Skip to content

Iterator and range classes for iterating over groups of adjacent items

License

Notifications You must be signed in to change notification settings

hoisunng/adjacent_range

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

adjacent_range

Iterator and range classes for iterating over groups of adjacent items

These classes are inspired by this Stack Overflow answer and this lightning talk. The result is an adjacent_iterator to loop over N consecutive items. For the special case where N=2, the iterators are stored in a std::pair, so access is possible via the members first and second. For the other cases, N!=2 , access is required to use the std::get<> function.

Example
for (const auto& p : make_adjacent_range<2>(v)) {
  do_something(p.first, p.second);
}

About

Iterator and range classes for iterating over groups of adjacent items

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages