Comments on my answer here have made me think about how one might implement the same pattern I’ve been doing with C++ streams. Specifically, I need to be able to have a function which can write to the console, a file, or a string/memory buffer. I don’t need most of the formatting features and such that IOStreams provide. Is there some better design which would allow this type of redirection idiomatically that’s commonly used in other circles?
for example – for testing I need to be able to write to a string, but for real program use it’s always going to be going to a file or the console.
Totally untested, but you get the idea.
Personally, I think iostream is just great. If I need to go fast, I’ll write a fast parser.
printfstill has a lot of room for speed improvement… it’s a nice middle ground, I suppose, but still just a compromise.