Every story and comment from the Hacker News API, in a layout borrowed from 2001.
A comment on Calculating integer factorials in constant time, taking advantage of overflow.
template<int64_t n> int64_t fact() { return n * fact<n-1>(); } template<> int64_t fact<0>() { return 1; }
The book "Modern C++ design" from Alexandrescu extensively covers that kind of stuff.
There might even be a way to use a loop and constexprs.
template<int64_t n> int64_t fact() { return n * fact<n-1>(); } template<> int64_t fact<0>() { return 1; }
The book "Modern C++ design" from Alexandrescu extensively covers that kind of stuff.
There might even be a way to use a loop and constexprs.