Step 6 of 6
Challenge: compile-time computation
constexpr functions can run during compilation when their inputs are constants. The result is baked into the program as a literal, and static_assert can check it. Lookup tables, hashes of fixed strings, unit conversions and configuration validation are often done this way in performance-critical code.
Since C++20, constexpr functions may use loops, local variables, std::array and even std::vector (as long as it doesn't escape).
Your turn:
constexpr std::array<int, N> first_primes<N>(): the first N primesconstexpr std::uint32_t hash32(std::string_view s): 32-bit FNV-1a (start2166136261u, for each byteh ^= byte; h *= 16777619u;)
Both must work at compile time: the tests use them inside static_assert.