Boost logo

Boost :

From: Daniel Frey (daniel.frey_at_[hidden])
Date: 2004-07-01 04:48:25


Hi,

I just wrote a small helper function to clear a container. Well, OK, we
already have that, do we? For a container 'cont':

   cont.clear();

But this doesn't neccessarily free the memory allocated. The "usual"
workaround is:

   Cont().swap( cont );

But Cont (the type of the container) is sometimes rather large and the
code doesn't communicate well what I intended.

I thus wrote the following small helper:

   template< typename T > void reset( T& t )
   {
     T().swap( t );
   }

Would this make a good addition to boost.utility? Any comments welcome...

Regards, Daniel

-- 
Daniel Frey
aixigo AG - financial solutions & technology
Schloß-Rahe-Straße 15, 52072 Aachen, Germany
fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
eMail: daniel.frey_at_[hidden], web: http://www.aixigo.de

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