Search code examples
c++inline-functions

How to guarantee that a function is inlined in C++


in C++, a function can be defined to be inline using inline key word. It is like the programmer has requested from the compiler to insert the complete body of the function in every place that the function is called.

But as I know compilers are not obligated to respect this request. So is there any way to guarantee that a function is inlined?


Solution

  • Use __forceinline in VC++ and __attribute__((always_inline)) in g++