-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
added: make CFileItemList iterable #11003
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this. I was always too lazy to do it :-/
@@ -723,6 +723,9 @@ class CFileItemList : public CFileItem | |||
const std::string &GetContent() const { return m_content; }; | |||
|
|||
void ClearSortState(); | |||
|
|||
VECFILEITEMS::const_iterator begin() { return m_items.begin(); } | |||
VECFILEITEMS::const_iterator end() { return m_items.end(); } |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
On purpose. We do not want a mutable iterator, CFileItemList is based on Add () paradigm. The compiler is smart enough but if you want explicit you shall have explicit give me 15mins to get home . |
1cb9d0a
to
747fe4e
Compare
meh. you are of course completely correct, my left hand had forgotten to commit the const versions which i realized was needed after testing. i thought you were (only) referring to begin() and end() returning const iterators wanting cbegin cend non-const overloads when i wrote ^^ (and obviously i "read" your comment too fast..). i did learn something new though - the compiler will not consider non-const overloads of cbegin|cend at all. i have kept the code that was there and added the missing cbegin() cend() implementations. if you want mutable iteration, just say so. i gave my reasoning above, it just seemed to break surrounding design to me. |
No I don't want mutable iterators because it will break stuff that works when using |
jenkins build this please |
Should there be any updates/changes or can this be merged? |
747fe4e
to
4871e9c
Compare
as far as i am concerned it should be as ok. i need the explicit begin() / end() because the compiler is too stupid to constify on its own (i.e. if the CFileItemList is not in a const context it won't consider cbegin() / cend()). |
jenkins build and merge this please |
Let's try again. jenkins build and merge this please |
Just gave it a try and it doesn't work in all cases. E.g. when I have a
so we are missing the |
This makes CFileItemList iterable, i.e.