Code Room
Code reviewHard
Question
Review this C++ async registration using a lambda.
What a strong answer looks like
Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix — specific and kind.
Learn the concepts
#include <functional>#include <string> struct Worker { std::string name; void schedule(std::function<void()>& slot) { slot = [this]() { use(name); }; } void use(const std::string& s);}; std::function<void()> g_slot;void wire() { std::function<void()> tmp; { Worker w{"alpha"}; w.schedule(reinterpret_cast<std::function<void()>&>(tmp)); } g_slot = tmp; g_slot(); // invoked later}Run or narrate your approach, then ask the coach.