All challenges
Multiple ChoiceIntermediate 45s

Stateless lambda to function pointer

When can a lambda be converted to a plain function pointer?
Options
  1. 1Always, regardless of captures, because the closure type converts to a pointer through an implicit conversion.
  2. 2When it has no captures (an empty closure), so it can decay to a pointer to its static call operator.
  3. 3Never; a lambda can never become a plain function pointer and must always be wrapped in std::function.
  4. 4Only if the lambda is declared mutable, since a mutable operator() has the required function-pointer layout.

Think you can answer under pressure?

Get matched and answer live questions in 3-minute 1v1 battles. Elo ranking, badge tiers and bragging rights on the line.

Play this in a 3-minute battle