Marshall Clow wrote:
At 10:08 PM -0400 10/7/05, Piyush Kapadia wrote:
Does Boost Library internally does Reference counting for most of its internal objects ?
Does it also use it's shared_ptr kind of Smart pointer implementation internally ?
Sorry for my ignorance, but isn't there any cleaner Smart Pointer implementation where we don't have to use new every time initiating object and smart pointer becomes part of the class rather that separate implementation like following -
shared_ptr sp(new int(5));
How about (untested code, but I have something pretty similar in my code):
template <class T> boost::shared_ptr<T> New () { return boost::shared_ptr<T> ( new T ); }
template
boost::shared_ptr<T> New ( A1 a1 ) { return boost::shared_ptr<T> ( new T ( a1 ) ); } template
boost::shared_ptr<T> New ( A1 a1, A2 a2 ) { return boost::shared_ptr<T> ( new T ( a1, a2 ) ); } and so on.
Then can you just say: shared_ptr<int> sp = New<int> ( 5 );
I assume you mean (A1 const & a1, A2 const & a2, ...) ?