Example 1: Compile-time Square Root Computation: ceil(sqrt(N)) (Note: I found this snippet on the web somewhere) // : template struct Root; template struct Root { static const int root = Mid; }; template struct Root { static const int mean = (Low + High)/2; static const bool down = (mean * mean >= Size); static const int root = Root::root; }; // User code: // compute sqrt(N), use it for static table size int table[Root::root];