主要喜欢他的语法着色功能,真的很方便,RSS等方面的功能也很全面......
![](/Emoticons/regular_smile.gif)
测试一下:
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**///////////////////////////////
//Prime.cpp
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
/**///////////////////////////////![](/Images/OutliningIndicators/None.gif)
template<int Val>
struct IntType
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
const static int value = Val ;
};
template<bool flag, typename T, typename U>
struct Select
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
typedef T Result;
};
![](/Images/OutliningIndicators/None.gif)
template<typename T, typename U>
struct Select<false, T, U>
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
typedef U Result;
};
template <unsigned int N,unsigned int x>
struct FindRoot
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
const static int value=Select<(N/x)==x||((N/x+x)/2==x),IntType<x>,FindRoot<N,(N/x+x)/2> >::Result::value;
};
![](/Images/OutliningIndicators/None.gif)
template <unsigned int N>
struct Sqrt
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
const static int value=FindRoot<N,N/2>::value;
};
![](/Images/OutliningIndicators/None.gif)
template <>
struct Sqrt<0> ;
![](/Images/OutliningIndicators/None.gif)
template <int N,int divider>
struct TestPrime
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
const static int value=Select<(N%divider)==0,IntType<0>,TestPrime<N,divider-1> >::Result::value;
};
![](/Images/OutliningIndicators/None.gif)
template <int N>
struct TestPrime<N,1>
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
const static int value=1;
};
![](/Images/OutliningIndicators/None.gif)
template <unsigned int N>
struct IsPrime
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
const static int value=TestPrime<N,Sqrt<N>::value+1>::value;
};
![](/Images/OutliningIndicators/None.gif)
template <>
struct IsPrime<2>
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
const static int value=1;
};
![](/Images/OutliningIndicators/None.gif)
template <>
struct IsPrime<1>;
![](/Images/OutliningIndicators/None.gif)
int printf(const char*,
);
![](/Images/OutliningIndicators/None.gif)
int main()
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ContractedBlock.gif)
{
const int yes=IsPrime<123127>::value;
printf("%d\n",yes);
}
![](/Images/OutliningIndicators/None.gif)