Compile-Time CRC Table

Hard C++ Optimization Asked at NVIDIA
Solve this problem

Generate a 256-entry CRC-32 lookup table entirely at compile time, so it lands in flash as initialised data with no startup cost.

Constraints

  • The table must be constexpr and usable in a constant expression.
  • Polynomial 0xEDB88320 (reflected).
  • No runtime initialisation loop.
  • static_assert at least one known entry.
  • C++14 or later constexpr rules.
Starter codeC++
1#include <cstdint>2#include <array>3 4// TODO: constexpr CRC-32 table