Quote:Original post by Kest
I just cranked my compiler up from level 3 to level 4 warnings, and there's a lot of work here. One of the warnings pertain to something that I've really relied on:
warning C4239: nonstandard extension used : 'argument' : conversion from 'Class' to 'Class &'.
This is indeed a non-standard extension - by the standard, writing the code this way (without const-correctness) is an *error*. Strange that you'd only get a warning at level 4 for that. :
The philosophy is that if you create a temporary, then you are saying you don't care about it - and don't have a way to check any changes to the object - which is mutually incompatible with the idea of passing it to a function that is expected to create such changes. If the function *does* modify the value, you can always set aside a variable for it separately. Sometimes it helps to make an anonymous scope for the "temporaries" plus the call. But otherwise, FFS be const-correct :)