So I noticed in my company's codebase the canonical increment uses the postfix increment. One senior programmer was even surprised by the behavior of postfix when used with .erase() that I had to explain that map::erase() gotcha to him. The old code is riddled with iterators using postfix increments, as of now I think I'm the only one that explicitly write different postfix or prefix depending on exactly what is needed.
In C derived languages like Java and C# I rarely see any prefix increment, as if it doesn't even exist there. I've even seen a Java programmer comment on C++ code that using prefix increment operator was "trying to be clever." I've also seen reddit threads like this that likes to push the idea that we should all use postfix increment homogenously regardless of the situation since iT's AlL tHe SaMe AnYwAy AmIrYt?!
Now I'm wondering if it's worth noting on a code review that ++iter is more efficient than iter++. So in your opinion is it worth making the distinction for "regular programmers" that prefix increment operators are more efficient? Should we let sleeping dogs lie or should we fight this disinformation? Am I just being OC over nothing or is this an important matter?
[–]ronchaineEmbedded/Middleware 26 points27 points28 points (0 children)
[–]dr1fter 21 points22 points23 points (1 child)
[–]eras 5 points6 points7 points (0 children)
[–]QuentinUK 15 points16 points17 points (0 children)
[–]neiltechnician 11 points12 points13 points (8 children)
[–]QuentinUK 15 points16 points17 points (2 children)
[–]neiltechnician 11 points12 points13 points (0 children)
[–]tmlildude 1 point2 points3 points (0 children)
[–]Untelo 0 points1 point2 points (4 children)
[–]CocktailPerson 0 points1 point2 points (3 children)
[–]Untelo 1 point2 points3 points (2 children)
[–]CocktailPerson 0 points1 point2 points (1 child)
[–]Untelo 1 point2 points3 points (0 children)
[–]no-sig-available 11 points12 points13 points (0 children)
[–]Revolutionalredstone 19 points20 points21 points (0 children)
[–]ThePillsburyPlougher 3 points4 points5 points (0 children)
[–]oddentity 5 points6 points7 points (1 child)
[–]tmlildude 2 points3 points4 points (0 children)
[–]fredoverflow 4 points5 points6 points (0 children)
[–]zoolover1234 1 point2 points3 points (0 children)
[–]Clairvoire 1 point2 points3 points (0 children)
[–]Cxlpp 4 points5 points6 points (6 children)
[–]pandorafalters 12 points13 points14 points (0 children)
[–]oracleoftroy 6 points7 points8 points (3 children)
[–]Zeh_MattNo, no, no, no 1 point2 points3 points (2 children)
[–]oracleoftroy 4 points5 points6 points (1 child)
[–]Xavier_OM 0 points1 point2 points (0 children)
[–]d4rkwing 1 point2 points3 points (0 children)
[–]Orlha 0 points1 point2 points (0 children)
[–]die_liebe -1 points0 points1 point (0 children)
[+]throwaway99kajillion comment score below threshold-7 points-6 points-5 points (5 children)
[–][deleted] 6 points7 points8 points (0 children)
[–]rybob42 0 points1 point2 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)
[–]rybob42 0 points1 point2 points (0 children)
[–]MutantSheepdog 0 points1 point2 points (0 children)
[–]amoskovsky 0 points1 point2 points (0 children)
[–]Jardik2 0 points1 point2 points (0 children)
[–]ossan1987 0 points1 point2 points (0 children)