我想做以下事情:
template <typename T>
struct foo
{
template <typename S>
friend struct foo<S>;
private:
// ...
};
但是我的编译器(VC8)对此感到窒息:
error C3857: 'foo<T>': multiple template parameter lists are not allowed
我想要所有可能的朋友template struct foo
的实例化。foo<T>
T
我如何使这项工作?
编辑:这个
template <typename T>
struct foo
{
template <typename>
friend struct foo;
private:
// ...
};
似乎可以编译,但它正确吗?朋友和模板的语法非常不自然。