Original Post
🔒 Locked
Inline functions?
Advertisement
Useful reading
Also the first item in Scott Meyers Effective C++ explains why you should prefer inline functions to macros.
Also the first item in Scott Meyers Effective C++ explains why you should prefer inline functions to macros.
Quote:
Original post by Bargaust
Is the typical C++ compiler (in my case, VC++) clever enough to automatically inline a very simple accessor method (that just returns a private member variable), or would I need to specify 'inline' myself?
It should be, yes. You could give a 'hint' to the compiler by declaring it inline (or even force it by using __forceinline), but VC should be smart enough to figure that out for itself.
I tend to use 'inline' as a hint to anyone else reading the code rather than the compiler since, as I understand it, the compiler will pretty much do what it wants anyways. Your compiler optimization settings (size vs speed, etc) probably have a bigger influence on whether a function is actually inlined or not than using the keyword in the source code.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement