Boost logo

Boost :

From: Kevin Atkinson (kevinatk_at_[hidden])
Date: 2000-03-29 09:36:42


On Wed, 29 Mar 2000, Kevin Atkinson wrote:

> On Wed, 29 Mar 2000, Ian Bruntlett wrote:
>
> > Kevin,
> >
> > > > If I use auto_resource<>, I'd only have to implement two member
> > functions,
> > > > reset() and release(). The class interface would be consistent - as long
> > as
> > > > reset() and release() were implemented correctly.
> > >
> > > 1) I assume you want to free the OS handle when you are done. Well each
> > OS
> > > handle will have to be freed in a different way. So you will still
> > > need to have a different specialization of auto_resource for each
> > handle.
> > Yes, I can live with that. Typically it will be a trivial O.S. call to
> > release the handle.
>
> So you STILL have to write code for each different specialization. What
> is you objection to creation a class to handle the necessary work and
> passing that class in as a parameters. It will involve just as much
> code and will work when the compiler can't tell two different resources
> apart as many OS handles are simply typedef of a integral type.

I should also add that the class that is passed in should have a default
value such as ResourceFree<Type>. You can then provide specializations of
that for particular resources when the resource type is NOT a typedef of
an integral type. This way you will only have to specify this class to
free the resource when it is needed. It is the same idea that SGI STL
used for the hash function.

----
Kevin Atkinson
kevinatk_at_[hidden]
http://metalab.unc.edu/kevina/

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