Boost logo

Boost :

From: Phil Nash (phil.nash.lists_at_[hidden])
Date: 2003-02-21 15:22:56


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" <Sam.Partington_at_[hidden]>
To: "Boost mailing list" <boost_at_[hidden]>
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
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk