Table of Contents
Generated lambdas (llmcpp)
Generated lambdas combine a normal C++ lambda interface with a body requested in prose. The modifier appears before the lambda expression:
auto accepted = __llm__ [minimum](int value) -> bool { Return whether value is at least minimum. };
The capture list, parameters, and return type remain C++ syntax. Only the body is generated. In this example, the compiler knows that minimum is captured and that the result must be usable as bool.
The agent receives information about lambda captures and can inspect the surrounding context. It should use the declarations available to that lambda rather than invent additional captures or assume access to unrelated local variables.
The accepted body replaces the request during source rewriting. The resulting closure behaves like an ordinary lambda, including its lifetime and capture semantics. A generated predicate can therefore be passed to algorithms such as std::copy_if without contacting a model while the algorithm runs. Generation changes how its implementation is authored, while C++ governs how it is called.
