// templates.h #ifndef TEMPLATES_H #define TEMPLATES_H template class Factorial { public: enum { val = i * Factorial::val }; }; template<> class Factorial<0> { public: enum { val = 1 }; }; #define Fact(X) (Factorial::val) #endif // TEMPLATES_H // templates_main.cpp #include "templates.h" #include using namespace std; int main(int argc, char** argv) { int val = Factorial<10>::val; // mov dword ptr [val],375F00h <---- Single move instruction cout << "Factorial<10>::val = " << val << endl; // mov dword ptr [val],375F00h <---- Single move val = Fact(10); cout << "Fact(10) = " << val << endl; return 0; }