On Nov 26, 2014, at 11:10 AM, Olaf van der Spek
On Thu, Nov 20, 2014 at 9:10 AM, Olaf van der Spek
wrote: On Wed, Nov 19, 2014 at 1:47 PM, Sylvester-Bradley, Gareth
wrote: shared_ptr/unique_ptr work fine for me with FILE*, one only has to write a deleter. A dedicated class would be needed for POSIX file descriptors though.
Peter Sommerlad and Andrew L. Sandoval's unique_resource RAII proposal uses both FILE* and POSIX file descriptors as examples. I think this is the latest revision: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4189.pdf
It does solve the RAII part but it doesn't provide a standard interface for native IO.
Not many responses... Does noone use native IO?
I use POSIX I/O calls frequently. I adapted Lisa Lippincott and Marshall Clow's work on Nitrogen to create a library called poseven, based on the same 'nucleus' core library. p7::fd_t is an enum type for a file descriptor, and n::ownedp7::fd_t and n::sharedp7::fd_t are smart resources that work like unique_ptr and shared_ptr (loosely speaking) respectively. Much of it is about a decade old, early in my exposure to generic programming, though just recently I added p7::coprocess. Let me know if you're interested in more info. https://github.com/jjuran/metamage_1/tree/master/posix/poseven/poseven/types https://github.com/jjuran/metamage_1/tree/master/posix/poseven/poseven/funct... Josh