Boost Ref Counting & Smart Pointers

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));

Piyush Kapadia wrote:
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));
http://www.boost.org/libs/smart_ptr/intrusive_ptr.html -- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim - Grafik/jabber.org

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 <class T, typename A1> boost::shared_ptr<T> New ( A1 a1 ) { return boost::shared_ptr<T> ( new T ( a1 ) ); } template <class T, typename A1, typename A2> 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 ); -- -- Marshall Marshall Clow Idio Software <mailto:marshall@idio.com> It is by caffeine alone I set my mind in motion. It is by the beans of Java that thoughts acquire speed, the hands acquire shaking, the shaking becomes a warning. It is by caffeine alone I set my mind in motion.

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 <class T, typename A1> boost::shared_ptr<T> New ( A1 a1 ) { return boost::shared_ptr<T> ( new T ( a1 ) ); }
template <class T, typename A1, typename A2> 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, ...) ?
participants (4)
-
Marshall Clow
-
Piyush Kapadia
-
Rene Rivera
-
Simon Buchan