|
Boost Users : |
From: Simon Buchan (simon_at_[hidden])
Date: 2005-10-10 01:15:28
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, ...) ?
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net