Logo

Question preview

Where'd that lambda go?

What this preview is

About this preview

Where'd that lambda go? is a medium quant interview question on language knowledge in Cpp.

Unlock full access to getcracked

Join to unlock this question, detailed solutions, and our complete library of quant finance interview prep.

Understanding lambda capture and temporary object lifetimes in C++

This is a medium-difficulty C++ language-knowledge question that tests your grasp of how lambdas interact with temporary objects and reference semantics. It appears frequently in interviews at firms that care deeply about correctness in systems code, because subtle mistakes around object lifetime can lead to hard-to-debug undefined behaviour.

To solve it, you need to reason carefully about when temporaries are destroyed, what the lambda actually captures (by reference or by value), and whether the code accesses dangling pointers or references. The question rewards candidates who can trace through scope rules and predict program behaviour without relying on compiler-specific quirks.

  • Lambda capture modes: by value vs. by reference
  • Temporary object lifetime and scope
  • Reference binding rules
  • Undefined behaviour and potential crash scenarios