
6 Nov
2007
6 Nov
'07
8:55 a.m.
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@synopsys.com) 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