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

后端 未结 15 2457
清歌不尽
清歌不尽 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:22

    When one should inline :

    1.When one want to avoid overhead of things happening when function is called like parameter passing , control transfer, control return etc.

    2.The function should be small,frequently called and making inline is really advantageous since as per 80-20 rule,try to make those function inline which has major impact on program performance.

    As we know that inline is just a request to compiler similar to register and it will cost you at Object code size.

提交回复
热议问题