Boost logo

Boost :

From: Howard Hinnant (hinnant_at_[hidden])
Date: 2006-11-18 10:20:22

<iostream> is the only C++ header that extracts a cost simply by
including it (in typical implementations). The usual implementation
is for it to include a static object of type std::ios_base::Init
which is responsible for initializing the 8 terminal streams (cin,
cout, cerr, clog, wcin, wcout, wcerr, wclog).

I've always thought it good programming practice to avoid including
<iostream> if the translation unit didn't actually need one of these
8 terminal streams. For example if I needed to just get to istream
and ostream to write my own I/O I would include <istream> and
<ostream> but not <iostream> (the naming is very unfortunate).

It has recently come to my attention that I could be overly sensitive
to this issue and making a fuss about nothing. So I'm writing here
for a reality check. Do boost programmers consider the use of
<iostream> as a short cut to get to non-terminal-streams I/O a
reasonable technique? Or do boost programmers feel that use of
<iostream> should be reserved only when using one or more of cin,
cout, cerr, clog, wcin, wcout, wcerr, wclog?

I did a brief survey of boost 1.33.1 and found many "relaxed" uses of
<iostream> under the boost/ directory (i.e. non test-case code). So
in practice it does appear that using <iostream> as a shortcut is
considered acceptable practice. However I wanted to highlight the
point just in case people do view this as a bug that has simply snuck
in under the radar to date.


Boost list run by bdawes at, gregod at, cpdaniel at, john at