That may be the case, but there are plenty of examples of elegant implementations.
JUCE, for instance:
#include <juce_core/juce_core.h>
class MyComponent {
public:
void doAsyncOperation(std::function<void(int)> callback) {
// Simulate async work
juce::MessageManager::callAsync([callback]() {
callback(42); // Call the functor with result
});
}
};
// Usage
MyComponent comp;
comp.doAsyncOperation([](int result) {
juce::Logger::writeToLog("Callback received with: " + juce::String(result));
});
.. I think that's kind of clean and readable, but ymmv, I guess?