I'm not sure if this question has been asked and i couldn't find an example in all of my searches. But I'd like to write a class that would perform substitution of keywords while some other class is reading from it. I was thinking about getting streambuf from ios::rdbuf() and performing all the substitutions and then setting it back but that approach make take some time with big files. If my understanding is correct about how streambuf class works. Can anybody suggest a way of inheriting from iostream and doing the substitution on-the-fly ?