4 ms·
I'm not familiar with closures from other languages. What about capturing a shared_ptr by value?
by leni536 10y ago
I'm not familiar with closures from other languages. What about capturing a shared_ptr by value?
- thrownaway2424 10y agoThe thing to keep in mind is that copying a shared_ptr isn't cheap at all. It's a class with a pointer and atomic reference count inside and the atomic inc/dec takes many cycles.
- leni536 10y agoHow does this compare to the cost of a closure in other languages? Yeah atomic reference counts are not cheap, but basically that's the point of a shared_ptr.
- thrownaway2424 10y agoI'm not sure. I don't program in C++ because I want it to have performance comparable to other languages.