Should I pay attention on const modifier working with primitive types? Which one is more syntactically correct and why?
First version:
f
I am going to say that with primitives it may well be more efficient to actually copy them. When you pass a reference, the compiler still has to pass bytes on the stack, and then has to dereference the address to get the content.
In addition, passing by value overcomes any possible concurrency / volatility issues regarding the memory of what is being passed.
It's a case of "don't try to optimise here".
Returning by const is style. I usually don't, others prefer to just in case someone is gonig to do something with the returned value. Next you'll find people returning them by r-value reference...
I would normally go for your first option. The other alternative is pass by value (not necessary to use const) and return by const value.