What are you using for smart pointers these days?

Started by
11 comments, last by hplus0603 18 years, 10 months ago
It should be noted that two smart pointers are currently being reviewed to become part of the C++ standard library, boost::shared_ptr and boost::weak_ptr, its in technical report 1 (TR1), std::tr1::shared/weak_ptr some compilers already implement most of TR1 you can find out the other goodies in the latest draft paper, note mem_fn is in there too cause mem_fun/mem_fun_ref are limited and can't handle smart pointers.

No doubt TR2 is round the corner then i'm guessing 2007/8 will be the year of the next standard revision (last being 2003 TC1) or C++0x by the looks of things.
Advertisement
Quote:Original post by MaulingMonkey
Quote:Original post by Telastyn
Becuase I've yet to get boost to compile nicely,

Make sure you use bjam - using the makefiles yourself is a pain, using bjam I got everything to work first try with no hassle (just followed the instructions in "getting started").
Quote:and I've little direct use for auto_ptr, I've a few places where I've implimented something similar to [but less clean than] MaulingMonkey's example.


You should see all the support code I've got for it. Clean on the outside, but a horrible mess on the inside I assure you :-). I even pulled in <boost/function.hpp> so I could implement operator->* so I could implement industry::mem_fun_ptr which is just like std::mem_fun only it works with anything that's got ->* defined... not only that, but I have no less than 6 overloads just for ->* at the moment, and that dosn't even allow me to use a two-argument functions with it...


Ah, I did not mean less clean, I meant... erm, less good. Heh. The actual implimentation isn't so much a smart_pointer implimentation as a quick hack to make a pure virtual class pointer die at end of scope and not be totally broken when placed into containers.

One of these days I'll learn not to make those quick hacks...

And for Boost, I was actually using my OS's supplied package. Example code just didn't compile nicely... I tried using bjam &#111;n my windows machine [a while ago], and bjam wouldn't even install. <br><br>Nothing from google, the faq, the install documentation, or in the &#111;ne case my post here really helped, and I'm not nearly skilled enough to muck through makefiles or template magickry to make it work. *shrug* I figure &#111;ne of these times it'll work.<br><br>
Whatever the library provides that I'm using.

I e, for Win32 stuff, and ATL/WTL, I'll use CComPtr. For boost stuff, I'll use boost::shared_ptr where possible. For Ogre, I'll use Ogre::ResoucePtr. Etc.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement