Peter suggested I use shared_count when I first started talking about
smart_resource (or shared_resource as I was then calling it) over a year
ago - so it's not a new thing :-)

[)o
IhIL..

----- Original Message -----
From: "Sam Partington" <[EMAIL PROTECTED]>
To: "Boost mailing list" <[EMAIL PROTECTED]>
Sent: Friday, February 21, 2003 5:48 PM
Subject: Re: [boost] smart_ptr vs smart_resource


> Neat!
>
> Have you just unwittingley submitted shared_resource?
>
> Sam
>
> Peter Dimov wrote:
> > You might want to use detail::shared_count instead. It may be
> > undocumented but it works and it sure isn't going away since that's
> > what shared_ptr uses under the hood.
> >
> > #include <boost/detail/shared_count.hpp>
> > #include <iostream>
> >
> > int get_int_based_resource()
> > {
> >     std::cout << "get_int_based_resource()\n";
> >     return 0;
> > }
> >
> > void release_int_based_resource(int r)
> > {
> >     std::cout << "release_int_based_resource(" << r << ")\n";
> > }
> >
> > template<class X> class resource
> > {
> > public:
> >
> >     template<class D> resource(X x, D d): x_(x), n_(x, d)
> >     {
> >     }
> >
> > private:
> >     X x_;
> >     boost::detail::shared_count n_;
> > };
> >
> > int main()
> > {
> >     resource<int> r(get_int_based_resource(),
> >     release_int_based_resource); resource<int> r2(r);
> > }
>
> _______________________________________________
> Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost
>

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to