When should I write the keyword 'inline' for a function/method?

后端 未结 15 2459
清歌不尽
清歌不尽 2020-11-21 06:55

When should I write the keyword inline for a function/method in C++?

After seeing some answers, some related questions:

  • When should I <

15条回答
  •  名媛妹妹
    2020-11-21 07:01

    gcc by default does not inline any functions when compiling without optimization enabled. I don't know about visual studio – deft_code

    I checked this for Visual Studio 9 (15.00.30729.01) by compiling with /FAcs and looking at the assembly code: The compiler produced calls to member functions without optimization enabled in debug mode. Even if the function is marked with __forceinline, no inline runtime code is produced.

提交回复
热议问题