Hi Guys,
In VS2010 C++ I can use std::tr1::shared_ptr all well and fine. However, in MS VC6 this isn't implemented - VC6 before TR1... doh! However, I also apparently can't use the boost library as VC6 does not support partial specialisation. Therefore, I'm looking for an implementation of a shared pointer and am currently trying to write my own (very simple) version.
I am implementing a really simple shared pointer class. To do this I am going to use a map to keep track of all pointers so that I can count references.
One thing is confusing me at the moment though...
1 2 3 4 5 6 7 8 9 10 11 12
|
class MyClass;
class MySPtr
{
private:
typedef std::map<MyClass*, unsigned int> MyMap;
MyMap myMap;
...
... more code ...
...
};
|
The above fails to compile in VC6... the build output looks like the compiler has gotten stuck in some continual loop?! Messages also indicate some truncation of identifiers which could be the problem.
However, if I change
MyMap mymap
to
MyMap *myMap
all becomes well again and allocating the map isn't going to be that tough.
So, my question is, why does having an encapsulated map rather than a pointer to a map cause such problems?
Any help greatly appreciated as I'm rather stumped :-S
Many thanks,
James