Benefits of declaring a function as “inline”?

前端 未结 10 1890
天涯浪人
天涯浪人 2020-12-09 14:01

Every time I read about the \"inline\" declaration in C it is mentioned that it is only a hint to the compiler (i.e. it does not have to obey it). Is there any benefit to ad

10条回答
  •  旧巷少年郎
    2020-12-09 14:16

    The C++ FAQ has good info on this. I prefer to use the inline function as it gives the compiler more information about what I would "like" it to do. Whether or not the compiler ends up inlining it is up to it, but giving it a little help won't hurt.

提交回复
热议问题