Square root metafunction?
问题 Is it possible to compute the square root of an integer with a metafunction with the following signature : template<unsigned int N> inline double sqrt(); (or maybe using the constexpr keyword, I don't know what is the best). With that, sqrt<2>() would be replaced by 1.414... at compile-time. What would be the best implementation for a such function ? 回答1: This may not be what you are looking for, but I wanted to make sure you realized that typically with optimization the compiler will