Boost logo

Boost :

From: Sam Partington (Sam.Partington_at_[hidden])
Date: 2003-02-21 11:48:17


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


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