Skip to content

roehrdor/cpp-enumerate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cpp-enumerate

C++ 14 based, python like enumeration of C++ iterables, returning the index and value. Also works with custom iterables that require ADL.

Examples:

  • with std::vector
std::vector<int> v{1, 2, 3, 4};
for (auto&& [idx, val] : rz::enumerate(v)) {
    // 
}
  • custom iterable
struct Foo {
    int x;
    int * begin() { return &x; }
    int * end() { return &x + 1; }
};

for (auto&& [idx, val] : rz::enumerate(Foo{7})) {
    //
}

Releases

No releases published

Packages

No packages published