Boost logo

Boost :

From: Martin Schulz (Martin.Schulz_at_[hidden])
Date: 2007-11-06 03:55:43


> >> shared_ptr<FILE> foo(fread("foo.txt","r"),fclose);

Why not something like the following:

shared_ptr<FILE> foo(fopen("foo.txt","r"),
call_if_arg_not_null(fclose));

With call_if_arg_not_null being a functor (based on boost::function or
whatever) that simply calls fclose only if the argument is nonzero.

I think the obvious rationale is that while both approaches have their
merits, you can indeed implement the one based on the other but not vice
versa.

Yours,

-- 
Dr. Martin Schulz (schulz_at_[hidden])
Software Engineer 
Synopsys GmbH 
Karl-Hammerschmidt-Str. 34
D-85609 Dornach, Germany
Munich office: +49 (89) 993-20203
Home office:   +49 (721) 6099511
http://www.synopsys.com
 

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