Taylor series expansion as constexpr
I'm trying to build a simple sine function using taylor series expansion that can be evaluated at compile time using C++14 constexpr . My code is compiling, but the compiler doesn't generate a constant. sine is defined as follows: template <int P, typename T = double> constexpr T sine(T x) { T result = x; for (int i = 1; i < P; ++i) result += power<T>(-1, i) * power<T>(x, 1 + 2 * i) / factorial<T>(1 + 2 * i); return result; } I can provide code for power and factorial if needed. They are trivial and also constexpr . I'm calling sine from within a loop like this: template <int N> void test