Is it more performant to use function pointers? I was under the impression that lambdas are performant in C++, given that it’s just syntactic sugar for function objects (functors). I know std::function isn’t as performant since the compiler cannot inline, due to inability to deduce the function.
What is the use case of this?
Is it more performant to use function pointers? I was under the impression that lambdas are performant in C++, given that it’s just syntactic sugar for function objects (functors). I know std::function isn’t as performant since the compiler cannot inline, due to inability to deduce the function.
The use case is outlined in the example.
If you are asking what we get by avoiding the two types to be different, then:
- if the types are the same, they can be stored in a container
- if the types are the same, the type will be generated only once, affecting compilation speed and size of the binary