add `enumerate`
Given an 'iterable', return a new iterable which iterates over a pair of index and elements of the original 'iterable'.
For example:
for ( auto [i,s] : LHCb::range::enumerate( std::array{0,1,4,9,16,25} ) ) {
assert( i*i == s );
}
The index starts, by default, at 0, and has a type of size_t
but this can be customised as well:
for ( auto [i,s] : LHCb::range::enumerate( std::array{4u,9u,16u,25u,36u}, 2u ) ) {
assert( i*i == s );
}
Edited by Rosen Matev
Merge request reports
Activity
added enhancement label
assigned to @gunther
- Resolved by Andre Gunther
/ci-test --merge --platforms=x86_64-centos7-gcc9-opt,x86_64-centos7-clang8-opt
added ci-test-triggered label
- [2020-09-19 16:12] Validation started with lhcb-master-mr#1343
- [2020-09-21 00:15] Validation started with lhcb-head#2717
Edited by Software for LHCbadded lhcb-head label
- Resolved by Andre Gunther
removed lhcb-head label
added 13 commits
-
b1a04f54...f518e1c7 - 12 commits from branch
master
- 7b8c0804 - add `enumerate`
-
b1a04f54...f518e1c7 - 12 commits from branch
added lhcb-head-2 label
Please register or sign in to reply