I'm looking at this GitHub repository for a drop-in replacement for std::shared_ptr in Visual C++ 6 to modify some old code but I've found that this library is incompatible due a parser error being thrown by the compiler.
I know that nested template classes and friend classes are supported. But this is a template<class U>
which is different from the template of class shared_ptr
and also that the friend class is referencing itself.
What is the purpose of this self-referencing templated friend class and how is it being used?
The problem can be demonstrated without compiling the referenced shared_ptr
library:
template<class T>
class shared_ptr
{
template<class U>
friend class shared_ptr;
};
int main() {
return 0;
}
The compiler throws the following error:
main.cpp(5) : error C2059: syntax error : '<end Parse>'
main.cpp(6) : see reference to class template instantiation 'shared_ptr<T>' being compiled
main.cpp(6) : error C2143: syntax error : missing ';' before '}'
main.cpp(6) : see reference to class template instantiation 'shared_ptr<T>' being compiled
main.cpp(6) : error C2238: unexpected token(s) preceding ';'
main.cpp(6) : see reference to class template instantiation 'shared_ptr<T>' being compiled
I don't need this library as I've been able to work around the issue by using Boost 1.34.1. But I would like to understand this limitation and what it purpose it serves.