This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
[v3] bitset shouldn't bring in global I/O objects
- To: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Subject: [v3] bitset shouldn't bring in global I/O objects
- From: Phil Edwards <pedwards at disaster dot jaj dot com>
- Date: Sat, 24 Mar 2001 18:59:43 -0500
Here's a piece of advice that we give to C++ users: The problem with using
the iostream header when all you need are the istream and ostream classes
is that you get the global objects (cin, cout, etc) also -- which means
you also get the static ios_base::Init object. When you only need the
class definition, you should use the istream and/or ostream headers only.
It saves space and startup time.
Well, we should follow this advice in maintainer-land too. std_bitset.h was
including std_iostream.h just to be able to declare op<< and op>> for the
classes, which resulted in references to ios_base::Init from the bitset
header (surely a non sequitur for C++ if ever there was one).
This allows std_bitset.h to do its work without the space/time overhead.
Applied to trunk only, since there is no correctness issue without it,
just a very slight performance one.
2001-03-24 Phil Edwards <pme@sources.redhat.com>
* include/bits/std_bitset.h: Include ostream and istream headers
instead of iostream.
Index: include/bits/std_bitset.h
===================================================================
RCS file: /cvs/gcc/gcc/libstdc++-v3/include/bits/std_bitset.h,v
retrieving revision 1.5
diff -u -3 -p -r1.5 std_bitset.h
--- std_bitset.h 2001/03/04 21:34:00 1.5
+++ std_bitset.h 2001/03/24 23:41:18
@@ -38,7 +38,8 @@
#include <bits/std_stdexcept.h> // for invalid_argument, out_of_range,
// overflow_error
-#include <bits/std_iostream.h> // for istream, ostream
+#include <bits/std_ostream.h> // for ostream (operator<<)
+#include <bits/std_istream.h> // for istream (operator>>)
#define _GLIBCPP_BITSET_BITS_PER_WORD (CHAR_BIT*sizeof(unsigned long))
#define __BITSET_WORDS(__n) \