iterator cleanup in several places - #2164
Conversation
|
You're probably right. What would you suggest I use for a Or are you only suggesting this for the longer |
|
For simple cases like that (literally two rows of code) |
|
Ok, I believe I have addressed the naming issues. I have also cleaned up a few more places in the code where range-based |
|
You can't do this It's going to segfault. |
|
@UdjinM6 Works fine in my test. Code: https://gitlab.com/nmarley/cpptest/blob/master/range-for-modify.cpp Output: https://gist.github.com/nmarley/c28de321bd15d1205900b1cf9d595d2e |
|
|
@UdjinM6 Sorry, should be public now. And you're right, looks like this code was "working" because of some internal ordering of keys. Once I tried deleting element I will go back and refactor (or revert) these. I was hoping to get rid of all the incrementing iterator |
|
Well, if that was the goal, you could probably try smth like: EDIT: or if you REEEALLY want to use :) |
|
The problem with the approach above is that this way you always create a copy, even if you don't need it, while with EDIT: however for small maps the overhead is probably negligible. |
|
Well, my idea was actually to invert the if / else condition such that I can |
|
I've reverted changes where I made the false assuption that a container being iterated over could be modified using range-based for, which isn't the case. Also rebased onto the latest |
|
Just had one question on the rationale for edit: I fast-forwarded my branch tip to include your commits directly. |
* iterator cleanup in Dash-specific code * const * *Pair/pair * it++ -> ++it
Please see individual commits. A few notes:
autoand range-basedfor