我不得不处理一个我完全困惑的代码。对模板感到困惑
#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;
如何更大和少运营商在这里使用?
我不能找出如何第二模板用于:
template<bool b>
你不明白什么? – juanchopanza