I think this should work for all the cases you mention: http://www.boost.org/libs/smart_ptr/sp_techniques.html#handle http://www.boost.org/libs/smart_ptr/sp_techniques.html#on_block_exit -delfin
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Aaron W. LaFramboise Sent: Friday, January 21, 2005 2:13 PM To: boost-users@lists.boost.org Subject: Re: [Boost-users] How to automatically release legacy resources?
Mauricio Gomes wrote:
I would create a class (File or other name) that close() on its destructor.
I do not like this solution, but not because it doesn't work. It works just fine, and probably better than the more complicated alternatives that I have been thinking of.
The trouble is that its 'difficult.' Writing a class to do this takes a small but significant amount of effort. Maintaining code with this class be be slightly but significantly more difficult.
In particular, in code specific to a particular problem domain (as opposed to in general-purpose libraries), I don't like to see a whole lot of code that has nothing to do with that domain, or adds a whole lot of structure for very little expressive benefit. This sort of verbosity is a problem--I think--and a particular problem for C++. A significant criticism of C++ that I have heard is that the implementation of many sorts of code requires too structure, so that there is less actual expressive code than non-expressive code.
Aaron W. LaFramboise _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users