Can modern C++ compilers inline functions that are defined in a cpp file

后端 未结 4 1128
无人及你
无人及你 2020-12-09 03:10

I am aware that the keyword inline has useful properties e.g. for keeping template specializations inside a header file. On the other hand I have often read tha

4条回答
  •  心在旅途
    2020-12-09 03:44

    Within the compilation unit the compiler will have no problem inline functions (even if they are not marked as inline). Across compilation units it is harder but modern compilers can do it.

    Use of the inline tag has little affect on 'modern' compilers and whether it actually inlines functions (it has better heuristics than the human mind) (unless you specify flags to force it one way or the other (which is usually a bad idea as humans are bad at making this decision)).

提交回复
热议问题