Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codechange: Replace FOR_ALL_XXX with range-based for loops #7864

Merged
merged 24 commits into from Dec 21, 2019

Conversation

glx22
Copy link
Contributor

@glx22 glx22 commented Dec 18, 2019

No description provided.

Copy link
Member

@LordAro LordAro left a comment

Choose a reason for hiding this comment

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

👍

* @param from index of the first Titem to consider
* @return an iterable ensemble of all valid Titem
*/
static Pool::IterateWrapper<Titem> Iterate(size_t from = 0) { return Pool::IterateWrapper<Titem>(from); }
Copy link
Member

Choose a reason for hiding this comment

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

perhaps a specific const variant could be useful as well?

typedef T* pointer;
typedef T& reference;
typedef size_t difference_type;
typedef std::forward_iterator_tag iterator_category;
Copy link
Member

Choose a reason for hiding this comment

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

these all seem to be unused? Or are they necessary for the iterator "type" ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are necessary if we want to use the iterator in std algorithms like std::distance() or std::count_if().
But they are not needed for range-based for loops.

src/network/network.cpp Outdated Show resolved Hide resolved
src/road_cmd.cpp Outdated Show resolved Hide resolved
@nielsmh nielsmh merged commit e3c75a3 into OpenTTD:master Dec 21, 2019
@glx22 glx22 deleted the iterator branch December 21, 2019 20:40
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.

None yet

3 participants