Skip to content

Conversation

@PastaPastaPasta
Copy link
Member

Issue being fixed or feature implemented

I like being explicit where possible, and the lack of an enumerate function in c++ has annoyed me for a while. This PR implements a enumerate() function that takes in an iterable object, and returns an tuple containing an iterator and a index. This can be decomposed using structured bindings. This makes code clearer and more readable, and should easily compile down to the same machine code based on my limited playing with it in godbolt

What was done?

How Has This Been Tested?

make check

Breaking Changes

n/a

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated relevant unit/integration/functional/e2e tests
  • I have made corresponding changes to the documentation

For repository code-owners and collaborators only

  • I have assigned this pull request to a milestone

@PastaPastaPasta PastaPastaPasta added this to the 18.2 milestone Oct 22, 2022
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls see 35db267504

Also, is src/test/block_reward_reallocation_tests.cpp the only place where this could be useful?

@PastaPastaPasta
Copy link
Member Author

No, I'm sure it could be useful in a plethora of places, but here was the location that made me think of this. I'll apply your commit soon, I had actually done those changes but forgot to push 🙈

…s enumerate() method, and use it in block_reward_reallocation_tests.cpp
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@UdjinM6 UdjinM6 changed the title refactor: introduce a new enumerate.h file that operates like python's enumerate() method, and use it in block_reward_reallocation_tests.cpp refactor: introduce a python-like enumerate() method, and use it in block_reward_reallocation_tests.cpp Oct 23, 2022
@UdjinM6 UdjinM6 merged commit 88adf24 into dashpay:develop Oct 23, 2022
@PastaPastaPasta PastaPastaPasta deleted the util/enumerate branch October 23, 2022 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants