# Generated templates (llmcpp) **Generated templates** request one reusable implementation expressed in terms of template parameters. The repository's top-k example specifies ordering and tie behavior: ```cpp template __llm__ auto top_k_by(const Range &values, std::size_t count, Projection project) -> std::vector { Return at most count elements from values with the greatest project value. Order results from greatest to least, preserving input order for ties. } ``` The body must use the supplied range and projection rather than assume a particular record type. The return type depends on `Range::value_type`, which Clang interprets as C++ syntax. llmcpp generates one template body, not one body per instantiation. Candidate compilation checks what is visible and instantiated in the translation unit. Other argument types may expose errors later, so tests should cover the kinds of ranges and projections the interface promises to support. Source: [11_top_k_by.cpp](https://github.com/yanevskiv/llmcpp/blob/main/examples/11_top_k_by.cpp).