-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Fix warning C26817 on copying in for (auto vh : value_and_holder(...))
#2382
Conversation
…nge-for loop. Consider making it a const reference (es.71).
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.
value_and_holder
shouldn't be too expensive to copy (and quite optimizable, even, I'd think?), but I see no immediate reason why this wouldn't work, so why not! 👍
for (auto vh : value_and_holder(...))
In theory, Besides the |
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.
Good catch, @bstaletic
… with `auto vh &` (found by @bstaletic)
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.
I've made those changes and pushed them. Let's see if CI turns nicely green.
Green, green, green, green, green, ... Thanks for reporting and fixing, @MichaelGoulding! |
Thanks, for fixing up the last bit. @YannickJadoul |
C26817: Potentially expensive copy of variable 'vh' in range-for loop. Consider making it a const reference (es.71).
EDIT (@YannickJadoul): Fixes #2379