In inline functions, scalar types should be passed by value or reference?

132 Views Asked by At

I know, the question of passing scalars by value vs. by reference has been asked and answered gazillion times before, and I know - in general - they should be passed by value. But what about inline functions? And the reason I ask this is I just did some refactoring with Visual Studio 2022, and when I called VS's "Extract Function" command, it extracted the scalar variables like constant reference (e.g. const int &).

Does VS know something I don't in relation to inline functions, or should I double check and override the code generated by VS?

Edit #1: I also noticed, when pointers were passed as parameters, it didn't use the inline keyword. Is it because it knows these functions cannot be inlined? If yes, why?

Edit #2: It also did some other funny things. For example: (Vehicle *& vehicle_ptr) It just referenced a pointer. I think it proves that VS does the function extraction using some very simple script.

0

There are 0 best solutions below