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

后端 未结 15 2790
清歌不尽
清歌不尽 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条回答
  •  萌比男神i
    2020-11-21 07:15

    When developing and debugging code, leave inline out. It complicates debugging.

    The major reason for adding them is to help optimize the generated code. Typically this trades increased code space for speed, but sometimes inline saves both code space and execution time.

    Expending this kind of thought about performance optimization before algorithm completion is premature optimization.

提交回复
热议问题