A fixed-width formatter sizes its buffers from template parameters — so the digit count of those parameters has to be a compile-time constant too. Divide by ten until it runs out; the only question is expressing that as a recursion the compiler evaluates.
Implement DigitCount<N>::value — the number of decimal digits of N, computed at compile time. DigitCount<12345>::value == 5.
N below 10 is one digit — the base. Otherwise it is 1 + the digits of N / 10.
In C++17 without requires, dispatch the base case through a helper: a bool non-type parameter or a constexpr function both work.
Hit Submit (or ⌘/Ctrl + ↵) — test results will show up here.