TL;DR
The article discusses the interconversion between std::function and copyable_function, highlighting design flaws and the importance of avoiding unnecessary allocations. Key outcomes include recommendations for implementors to enhance performance.
✦ Why It Matters
Review your use of std::function and consider implementing copyable_function to optimize performance.
Key Takeaways
How It Works
std::copyable_function allows for efficient interconversion with std::function, enabling callable objects to be copied without unnecessary heap allocations. This is achieved by ensuring that both types can hold any copyable and callable object, streamlining the process of moving between them.
⚠ The Catch
Mixing std::function and std::copyable_function can lead to performance degradation due to the creation of a 'linked list' of callables, which slows down function calls.
Related