Object-oriented design patterns in the kernel, part 1
Posted Jun 3, 2011 9:46 UTC (Fri) by
cortana (subscriber, #24596)
In reply to:
Object-oriented design patterns in the kernel, part 1 by Cyberax
Parent article:
Object-oriented design patterns in the kernel, part 1
FYI, you can still use shared_ptr with FILE* (and probably any other C API that follows the same pattern.
shared_ptr<FILE> f (fopen ("whatever", "r"), fclose);
Now, fclose will be called whenever the last copy of that shared_ptr is destructed. No more single exit points, goto tricks, or leaning towers of if statements!
(
Log in to post comments)