使用海湾合作委员会4.2。
我有这个条件类型的元模板:
template <bool condition, typename Then, typename Else>
struct IF
{
typedef Then RET;
};
template <class Then, class Else>
struct IF<false, Then, Else>
{
typedef Else RET;
};
当我这样使用它时:
template <typename T>
class Param
{
IF< sizeof(int)<sizeof(long), long, int>::RET i;
};
它有效,但是当我像这样使用它时(尝试使用模板参数):
template <typename T>
class Param
{
IF< sizeof(int)<sizeof(long), T&, T* >::RET mParam;
};
我收到此错误代码:
error: type 'IF<false, T&, T*>' is not derived from type 'Param<T>'
为什么会发生这种情况?怎么解决呢?
提前致谢!