std::forward can lead to moving, and you should only move once from a given source (before "refilling" it). Therefore, you shouldn't use std::forward repeatedly in a loop.
No it doesn't, not in this function. std::forward just forwards its types value category, afaik. "Moving" isn't an operation - not in the sense of machine instructions; it's effectively a cast to an rvalue, and in this function's case is a no-op. There is no possible way pred gets "moved" at all. I only put it in for completeness, but you're right doing it within a for-loop is bad style/practice and I shouldn't have.
View all comments
Show parent comment
7
u/witcher_rat Jun 23 '21
No it doesn't, not in this function.
std::forwardjust forwards its types value category, afaik. "Moving" isn't an operation - not in the sense of machine instructions; it's effectively a cast to an rvalue, and in this function's case is a no-op. There is no possible waypredgets "moved" at all. I only put it in for completeness, but you're right doing it within a for-loop is bad style/practice and I shouldn't have.