65,211
社区成员
发帖
与我相关
我的任务
分享
//For the if condition
template<bool C>
class IfCondition {};
template<>
class IfCondition<true>
{
public:
inline static void DoFun()
{
using namespace std;
cout << "Now is the true time" << endl;
}
};
template<>
class IfCondition<false>
{
public:
inline static void DoFun()
{
using namespace std;
cout << "Now is the false time" << endl;
}
};
IfCondition< (2>3) >::DoFun(); //编译器常量表达式可以
int a = 2; int b = 3;
IfCondition< (a>b) >::DoFun(); //不行.
const int a = 2; const int b = 3;
IfCondition< (a>b) >::DoFun(); //OK.