我有这种情况:访问嵌套模板参数
template<unsigned int N>
class Base
{
public:
Base(){}
int myint[N];
};
template<unsigned int M>
class BaseWrapper : Base<M>
{
public:
BaseWrapper(){}
};
template<typename T>
class User
{
public:
User(){}
//int myint[T::N]; //How to statically allocate using M or N from above?
};
int main(void)
{
User<BaseWrapper<10> > myuser;
// Do something with User::myint here.
}
我希望能够使用模板参数的非类型参数User
在User
类静态分配数据。我知道我可以使用模板模板参数在User
内部创建BaseWrapper<M>
,但这不是我的首选方法。任何简单的方法来做到这一点?
谢谢!