
From: christopher diggins <cdiggins@videotron.ca>
From: "Peter Dimov" <pdimov@mmltd.net>
IMO, this is how a more realistic example would look like:
[snip]
This is just a reflection of the general "globals are bad" principle.
Most of the application code I have seen written, does so directly to cout rather than to a function parameter. I also don't see any advantage to passing istream and ostream as function parameters, when cin and cout can be easily redirected using rdbuf.
Part of the issue being raised here are whether it is wise to promote code that uses cin and cout in these ways and relies upon redirection via rdbuf() to make them reusable. If a client of your library must rewrite main() in order to make it usable, is it onerous to expect that the code would be altered to use supplied streams rather than cin and cout? Even a slight alteration to your library would provide the same feature set but would encourage clients to write better code in the future. -- Rob Stewart stewart@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;