项目作者: roehrdor

项目描述 :
高级语言: C++
项目地址: git://github.com/roehrdor/cpp-enumerate.git
创建时间: 2019-03-19T17:49:43Z
项目社区:https://github.com/roehrdor/cpp-enumerate

开源协议:Other

下载


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

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

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