3 ms·
In principle there is no difference, in practice until relatively recently some popular compilers would fail to inline calls via function pointers. The reason i
by gpderetta 11y ago
In principle there is no difference, in practice until relatively recently some popular compilers would fail to inline calls via function pointers. The reason is that the inliner would need to run after constant propagation and after the HOF function itself, i.e. sort, has been inlined. With function objects and templates you get a distinct instance of sort for each callback type so the target is known statically even before any optimisation starts.