Skip to content
Snippets Groups Projects

add `enumerate`

Merged Gerhard Raven requested to merge add-enumerate into master

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

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • Andre Gunther assigned to @graven and unassigned @gunther

    assigned to @graven and unassigned @gunther

  • removed lhcb-head label

  • Gerhard Raven added 13 commits

    added 13 commits

    Compare with previous version

  • Gerhard Raven added 1 commit

    added 1 commit

    Compare with previous version

  • Andre Gunther resolved all threads

    resolved all threads

  • Andre Gunther assigned to @gunther and unassigned @graven

    assigned to @gunther and unassigned @graven

  • Gerhard Raven changed the description

    changed the description

  • Andre Gunther approved this merge request

    approved this merge request

  • Andre Gunther assigned to @dovombru and unassigned @gunther

    assigned to @dovombru and unassigned @gunther

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Please register or sign in to reply
    Loading