Logo

Coding preview

Compile Time FindIf

What this preview is

About this preview

Compile Time FindIf is a hard quant coding problem on language knowledge in Cpp, asked at Quant.

Unlock full access to getcracked

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

Compile-time template metaprogramming with variadic search

This hard C++ coding problem tests your ability to implement a compile-time algorithm using template metaprogramming. It requires you to build a functor that searches a heterogeneous compile-time collection and returns an optional containing the first element that satisfies a given predicate, or std::nullopt if no match exists.

The challenge sits at the intersection of variadic templates, recursive template instantiation, and constexpr evaluation. You must design a template structure that can iterate through a type-level sequence, apply a predicate at compile time, and halt on the first match. All work happens during compilation; static assertions verify correctness. This skill is uncommon outside high-performance and systems programming roles, but quant firms that build custom DSLs or compile-time optimisation frameworks value it highly.

  • Variadic template parameter unpacking and recursion
  • Index-based compile-time access to tuple-like structures
  • Constexpr lambda captures and predicate application
  • Type-level vs. value-level computation in templates