更新时间:2023-11-02 08:27:22
在第二种情况下,RET
是什么,取决于模板类型T
.需要确保编译器在所有可能的实例化中都将是一种类型(并且可能不是IF某些实例化的静态成员).您可以使用typename
关键字来实现.
In the second case, what RET
is, depends on the template type T
. The compiler needs to be assured that it is going to be a type in all possible instantiations (and not perhaps a static member of some instantiation of IF). You do so with the typename
keyword.
template <typename T>
class Param
{
typename IF< sizeof(int)<sizeof(long), T&, T* >::RET mParam;
};