【发布时间】:2014-05-07 06:51:21
【问题描述】:
我必须处理一个代码,我对此感到非常困惑。
#include <iostream>
template<class T, T t = T()>
class A
{
private:
template<bool b>
class B
{
public:
static const int m_n = b ? 1 : 0;
};
public:
static const int m_value = B<(t > T())>::m_n - B<(t < T())>::m_n;
};
int main()
{
std::cout << A<int, -9>::m_value
<< A<bool, true>::m_value
<< A<char>::m_value << std::endl;
return 0;
}
你能评论一下下面这行吗?
static const int m_value = B<(t > T())>::m_n - B<(t < T())>::m_n;
这里如何使用greater和less运算符?
我不知道第二个模板是如何使用的:
template<bool b>
【问题讨论】:
-
你到底有什么不明白的?