I would recommend that your version of flush incorporate cout.flush(), otherwise it can be misinterpreted by a user, at it doesn't actually flush the stream, which is the whole point of endl.