Multiple ChoiceBeginner 45s
Init-capture move semantics
What does the init-capture `[p = std::move(ptr)]` accomplish in a lambda?
Options
- 1It captures ptr by reference but renames the reference to p, so no ownership is transferred to the closure.
- 2It is invalid syntax; a lambda cannot move-capture, and only plain by-copy or by-reference capture is allowed.
- 3It creates a copy of ptr, because a lambda always copies captures and never moves them into the closure.
- 4It moves ptr into a new closure member, allowing the lambda to own it and be safely returned.
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.