What Does It Mean For a C++ Function To Be Inline?

后端 未结 9 786
攒了一身酷
攒了一身酷 2020-12-01 06:12

See title: what does it mean for a C++ function to be inline?

9条回答
  •  一向
    一向 (楼主)
    2020-12-01 06:53

    The function body is literally inserted inside the caller function. Thus, if you have multiple calls to this function, you get multiple copies of the code. The benefit is you get faster execution.

    Usually very short function are inlined, when the copy of the function body would be not much bigger than the usual prologue/epilogue code generated for the normal function call.

    You can read more at MSDN article about inline - http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx

提交回复
热议问题