When do compilers inline C++ code?

前端 未结 11 1177
孤独总比滥情好
孤独总比滥情好 2020-11-29 08:07

In C++, do methods only get inlined if they are explicitly declared inline (or defined in a header file), or are compilers allowed to inline methods as they see

11条回答
  •  隐瞒了意图╮
    2020-11-29 08:47

    The inline keyword is just a request to the compiler. The compiler reserves the right to make or not make a function inline. One of the major factor that drives the compiler's decision is the simplicity of code(not many loops)

    Member functions are declared inline by default.(The compiler decides here also)

    These are not hard and fast rules. It varies according to the compiler implementations.

    If anybody knows other factors involved, please post.

提交回复
热议问题