Template Meta-Programing 初歩 その1 : 階乗
template < int n > struct Factional { enum { value = n * Factional< n - 1 > }; }; template <> struct Factional< 1 > { enum { value = 1 }; }; int i = Factional< 5 >::value; /* i = 120 */
template < int n > struct Factional { enum { value = n * Factional< n - 1 > }; }; template <> struct Factional< 1 > { enum { value = 1 }; }; int i = Factional< 5 >::value; /* i = 120 */