Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

STL class for reference-counted pointers?

This should be trivial but I can't seem to find it (unless no such class exists!)

What's the STL class (or set of classes) for smart pointers?

UPDATE

Thanks for the responses,
I must say I'm surprised there's no standard implementation.

I ended up using this one: http://archive.gamedev.net/reference/articles/article1060.asp

like image 593
hasen Avatar asked Mar 17 '09 06:03

hasen


1 Answers

With the exception of the already mentionned TR1 shared_ptr, there is no reference-counted pointer in STL.

I suggest you use boost::shared_ptr (downloading boost will be enough, there is nothing to compile, its implementation is header-only).

You may also want to have a look at smart pointers from Loki libraries (again, header-only implementation).

For an overview of available smart pointers, see there.

like image 94
Benoît Avatar answered Oct 23 '22 10:10

Benoît