This example script compiles cleanly in gcc 8.2, but in Visual Studio 2019 it returns error C3200: 'bar<int>': invalid template argument for template parameter 'bar', expected a class template at the line where the 'new' occurs:
template<typename T, template<typename> class bar>
class foo;
template<typename T>
class bar
{
friend class foo<T, bar>;
};
template<typename T, template<typename> class bar>
class foo
{
};
class baz : bar<int>
{
public:
void mash()
{
auto whoosh = new foo<int, bar>();
}
};
int main(int argc, char **argv)
{
baz A;
A.mash();
return 0;
}
Reading around, I think the problem may be that the second template argument in that line is now a well-defined type rather than a template, but even if that's true I don't know what to do about it. Replacing 'bar' with 'decltype(bar)' didn't get me anywhere.
I would welcome any suggestions.