Hello, please consider the following code:
template <typename T>
struct foo
{
template <typename S>
struct bar
{
template <typename> friend struct bar;
};
};
I'd like all instantiations of foo<T>::bar
to be friends of foo<T>::bar<S>
for any S
. If bar
is not a nested template, the syntax above works just fine. But when I do for example
int main()
{
foo<int> x;
}
MSVC8 (Visual C++ 2005) doesn't like it:
1>.\main.cpp(11) : error C3855: 'foo<T>::bar': template parameter 'S' is incompatible with the declaration
1> .\main.cpp(12) : see reference to class template instantiation 'foo<T>::bar<S>' being compiled
1> .\main.cpp(14) : see reference to class template instantiation 'foo<T>' being compiled
The compiler gives me the same errors if I use
template <typename> friend struct foo<T>::bar;
instead. How can I achieve what I want ?
EDIT: I double checked (it's morning here, and I'm not really awake), this seems to be a VC8 bug: