According to Scott Meyers, one area where C++ shines over C is that function objects are faster than function pointers. He says this is because function objects are inlined, whi
Yes, function objects might lead to faster code. But the only way to ensure that is to benchmark.
The documentation says: "GCC may still be unable to inline a function for many reasons; the -Winline
option may be used to determine if a function has not been inlined and why not."
Of course it will depend on compiler, version, flags, etc. Sometimes inlining can be counter-productive (code bloat etc.), so each compiler has its own set of rules to decide whether a function should be inlined. By the way, the inline
keyword is only a hint, and some libraries such as eigen have a hard time to enforce inlining.