ranking Sort Sort   |   date Sort Sort   |   member Sort Sort
Syndication

11
Date Submitted Thu. Aug. 3rd, 2006 11:54 AM
Revision 1
Helper bobbyrward
Tags boost | CPlusPlus | preprocessor | shared_ptr
Comments 0 comments
template function to create a boost::shared_ptr in the form

boost::shared_ptr classPtr = new_ptr(Arg1, Arg2);

You can also make new_ptr_access a friend of className and make the constructor and destructor private.

This keeps the end user from:

Creating an instance manually on the heap
Creating an instance manually on the stack
Deleting a shared_ptr manually using "delete get()"