Benefits of inline functions in C++?

后端 未结 14 1393
终归单人心
终归单人心 2020-11-22 05:30

What is the advantages/disadvantages of using inline functions in C++? I see that it only increases performance for the code that the compiler outputs, but with today\'s opt

14条回答
  •  孤街浪徒
    2020-11-22 06:04

    Our computer science professor urged us to never use inline in a c++ program. When asked why, he kindly explained to us that modern compilers should detect when to use inline automatically.

    So yes, the inline can be an optimization technique to be used wherever possible, but apparently this is something that is already done for you whenever it's possible to inline a function anyways.

提交回复
热议问题