Question 13
Back to Exercise
When is std::function<void(int)> the right choice?
- A Always, instead of auto
- B When you need to store callables of different types behind one signature, e.g. a vector of callbacks Correct
- C For the fastest calls
- D To make lambdas recursive in C++23
Correct Answer: Option B
It erases the type at a small run-time cost; auto and templates keep the exact type.
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!