namespace KS
{
namespace Math
{
template <unsigned int Limit, typename T>
struct E
{
//static const T result;
};
template <unsigned int Limit>
struct E <Limit, float>
{
static const float result;
};
template <>
const float E <0, float>::result = 1.0f;
// Assume that KS::Math::Factoral does return a succesful factorial, which tests show that it does
template <unsigned int Limit>
const float E <Limit, float>::result = ((KS::Math::E<(Limit - 1), float>::result) + (1.0f / KS::Math::Factorial<(Limit)>::result));
}
}
// Here is my test code
std::cout << KS::Math::E<0, float>::result << std::endl;
std::cout << KS::Math::E<1, float>::result << std::endl;
std::cout << KS::Math::E<2, float>::result << std::endl;
std::cout << KS::Math::E<6, float>::result << std::endl;