3 ms·
This could actually change performance though as the lambda version gives you a unique templace instantiation of std::transform while the non-lambda version req
by account42 7y ago
This could actually change performance though as the lambda version gives you a unique templace instantiation of std::transform while the non-lambda version requires std::transform to be inlined into the caller (or cloned to an argument-specific version) before the compiler can make any optimizations based on its knowledge of toupper.
- BeeOnRope 7y agoGood point. I would usually expect std::transform to be inlined, since it is quite simple - but it may not be and it's a very good point in general regarding the optimization probability for function pointers versus lambdas. Ultimately, I ended up reverting the change, so using a lambda based on the advice the taking the address of a standard-library function is verboten, since they may introduce overloads at any time [1]. --- [1] https://twitter.com/foonathan/status/1197051249822195712 https://twitter.com/foonathan/status/1197051249822195712