Wrapping FILE* with custom std::ostream
I have a function which works with a std::ostream . I need to support using a C file handle ( FILE* ). Should I be creating my own subclass of std::ostream which delegates to a FILE* ? As Ben Voigt points out, you want to subclass streambuf . There are pages on the University of Southern California's website which have the documentation , header , and source for a GNU implementation of a streambuf subclass ( stdiobuf ) that wraps a FILE* . It has some dependencies on the library it is a part of (GroovX), but those should be easily to remove (I would begin by removing all references to GVX