Listing 5

// Original prime number generator with debugging code included.

template<int P, int I> struct CIsPrime
{
   enum { result = ( P == 2 ) || ( P % I ) && 
                          CIsPrime<( I > 2 ? P : 0), I-1>::result } ;
   typedef CIsPrime<P, I> This;            // Compile-time
   static CMetaProgramDebug<This> m_debug; // debug code
} ;
template<int P, int I> CMetaProgramDebug<CIsPrime<P, I> > 
                                            CIsPrime<P, I>::m_debug;