I am new to c++ and need help with metaprogramming. I have checked out the enum example wherein the call factorial<4>::value yields 24.
What I need is a modification to the code so that factorial<4>() returns 24. Have been trying it for quite some time now and do not know how to exactly search for it on the internet too. Any help would be much appreciated. Thank you !
Here is what I have at the moment:
template <int N> struct factorial { enum { value = N * factorial<N - 1>() }; }; template <> struct factorial<0> { enum { value = 1 }; };