std::tr1::shared_ptr equivalent in MS VC6

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
Hi Guys,

My apologies, this is in fact a simple truncation error! It seems VC6 has a limit of 255 characters for identifiers which is just totally useless when using STL inside my classes... there's just no way I can shrink the length of the identifiers...

Thanks anyway if you took a look at this.
First, why do you need a map to count references?
+1 for moorecm's question

Have you tried actually constructing the map dynamically? It may still fail... I mean, pointers on their own don't cause a template to be instantiated.

Regards
Topic archived. No new replies allowed.