Somehow both less and more cursed than expected.
Since printf is almost Turing complete (difficult or impossible to have loops that’s standard compliant?), it might be possible to pass printf to qsort. The array passed in needs careful engineering though.
And I thought that C++ template metaprogramming was fun, this is even better :)