diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index a9cd3fc3606..dc3d498cc13 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,26 @@
+2001-10-09 Phil Edwards Chapter 17 is actually a list of definitions and descriptions used
in the following chapters of the Standard when describing the actual
@@ -27,7 +27,7 @@
Chapter 17: Library Introduction
+Chapter 17: Library Introduction
<foo>
vs <foo.h>
-
@@ -92,9 +92,9 @@
an application for high-speed using this implementation of the STL.
Here is one possible example displaying the forcing of the malloc-based
allocator over the typically higher-speed default allocator:
-
+
std::list <void*, std::malloc_alloc> my_malloc_based_list;
-
+
A recent journal article has described "atomic integer operations," which would allow us to, well, perform updates @@ -177,10 +177,10 @@
+
See license.html for copying conditions.
Comments and suggestions are welcome, and may be sent to
-the mailing list.
+the libstdc++ mailing list.
As long as this sentence is in place, this page isn't
official. It is still experimental if you are reading this. There are two licenses affecting GNU libstdc++-v3: one for the code, and
one for the documentation. Here we will describe both of them, and try
- to answer some of the common questions. If you have more questions, ask the
- FSF or the gcc-help mailing list; the person writing this page is a
- programmer, not a lawyer.
+ to answer some of the widespread questions. If you have more questions,
+ ask the FSF or the
+ gcc mailing list; the person
+ writing this page is a programmer, not a lawyer.
Licenses for the Library
+Licenses for the Library
@@ -44,8 +45,7 @@ official. It is still experimental if you are reading this.
Hopefully that text is self-explanatory. If it isn't, you need to speak - to your lawyer, or the Free Software Foundation. I am not a legal expert. - I do not even play one on television. + to your lawyer, or the Free Software Foundation.
-
-Comments and suggestions are welcome, and may be sent to
-the mailing list.
+
+Comments and suggestions about this page are welcome, and may be sent to
+the libstdc++ mailing list.
+Comments or questions about the licenses themselves are also welcome, and
+should be directed to the GCC list as descibed above.
Chapter 18 deals with the functions called and objects created
automatically during the course of a program's existence.
@@ -59,7 +59,7 @@
not overload on pointer-vs-integer types to begin with. He also
offers a way to make your own magic NULL that will match pointers
before it matches integers:
- Chapter 18: Library Support
+Chapter 18: Library Support
+
(Cribbed from the published version of
the
Effective C++ CD, reproduced here with permission.)
const // this is a const object...
class {
public:
@@ -76,7 +76,7 @@
// taken (see Item 27)...
} NULL; // and whose name is NULL
-
(Cribbed from the published version of
+
foo(0);
instead of foo(NULL);
, then you're back
where you started.
- Added Note: When we contacted Dr. Meyers to ask permission to +
Added Note: When we contacted Dr. Meyers to ask + permission to print this stuff, it prompted him to run this code through current compilers to see what the state of the art is with respect to member template functions. He posted @@ -106,12 +107,12 @@
-
<limits>
<limits>
numeric_limits
defined as follows:
- + template classnumeric_limits
defined as follows: +template<typename T> struct class { static const bool is_specialized; static T max() throw(); @@ -147,7 +148,7 @@ static const bool traps; static const bool tinyness_before; static const float_round_style round_style; - };+ };
Return to top of page or to the FAQ. @@ -171,7 +172,7 @@ (This isn't actually new.)
+then at a call ofextern "C or C++" void f1 (void); extern "C or C++" void f2 (void); @@ -179,7 +180,7 @@ atexit(f1); static Thing obj2; atexit(f2); -then at a call ofexit()
, f2 will be called, then +
exit()
, f2 will be called, then
obj2 will be destroyed, then f1 will be called, and finally obj1
will be destroyed. If f1 or f2 allow an exception to propogate
out of them, Bad Things happen.
@@ -221,9 +222,9 @@
By default, if one of the "throwing new
s" can't
allocate the memory requested, it tosses an instance of a
bad_alloc
exception (or, technically, some class derived
- from it). You can change this by writing your own function (called
- a new-handler) and then registering it with set_new_handler()
:
-
+ from it). You can change this by writing your own function (called a + new-handler) and then registering it withset_new_handler()
: +typedef void (*PFV)(void); static char* safety; @@ -242,10 +243,10 @@ int main () { safety = new char[500000]; - old_handler = set_new_handler (&my_new_handler); + old_handler = set_new_handler (&my_new_handler); ... } -+
bad_alloc
is derived from the base exception
class defined in Chapter 19.
@@ -256,15 +257,13 @@
-
-
+
See license.html for copying conditions.
Comments and suggestions are welcome, and may be sent to
-the mailing list.
+the libstdc++ mailing list.
Chapter 19 deals with program diagnostics, such as exceptions
and assertions. You know, all the things we wish weren't even
@@ -38,20 +38,19 @@
place). It's good to remember that you can add your own data to
these exceptions when extending the heirarchy:
Return to top of page or
to the FAQ.
+
See license.html for copying conditions.
Comments and suggestions are welcome, and may be sent to
-the mailing list.
+the libstdc++ mailing list.
Chapter 20 deals with utility classes and functions, such as
the oft-debated AP is meant to prevent nasty leaks in the presence of
exceptions. That's all. This code is AP-friendly:
- Changing that code as follows is not AP-friendly:
- Chapter 19: Diagnostics
+Chapter 19: Diagnostics
- using std::runtime_error;
- struct My_Exception : public runtime_error
+
+ struct My_Exception : public std::runtime_error
{
public:
My_Exception (const string& whatarg)
- : runtime_error(whatarg), e(errno), id(GetDataBaseID()) { }
+ : std::runtime_error(whatarg), e(errno), id(GetDataBaseID()) { }
int errno_at_time_of_throw() const { return e; }
DBID id_of_thing_that_threw() const { return id; }
protected:
int e;
DBID id; // some user-defined type
};
-
+
-Chapter 20: General Utilities
+Chapter 20: General Utilities
auto_ptr<>
.
@@ -47,7 +47,7 @@
+
When an exception gets thrown, the instance of MyClass that's
been created on the heap will be
// not a recommend naming scheme, but good for web-based FAQs
typedef std::auto_ptr<MyClass> APMC;
@@ -62,20 +62,20 @@
function_taking_MyClass_pointer (ap.get());
}
-
When an exception gets thrown, the instance of MyClass that's
+ delete
'd as the stack is
unwound past func()
.
+
You will get the same problems as you would without the use
of AP:
-
APMC ap (new MyClass[22]);
-
You will get the same problems as you would without the use
+
+
char* array = new char[10]; // array new...
...
delete array; // ...but single-object delete
-
+
AP cannot tell whether the pointer you've passed at creation points to one or many things. If it points to many things, you are about @@ -92,12 +92,12 @@
All of the containers described in the standard library require their contained types to have, among other things, a copy contructor like this: -
+Note the const keyword; the object being copied shouldn't change. The template classstruct My_Type { My_Type (My_Type const&); }; -+
auto_ptr
(called AP here) does not
meet this requirement. Creating a new AP by copying an existing
@@ -106,14 +106,14 @@
copy ctors of AP do not take const objects.
The resulting rule is simple: Never ever use a container of - auto_ptr objects. The standard says that undefined behavior - is the result, but it is guaranteed to be messy. + auto_ptr objects. The standard says that "undefined" + behavior is the result, but it is guaranteed to be messy.
To prevent you from doing this to yourself, the concept checks built in to this implementation will issue an error if you try to compile code like this: -
+Should you try this with the checks enabled, you will see an error.#include <vector> #include <memory> @@ -121,7 +121,7 @@ { std::vector< std::auto_ptr<int> > vec_ap_int; } -+
Return to top of page or @@ -151,16 +151,16 @@
Construction is simple. The default ctor initializes each member with its respective default ctor. The other simple ctor, -
+does what you think it does,pair (const T1& x, const T2& y); -does what you think it does,first
gettingx
+
first
getting x
and second
getting y
.
There is a copy constructor, but it requires that your compiler handle member function templates: -
+The compiler will convert as necessary from U to T1 and from V to T2 in order to perform the respective initializations.template <class U, class V> pain (const pair<U,V>& p); -The compiler will convert as necessary from U to T1 and from +
The comparison operators are done for you. Equality
@@ -173,10 +173,10 @@
The less-than operator is a bit odd the first time you see it. It
is defined as evaluating to:
-
+
The other operators are not defined using the
x.first < y.first ||
( !(y.first < x.first) && x.second < y.second )
-
+ rel_ops
functions above, but their semantics are the same.
Finally, there is a template function called make_pair
that takes two references-to-const objects and returns an
instance of a pair instantiated on their respective types:
-
+pair<int,MyClass> p = make_pair(4,myobject); -+
Return to top of page or to the FAQ. @@ -198,10 +198,10 @@
+
See license.html for copying conditions.
Comments and suggestions are welcome, and may be sent to
-the mailing list.
+the libstdc++ mailing list.
Chapter 21 deals with the C++ strings library (a welcome relief).
Chapter 21: Strings
+Chapter 21: Strings
+
#include <iostream>
#include <string>
#include <sstream>
@@ -78,11 +78,11 @@
<< " and 3*N was " << (3*the_number);
return output_stream.str();
- }
+ }
A serious problem with CString is a design bug in its memory allocation. Specifically, quoting from that same message: -
+CString suffers from a common programming error that results in poor performance. Consider the following code: @@ -103,7 +103,7 @@ If you replace CString with string in the above function, the performance is O(n). -+
Joe Buck also pointed out some other things to keep in mind when comparing CString and the Standard string class: @@ -143,7 +143,7 @@ is identical to the standard 'string' class, but is case-insensitive in the same way as the (common but nonstandard) C function stricmp():" -
+ci_string s( "AbCdE" ); // case insensitive @@ -152,7 +152,7 @@ // still case-preserving, of course assert( strcmp( s.c_str(), "AbCdE" ) == 0 ); - assert( strcmp( s.c_str(), "abcde" ) != 0 );+ assert( strcmp( s.c_str(), "abcde" ) != 0 );
The solution is surprisingly easy. The original answer pages @@ -165,7 +165,8 @@ here.
See? Told you it was easy!
-Added June 2000: The May issue of C++ Report contains +
Added June 2000: The May issue of C++ Report + contains a fascinating article by Matt Austern (yes, the Matt Austern) on why case-insensitive comparisons are not as easy as they seem, and why creating a class is the wrong way to go about it in @@ -178,7 +179,7 @@ that nobody ever called me on it...) The GotW question and answer remain useful instructional tools, however.
-Added September 2000: James Kanze provided a link to a +
Added September 2000: James Kanze provided a link to a Unicode Technical Report discussing case handling, which provides some very good information. @@ -208,20 +209,20 @@ comments on what kind of string it will accept). The author uses a more general (but less readable) form of it for parsing command strings and the like. If you compiled and ran this code using it: -
+You would see this as output: -std::list<string> ls; stringtok (ls, " this \t is\t\n a test "); for (std::list<string>const_iterator i = ls.begin(); i != ls.end(); ++i) { std::cerr << ':' << (*i) << ":\n"; - }+ }
+with all the whitespace removed. The original:this: :is: :a: - :test:+ :test:
s
is still
available for use, ls
will clean up after itself, and
ls.size()
will return how many tokens there were.
@@ -235,7 +236,7 @@
with reading the new function names, this version is recommended
as an example.
- Added February 2001: Mark Wilden pointed out that the +
Added February 2001: Mark Wilden pointed out that the
standard std::getline()
function can be used with standard
istringstreams to perform
tokenizing as well. Build an istringstream from the input text,
@@ -256,7 +257,7 @@
This code will go through some iterations (no pun). Here's the simplistic version usually seen on Usenet: -
++ Note that these calls all + involve the global C locale through the use of the C functions#include <string> #include <algorithm> #include <cctype> // old <ctype.h> @@ -273,9 +274,9 @@ // result in a different string std::string capital_s; capital_s.reserve(s.size()); - std::transform (s.begin(), s.end(), capital_s.begin(), tolower);- Note that these calls all involve - the global C locale through the use of the C functions + std::transform (s.begin(), s.end(), capital_s.begin(), tolower);
toupper/tolower
. This is absolutely guaranteed to work --
but only if the string contains only characters
from the basic source character set, and there are only
@@ -285,11 +286,11 @@
characters (hahahahahaha), then you're done.
At minimum, you can write short wrappers like -
+char toLower (char c) { return tolower(static_cast<unsigned char>(c)); - }+ }
The correct method is to use a facet for a particular locale
and call its conversion functions. These are discussed more in
@@ -302,7 +303,7 @@
like transformations, this task is trivial with the use of string's
find
family. These examples are broken into multiple
statements for readability:
-
+Obviously, the calls tostd::string str (" \t blah blah blah \n "); // trim leading whitespace @@ -311,7 +312,7 @@ // trim trailing whitespace notwhite = str.find_last_not_of(" \t\n"); - str.erase(notwhite+1);+ str.erase(notwhite+1);
find
could be inserted directly
into the calls to erase
, in case your compiler does not
optimize named temporaries out of existance.
@@ -322,14 +323,13 @@
-
+
See license.html for copying conditions.
Comments and suggestions are welcome, and may be sent to
-the mailing list.
+the libstdc++ mailing list.
Chapter 22 deals with the C++ localization facilities.
Notes made during the implementation of locales can be found
- here.
+ Notes made during the implementation of locales can be found
+ here.
Notes made during the implementation of codecvt can be found
- here.
+ Notes made during the implementation of codecvt can be found
+ here.
The following is the abstract from the implementation notes:
- The following is the abstract from the implementation notes:
+ Chapter 22: Localization
+Chapter 22: Localization
class locale
-
class codecvt
-
+
+
The standard class codecvt attempts to address conversions between
different character encoding schemes. In particular, the standard
attempts to detail conversions between the implementation-defined
@@ -63,18 +63,19 @@
requirements are addressed, and examples of correct usage for both
the required specializations for wide and narrow characters and the
implementation-provided extended functionality are given.
-
+
Notes made during the implementation of ctype can be found - here. +
Notes made during the implementation of ctype can be found + here.
Notes made during the implementation of messages can be found - here. +
Notes made during the implementation of messages can be found + here.
He also writes: -
+Please note that I still consider this detailed description of - locales beyond the needs of most C++ programmers. It is written + locales beyond the needs of most C++ programmers. It is written with experienced programmers in mind and novices will do best to avoid it. -+
An article entitled "The Standard C++ Locale" was - published in Dr. Dobb's Journal and can be found +
An article entitled "The Standard C++ Locale" was + published in Dr. Dobb's Journal and can be found here.
A very common question on newsgroups and mailing lists is, "How do I do <foo> to a character string?" where <foo> is a task such as changing all the letters to uppercase, to lowercase, @@ -130,7 +131,7 @@ is created. Then member functions of that locale are called to perform minor tasks. Continuing the example from Chapter 21, we wish to use the following convenience functions: -
+This function extracts the appropriate "facet" from the locale loc and calls the appropriate member function of that facet, passing c as its argument. The resulting character @@ -153,7 +154,7 @@ parameter. So we write simple wrapper structs to handle that.namespace std { template <class charT> charT @@ -138,7 +139,7 @@ template <class charT> charT tolower (charT c, const locale& loc) const; - }+ }
The next-to-final version of the code started in Chapter 21 looks like: -
+#include <iterator> // for back_inserter #include <locale> #include <string> @@ -198,7 +199,7 @@ std::transform (s.begin(), s.end(), std::back_inserter(capital_s), up ); - }+ }
The final version of the code uses bind2nd
to eliminate
the wrapper structs, but the resulting code is tricky. I have not
@@ -210,10 +211,10 @@
+
See license.html for copying conditions.
Comments and suggestions are welcome, and may be sent to
-the mailing list.
+the libstdc++ mailing list.
Chapter 23 deals with container classes and what they offer.
Chapter 23: Containers
+Chapter 23: Containers
The result is that if all your algorithm calls look like -
- std::transform(beginof(foo), endof(foo), beginof(foo), SomeFunction);+
+ std::transform(beginof(foo), endof(foo), beginof(foo), SomeFunction);then the type of foo can change from an array of ints to a vector of ints to a deque of ints and back again, without ever changing any client code. @@ -84,8 +84,8 @@ give the extra three lines and avoid confusion.
Second, the line -
- inline unsigned int lengthof (T (&)[sz]) { return sz; }+
+ inline unsigned int lengthof (T (&)[sz]) { return sz; }looks just weird! Hint: unused parameters can be left nameless.
Return to top of page or @@ -96,14 +96,14 @@
No, you cannot write code of the form -
+because#include <bitset> void foo (size_t n) { std::bitset<n> bits; .... - }+ }
n
must be known at compile time. Your compiler is
correct; it is not a bug. That's the way templates work. (Yes, it
is a feature.)
@@ -117,7 +117,8 @@
A very large N in bitset<N>
. It has
+
A very large N in
+ bitset<N>
. It has
been pointed out a few times in newsgroups that N bits only takes up
(N/8) bytes on most systems, and division by a factor of eight is pretty
impressive when speaking of memory. Half a megabyte given over to a
@@ -136,7 +137,8 @@
there may be zero space overhead, but it's all allocated inside the
object.)
A container<bool>. The Committee made provision +
A container<bool>. The Committee
+ made provision
for the space savings possible with that (N/8) usage previously mentioned,
so that you don't have to do wasteful things like
Container<char>
or
@@ -148,14 +150,15 @@
normal vector anymore. There have been recent journal articles which
discuss the problems (the ones by Herb Sutter in the May and
July/August 1999 issues of
- C++ Report cover it well). Future revisions of the ISO C++
+ C++ Report cover it well). Future revisions of the ISO C++
Standard will change the requirement for vector<bool>
specialization. In the meantime, deque<bool>
is
recommended (although its behavior is sane, you probably will not get
the space savings, but the allocation scheme is different than that
of vector).
Extremely weird solutions. If you have access to +
Extremely weird solutions. If you have + access to the compiler and linker at runtime, you can do something insane, like figuring out just how many bits you need, then writing a temporary source code file. That file contains an instantiation of @@ -260,8 +263,8 @@
Section [23.1.2], Table 69, of the C++ standard lists this function for all of the associative containers (map, set, etc): -
- a.insert(p,t);+
+ a.insert(p,t);where 'p' is an iterator into the container 'a', and 't' is the item to insert. The standard says that "iterator p is a hint pointing to where the insert should start to search," but @@ -349,13 +352,13 @@
For now you can simply make a temporary string object using the constructor expression: -
+instead of -std::bitset<5> b ( std::string("10110") ); -+
+std::bitset<5> b ( "10110" ); // invalid -+
Return to top of page or to the FAQ. @@ -365,10 +368,10 @@
+
See license.html for copying conditions.
Comments and suggestions are welcome, and may be sent to
-the mailing list.
+the libstdc++ mailing list.
Chapter 24 deals with the FORTRAN subroutines for automatically
transforming lemmings into gold.
@@ -50,7 +50,7 @@
of overhead. (If you think that's the case anywhere, you don't
understand templates to begin with...) Oh, no; if you pass
in a pointer, then the compiler will instantiate that template
- using T* as a type and good old high-speed pointer arithmetic as
+ using T* as a type, and good old high-speed pointer arithmetic as
its operations, so the resulting code will be doing exactly the same
things as it would be doing if you had hand-coded it yourself (for
the 273rd time).
@@ -101,7 +101,7 @@
So, when you think of two pointers delimiting an array, don't think
of them as indexing 0 through n-1. Think of them as boundary
markers:
- Chapter 24: Iterators
+Chapter 24: Iterators
+
See? Everything between the boundary markers is part of the array.
Simple.
beginning end
| |
@@ -121,7 +121,7 @@
| | dereference 'end'.
beginning end
-
+
+
See license.html for copying conditions.
Comments and suggestions are welcome, and may be sent to
-the mailing list.
+the libstdc++ mailing list.
Chapter 25 deals with the generalized subroutines for automatically
transforming lemmings into gold.
@@ -49,9 +49,9 @@
example, Chapter 25: Algorithms
+Chapter 25: Algorithms
string::find()
). Most of the examples on this
page will use simple arrays of integers as a playground for
algorithms, just to keep things simple.
- The use of N as a size in the examples is
- to keep things easy to read but probably won't be legal code. You can
- use wrappers such as those described in the
+ The use of N as a size in the
+ examples is to keep things easy to read but probably won't be valid
+ code. You can use wrappers such as those described in the
containers chapter to keep
real code readable.
-
Return to top of page or to the FAQ.
@@ -93,10 +91,10 @@
+
See license.html for copying conditions.
Comments and suggestions are welcome, and may be sent to
-the mailing list.
+the libstdc++ mailing list.
Chapter 26 deals with building block abstractions to aid in
numerical computing:
Chapter 26: Numerics
+Chapter 26: Numerics
All of the Standard C math functions are of course included in C++,
@@ -48,7 +48,7 @@
compiled a list of C++98 and C99 conflict points; his description of
C's new type versus those of C++ and how to get them playing together
nicely is
-here.
+here.
valarray<>
and complex<>
.
- accumulate
;
- inner_product
; partial_sum
and
+ accumulate
,
+ inner_product
, partial_sum
, and
adjacent_difference
.
complex<>
is intended to be instantiated with a
floating-point type. As long as you meet that and some other basic
@@ -66,9 +66,9 @@
One of the major reasons why FORTRAN can chew through numbers so well
is that it is defined to be free of pointer aliasing, an assumption
- that C89 is not allowed to make, and neither is C++. C99 adds a new
- keyword, restrict
, to apply to individual pointers. The C++
- solution is contained in the library rather than the language
+ that C89 is not allowed to make, and neither is C++98. C99 adds a new
+ keyword, restrict
, to apply to individual pointers. The
+ C++ solution is contained in the library rather than the language
(although many vendors can be expected to add this to their compilers
as an extension).
Here is a simple example of the two forms of accumulate
.
-
+The first call adds all the members of the array, using zero as an initial value forint ar[50]; int someval = somefunction(); @@ -111,7 +111,7 @@ int sum = std::accumulate(ar,ar+50,0); int sum_stuff = std::accumulate(ar,ar+50,someval); int product = std::accumulate(ar,ar+50,1,std::multiplies<int>()); -+
sum
. The second does the same, but uses
someval
as the starting value (thus, sum_stuff == sum +
@@ -136,7 +136,8 @@
neccessary support for C99 (e.g., header files) cannot be found.
As of GCC 3.0, C99 support includes classification functions
- such as isnormal
, isgreater
, isnan
, etc.
+ such as isnormal
, isgreater
,
+ isnan
, etc.
The functions used for 'long long' support such as strtoll
are supported, as is the lldiv_t
typedef. Also supported
are the wide character functions using 'long long', like
@@ -151,10 +152,10 @@
-
+
See license.html for copying conditions.
Comments and suggestions are welcome, and may be sent to
-the mailing list.
+the libstdc++ mailing list.
diff --git a/libstdc++-v3/docs/html/27_io/howto.html b/libstdc++-v3/docs/html/27_io/howto.html
index 943cad08bdc..ec516d12db7 100644
--- a/libstdc++-v3/docs/html/27_io/howto.html
+++ b/libstdc++-v3/docs/html/27_io/howto.html
@@ -1,17 +1,17 @@
-
-
-
-
-
+
+
+
+
+
libstdc++-v3 HOWTO: Chapter 27
-
+
-Chapter 27: Input/Output
+Chapter 27: Input/Output
Chapter 27 deals with iostreams and all their subcomponents
and extensions. All kinds of fun stuff.
@@ -39,21 +39,21 @@
So you want to copy a file quickly and easily, and most important,
completely portably. And since this is C++, you have an open
ifstream (call it IN) and an open ofstream (call it OUT):
-
+
#include <fstream>
std::ifstream IN ("input_file");
- std::ofstream OUT ("output_file");
+ std::ofstream OUT ("output_file");
Here's the easiest way to get it completely wrong:
-
- OUT << IN;
+
+ OUT << IN;
For those of you who don't already know why this doesn't work
(probably from having done it before), I invite you to quickly
create a simple text file called "input_file" containing
the sentence
-
- The quick brown fox jumped over the lazy dog.
+
+ The quick brown fox jumped over the lazy dog.
surrounded by blank lines. Code it up and try it. The contents
of "output_file" may surprise you.
@@ -75,8 +75,8 @@
as well as the streams themselves. The pointer is easily retrieved
using the rdbuf()
member function. Therefore, the easiest
way to copy the file is:
-
- OUT << IN.rdbuf();
+
+ OUT << IN.rdbuf();
So what was happening with OUT<<IN? Undefined
behavior, since that particular << isn't defined by the Standard.
@@ -121,17 +121,17 @@
is the effect you want when writing to a screen -- get the text
out as soon as possible, etc -- but the buffering is largely
wasted when doing this to a file:
-
+
output << "a line of text" << endl;
output << some_data_variable << endl;
- output << "another line of text" << endl;
+ output << "another line of text" << endl;
The proper thing to do in this case to just write the data out
and let the libraries and the system worry about the buffering.
If you need a newline, just write a newline:
-
+
output << "a line of text\n"
<< some_data_variable << '\n'
- << "another line of text\n";
+ << "another line of text\n";
I have also joined the output statements into a single statement.
You could make the code prettier by moving the single newline to
the start of the quoted text on the thing line, for example.
@@ -139,9 +139,9 @@
If you do need to flush the buffer above, you can send an
endl
if you also need a newline, or just flush the buffer
yourself:
-
+
output << ...... << flush; // can use std::flush manipulator
- output.flush(); // or call a member fn
+ output.flush(); // or call a member fn
On the other hand, there are times when writing to a file should
be like writing to standard error; no buffering should be done
@@ -149,7 +149,7 @@
log file for security-related information). The way to do this is
just to turn off the buffering before any I/O operations at
all have been done, i.e., as soon as possible after opening:
-
+
std::ofstream os ("/foo/bar/baz");
std::ifstream is ("/qux/quux/quuux");
int i;
@@ -158,7 +158,7 @@
is.rdbuf()->pubsetbuf(0,0);
...
os << "this data is written immediately\n";
- is >> i; // and this will probably cause a disk read
+ is >> i; // and this will probably cause a disk read
Since all aspects of buffering are handled by a streambuf-derived
member, it is necessary to get at that member with rdbuf()
.
@@ -334,7 +334,7 @@
transforms everything sent through it to uppercase. This version
assumes many things about the nature of the character type being
used (for more information, read the books or the newsgroups):
-
+
#include <iostream>
#include <streambuf>
#include <locale>
@@ -365,13 +365,13 @@
// create special output buffer
outbuf ob;
// initialize output stream with that output buffer
- std::ostream out(&ob);
+ std::ostream out(&ob);
out << "31 hexadecimal: "
<< std::hex << 31 << std::endl;
return 0;
}
-
+
Try it yourself!
@@ -407,14 +407,14 @@
Because the C++ library includes the C library, both C-style and
C++-style I/O have to work at the same time. For example:
-
+
#include <iostream>
#include <cstdio>
std::cout << "Hel";
std::printf ("lo, worl");
std::cout << "d!\n";
-
+
This must do what you think it does.
Alert members of the audience will immediately notice that buffering
@@ -434,11 +434,11 @@
when both libraries' facilities are in use. If your program only uses
C++ I/O, then there's no need to sync with the C streams. The right
thing to do in this case is to call
-
+
#include any of the I/O headers such as ios, iostream, etc
std::ios::sync_with_stdio(false);
-
+
You must do this before performing any I/O via the C++ stream objects.
Once you call this, the C++ streams will operate independantly of the
@@ -446,9 +446,10 @@
company will become fully buffered on their own.
Note, by the way, that the synchronization requirement only applies to
- the standard streams (cin
, cout
, cerr
,
+ the standard streams (cin
, cout
,
+ cerr
,
clog
, and their wide-character counterparts). File stream
- objects that you create yourself have no such requirement and are fully
+ objects that you declare yourself have no such requirement and are fully
buffered.
@@ -456,10 +457,10 @@
-
+
See license.html for copying conditions.
Comments and suggestions are welcome, and may be sent to
-the mailing list.
+the libstdc++ mailing list.
diff --git a/libstdc++-v3/docs/html/configopts.html b/libstdc++-v3/docs/html/configopts.html
index 13ceb8c6dd6..48222427366 100644
--- a/libstdc++-v3/docs/html/configopts.html
+++ b/libstdc++-v3/docs/html/configopts.html
@@ -1,16 +1,16 @@
-
-
-
-
+
+
+
+
libstdc++-v3 configure options
-
+
-Interesting configure
+Interesting configure
options
The latest version of this document is always available at
@@ -89,7 +89,7 @@ options
(IEEE Std. 1003.1-200x) model based on langinfo/iconv/catgets,
'gnu' to specify a model based on functionality from the GNU C
library (langinfo/iconv/gettext) (from glibc, the GNU C
+ href="http://sources.redhat.com/glibc/">glibc, the GNU C
library), or 'generic' to use a generic "C"
abstraction which consists of "C" locale info. The
default is 'generic'.
@@ -167,16 +167,16 @@ options
the following puts all the libstdc++ headers into a directory
called "2.97-20001008" instead of the usual
"g++-v3".
-
- --with-gxx-include-dir=/foo/H-x86-gcc-3-c-gxx-inc/include/2.97-20001008
+
+ --with-gxx-include-dir=/foo/H-x86-gcc-3-c-gxx-inc/include/2.97-20001008
--enable-cxx-flags=FLAGS
With this option, you can pass a string of -f (functionality)
flags to the compiler to use when building libstdc++. FLAGS
is a quoted string of options, like
-
- --enable-cxx-flags='-fvtable-gc -fomit-frame-pointer -ansi'
+
+ --enable-cxx-flags='-fvtable-gc -fomit-frame-pointer -ansi'
Note that the flags don't necessarily have to all be -f flags,
as shown, but usually those are the ones that will make sense
for experimentation and configure-time overriding.
@@ -187,13 +187,13 @@ options
as well, so that everything matches.
Fun flags to try might include combinations of
-
+
-fstrict-aliasing
-fno-exceptions
-ffunction-sections
- -fvtable-gc
- and opposite forms (-fno-) of the same. Tell us (the mailing
- list) if you discover more!
+ -fvtable-gc
+ and opposite forms (-fno-) of the same. Tell us (the libstdc++
+ mailing list) if you discover more!
--enable-c-mbchar
[default]
@@ -207,17 +207,17 @@ options
Return to the top of the page or
- to the homepage.
+ to the libstdc++ homepage.
-
+
See license.html for copying conditions.
Comments and suggestions are welcome, and may be sent to
-the mailing list.
+the libstdc++ mailing list.
diff --git a/libstdc++-v3/docs/html/documentation.html b/libstdc++-v3/docs/html/documentation.html
index 9fa26684acf..e7cc3b06f04 100644
--- a/libstdc++-v3/docs/html/documentation.html
+++ b/libstdc++-v3/docs/html/documentation.html
@@ -1,8 +1,8 @@
-
+
Standard C++ Library v3
-
+
@@ -96,13 +96,13 @@
-Return to the homepage.
+Return to the libstdc++ homepage.
-
+
See license.html for copying conditions.
Comments and suggestions are welcome, and may be sent to
-the mailing list.
+the libstdc++ mailing list.
diff --git a/libstdc++-v3/docs/html/explanations.html b/libstdc++-v3/docs/html/explanations.html
index db54b0865ca..d7bf585eae8 100644
--- a/libstdc++-v3/docs/html/explanations.html
+++ b/libstdc++-v3/docs/html/explanations.html
@@ -1,16 +1,16 @@
-
-
-
-
+
+
+
+
Explanatory notes about libstdc++-v3 design
-
+
-Explanatory notes about libstdc++-v3
+Explanatory notes about libstdc++-v3
design
The latest version of this document is always available at
@@ -64,10 +64,10 @@ design
-
+
See license.html for copying conditions.
Comments and suggestions are welcome, and may be sent to
-the mailing list.
+the libstdc++ mailing list.
diff --git a/libstdc++-v3/docs/html/ext/howto.html b/libstdc++-v3/docs/html/ext/howto.html
index 0252388b3ae..10e5c261f30 100644
--- a/libstdc++-v3/docs/html/ext/howto.html
+++ b/libstdc++-v3/docs/html/ext/howto.html
@@ -1,23 +1,23 @@
-
-
-
-
-
+
+
+
+
+
libstdc++-v3 HOWTO: Extensions
-
+
-Extensions
+Extensions
Here we will make an attempt at describing the non-Standard extensions to
the library. Some of these are from SGI's STL, some of these are GNU's,
and some just seemed to appear on the doorstep.
-Before you leap in and use these, be aware of two things:
+
Before you leap in and use these, be aware of two things:
- Non-Standard means exactly that. The behavior, and the very
existence, of these extensions may change with little or no
@@ -48,14 +48,14 @@
Ropes and trees and hashes, oh my!
The SGI headers
-
+
<bvector>
<hash_map>
<hash_set>
<rope>
<slist>
<tree>
-
are all here; <bvector>
exposes the old bit_vector
+
are all here; <bvector>
exposes the old bit_vector
class that was used before specialization of vector<bool> was
available (it's actually a typedef for the specialization now).
<hash_map>
and <hash_set>
@@ -87,17 +87,17 @@
Why would you want to use a hashing class instead of the
"normal" implementations? Matt Austern writes:
-
[W]ith a well chosen hash function, hash tables
+ [W]ith a well chosen hash function, hash tables
generally provide much better average-case performance than binary
search trees, and much worse worst-case performance. So if your
implementation has hash_map, if you don't mind using nonstandard
components, and if you aren't scared about the possibility of
pathological cases, you'll probably get better performance from
- hash_map.
+ hash_map.
- (Side note: for those of you wondering, "Why wasn't a hash
- table included in the Standard in the first #!$@ place?" I'll
- give a quick answer: it was proposed, but too late and in too
+
(Side note: for those of you wondering, "Why wasn't a hash
+ table included in the Standard in the first #!$@ place?"
+ I'll give a quick answer: it was proposed, but too late and in too
unorganized a fashion. Some sort of hashing will undoubtedly be
included in a future Standard.
@@ -309,10 +309,10 @@
-
+
See license.html for copying conditions.
Comments and suggestions are welcome, and may be sent to
-the mailing list.
+the libstdc++ mailing list.
diff --git a/libstdc++-v3/docs/html/ext/sgiexts.html b/libstdc++-v3/docs/html/ext/sgiexts.html
index 12ed15cd304..bc54b358ae1 100644
--- a/libstdc++-v3/docs/html/ext/sgiexts.html
+++ b/libstdc++-v3/docs/html/ext/sgiexts.html
@@ -1,16 +1,16 @@
-
-
-
-
+
+
+
+
SGI extensions to the library in libstdc++-v3
-
+
-SGI extensions to the library in
+SGI extensions to the library in
libstdc++-v3
This page describes the extensions that SGI made to their version of the
@@ -25,7 +25,7 @@ libstdc++-v3
for a description). Not every chapter may have extensions, and the
extensions may come and go. Also, this page is incomplete because the
author is pressed for time. Check back often; the latest change was on
- $Date: 2001/09/27 00:48:00 $ (UTC).
+ $Date: 2001/10/04 20:03:22 $ (UTC).
Descriptions range from the scanty to the verbose. You should also check
@@ -223,10 +223,10 @@ libstdc++-v3
-
+
See license.html for copying conditions.
Comments and suggestions are welcome, and may be sent to
-the mailing list.
+the libstdc++ mailing list.
diff --git a/libstdc++-v3/docs/html/faq/index.html b/libstdc++-v3/docs/html/faq/index.html
index 8fb5a4b0e27..b06685a77c1 100644
--- a/libstdc++-v3/docs/html/faq/index.html
+++ b/libstdc++-v3/docs/html/faq/index.html
@@ -1,10 +1,10 @@
-
-
-
+
+
+
libstdc++-v3 FAQ
-
+
+ (chapters 23 through 25, mostly) is adapted from the final release
+ of the SGI STL.
1.5 When is libstdc++ going to be finished?
Nathan Myers gave the best of all possible answers, responding to a
Usenet article asking this question: Sooner, if you help.
-
1.6 How do I contribute to the effort?
Here is a
@@ -238,7 +235,7 @@ which is no longer available, thanks deja...-->
send a message to it. More information is available on the
homepage (including how to browse the list archives); to send
to the list, use
- libstdc++@gcc.gnu.org
.
+ libstdc++@gcc.gnu.org
.
If you have a question that you think should be included here,
or if you have a question about a question/answer here,
@@ -293,7 +290,7 @@ which is no longer available, thanks deja...-->
The Concurrent Versions System is one of several revision
control packages. It was selected for GNU projects because it's
free (speech), free (beer), and very high quality. The CVS entry in
+ href="http://www.gnu.org/software/cvs/cvs.html">CVS entry in
the GNU software catalogue has a better description as
well as a
link to the makers of CVS.
@@ -318,9 +315,9 @@ which is no longer available, thanks deja...-->
the testsuite on the library after building and installing it,
use "make check-install" instead.
- If you find bugs in the testsuite programs themselves, or if
- you think of a new test program that should be added to the
- suite, please write up your idea and send it to the list!
+
If you find bugs in the testsuite programs themselves, or if you
+ think of a new test program that should be added to the suite,
+ please write up your idea and send it to the list!
@@ -366,7 +363,6 @@ which is no longer available, thanks deja...-->
these two pseudos would win praise and accolades from many.
-
4.0 Known Bugs and Non-Bugs
Note that this section can get rapdily outdated -- such is the
@@ -442,13 +438,13 @@ New:
4.3 Bugs in the C++ language/lib specification
- Yes, unfortunately, there are some. In a message
-to the list, Nathan Myers announced that he has started a list of
+
Yes, unfortunately, there are some. In a
+ message
+ to the list, Nathan Myers announced that he has started a list of
problems in the ISO C++ Standard itself, especially with
regard to the chapters that concern the library. The list
- itself is posted on his
+ itself is
+ posted on his
website. Developers who are having problems interpreting
the Standard may wish to consult his notes.
@@ -528,7 +524,7 @@ to the list, Nathan Myers announced that he has started a list of
mailing list.
Currently our header files are installed in
- ${prefix}/include/g++-v3
(see the 'v'?). This may
+ ${prefix}/include/g++-v3
(see the 'v'?). This may
change with the next release of GCC, as it may be too confusing,
but the
question has not yet been decided.
@@ -539,14 +535,14 @@ to the list, Nathan Myers announced that he has started a list of
If you're on a GNU/Linux system and have just upgraded to
glibc 2.2, but are still using gcc 2.95.2, then you should have
read the glibc FAQ, specifically 2.34:
-
+
2.34. When compiling C++ programs, I get a compilation error in streambuf.h.
{BH} You are using g++ 2.95.2? After upgrading to glibc 2.2, you need to
apply a patch to the include files in /usr/include/g++, because the fpos_t
type has changed in glibc 2.2. The patch is at
http://clisp.cons.org/~haible/gccinclude-glibc-2.2-compat.diff
-
+
Note that 2.95.x shipped with the
old v2 library which is no longer
maintained. Also note that gcc 2.95.3 fixes this problem, but
@@ -645,11 +641,10 @@ http://clisp.cons.org/~haible/gccinclude-glibc-2.2-compat.diff
instance) will of course be a continuing task.
- This
+ This
question about the next libstdc++ prompted some brief but
- interesting speculation.
+ interesting
+ speculation.
@@ -676,9 +671,9 @@ HREF="http://gcc.gnu.org/ml/libstdc++/1999/msg00084.html">speculation.
it is better to refer to files there by their path, as in:
-
+
#include <ext/hash_map>
-
+
Extensions to the library have
their own page.
@@ -698,11 +693,11 @@ HREF="http://gcc.gnu.org/ml/libstdc++/1999/msg00084.html">speculation.
This is assuming that your idea of "multithreaded"
is the same as ours... The general question of multithreading
and libstdc++-v3 is addressed in the chapter-specific advice for
-Library
- Introduction. Threadsafe containers are covered in
- more detail in
-the
- Received Wisdom section on containers.
+ Library Introduction.
+ Threadsafe containers are covered in more detail in
+ the Received Wisdom section
+ on containers. Threading and I/O are discussed in
+ the I/O chapter.
@@ -728,10 +723,10 @@ HREF="http://gcc.gnu.org/ml/libstdc++/1999/msg00084.html">speculation.
-
+
See license.html for copying conditions.
Comments and suggestions are welcome, and may be sent to
-the mailing list.
+the libstdc++ mailing list.
diff --git a/libstdc++-v3/docs/html/faq/index.txt b/libstdc++-v3/docs/html/faq/index.txt
index 66d15a2ce81..0691da78429 100644
--- a/libstdc++-v3/docs/html/faq/index.txt
+++ b/libstdc++-v3/docs/html/faq/index.txt
@@ -105,14 +105,14 @@
1.4 How do I get libstdc++?
The eleventh (and latest) snapshot of libstdc++-v3 is [47]available
- via ftp.
+ via ftp. The filename is libstdc++-2.92.tar.gz.
The [48]homepage has instructions for retrieving the latest CVS
sources, and for browsing the CVS sources over the web.
The subset commonly known as the Standard Template Library (chapters
- 23 through 25, mostly) is adapted from the SGI STL, which is also an
- ongoing work.
+ 23 through 25, mostly) is adapted from the final release of the SGI
+ STL.
_________________________________________________________________
1.5 When is libstdc++ going to be finished?
@@ -555,7 +555,8 @@ http://clisp.cons.org/~haible/gccinclude-glibc-2.2-compat.diff
ours... The general question of multithreading and libstdc++-v3 is
addressed in the chapter-specific advice for [80]Library Introduction.
Threadsafe containers are covered in more detail in [81]the Received
- Wisdom section on containers.
+ Wisdom section on containers. Threading and I/O are discussed in
+ [82]the I/O chapter.
_________________________________________________________________
5.7 How do I get a copy of the ISO C++ Standard?
@@ -566,16 +567,16 @@ http://clisp.cons.org/~haible/gccinclude-glibc-2.2-compat.diff
their two-meeting commitment for voting rights, may get a copy of the
standard from their respective national standards organization. In the
USA, this national standards organization is ANSI and their website is
- right [82]here. (And if you've already registered with them, clicking
- this link will take you to directly to the place where you can [83]buy
+ right [83]here. (And if you've already registered with them, clicking
+ this link will take you to directly to the place where you can [84]buy
the standard on-line.
- Who is your country's member body? Visit the [84]ISO homepage and find
+ Who is your country's member body? Visit the [85]ISO homepage and find
out!
_________________________________________________________________
- See [85]license.html for copying conditions. Comments and suggestions
- are welcome, and may be sent to [86]the mailing list.
+ See [86]license.html for copying conditions. Comments and suggestions
+ are welcome, and may be sent to [87]the libstdc++ mailing list.
References
@@ -620,12 +621,12 @@ References
39. ../faq/index.html#5_5
40. ../faq/index.html#5_6
41. ../faq/index.html#5_7
- 42. ftp://gcc.gnu.org/pub/libstdc++/libstdc++-2.92.tar.gz
+ 42. http://gcc.gnu.org/libstdc++/download.html
43. ../17_intro/DESIGN
44. http://gcc.gnu.org/
45. http://gcc.gnu.org/gcc-2.95/buildstat.html
46. http://gcc.gnu.org/libstdc++/
- 47. ftp://gcc.gnu.org/pub/libstdc++/libstdc++-2.92.tar.gz
+ 47. http://gcc.gnu.org/libstdc++/download.html
48. http://gcc.gnu.org/libstdc++/
49. ../17_intro/contribute.html
50. http://www.boost.org/
@@ -658,10 +659,11 @@ References
77. http://gcc.gnu.org/ml/libstdc++/1999/msg00084.html
78. http://www.sgi.com/Technology/STL/
79. ../ext/howto.html
- 80. http://gcc.gnu.org/onlinedocs/libstdc++/17_intro/howto.html#3
- 81. http://gcc.gnu.org/onlinedocs/libstdc++/23_containers/howto.html
- 82. http://www.ansi.org/
- 83. http://webstore.ansi.org/ansidocstore/product.asp?sku=ISO%2FIEC+14882%2D1998
- 84. http://www.iso.ch/
- 85. ../17_intro/license.html
- 86. mailto:libstdc++@gcc.gnu.org
+ 80. ../17_intro/howto.html#3
+ 81. ../23_containers/howto.html
+ 82. ../27_io/howto.html
+ 83. http://www.ansi.org/
+ 84. http://webstore.ansi.org/ansidocstore/product.asp?sku=ISO%2FIEC+14882%2D1998
+ 85. http://www.iso.ch/
+ 86. ../17_intro/license.html
+ 87. mailto:libstdc++@gcc.gnu.org
diff --git a/libstdc++-v3/docs/html/install.html b/libstdc++-v3/docs/html/install.html
index 5d4b4f542c2..803e8c990b6 100644
--- a/libstdc++-v3/docs/html/install.html
+++ b/libstdc++-v3/docs/html/install.html
@@ -1,16 +1,16 @@
-
-
-
-
+
+
+
+
libstdc++-v3 Installation Instructions
-
+
-libstdc++-v3 INSTALL
+libstdc++-v3 INSTALL
The latest version of this document is always available at
@@ -124,20 +124,20 @@
(gcc
or gcc-3.0
, for example) is gccsrcdir.
Once in gccsrcdir, you'll need to rename or delete the
libstdc++-v3 directory which comes with that snapshot:
-
+
mv libstdc++-v3 libstdc++-v3-previous [OR]
- rm -r libstdc++-v3
+ rm -r libstdc++-v3
Next, unpack the libstdc++-v3 library tarball into this
gccsrcdir directory; it will create a
libsrcdir called libstdc++-version
:
-
- gzip -dc libstdc++-version.tar.gz | tar xf -
+
+ gzip -dc libstdc++-version.tar.gz | tar xf -
Finally, rename libsrcdir to libstdc++-v3
so that
gcc's configure flags will be able to deal with the new library.
-
- mv libsrcdir libstdc++-v3
+
+ mv libsrcdir libstdc++-v3
@@ -156,9 +156,9 @@
building the C++ language parts.
-
+
cd gccbuilddir
- gccsrcdir/configure --prefix=destdir --other-opts...
+ gccsrcdir/configure --prefix=destdir --other-opts...
@@ -178,8 +178,8 @@
[re]building only libstdc++
To rebuild just libstdc++, use:
-
- make all-target-libstdc++-v3
+
+ make all-target-libstdc++-v3
This will configure and build the C++ library in the
gccbuilddir/cpu-vendor-os/libstdc++ directory.
@@ -193,12 +193,12 @@
simply edit it and remove lines.
You're done. Now install the rebuilt pieces with
-
- make install
+
+ make install
or
-
+
make install-gcc
- make install-target-libstdc++-v3
+ make install-target-libstdc++-v3
@@ -206,20 +206,20 @@
Post-installation
Installation will create the destdir directory and
populate it with subdirectories:
-
+
lib/
include/g++-v3/
backward/
bits/
cpu-vendor-os/bits/
- ext/
+ ext/
You can check the status of the build without installing it using
-
- make check
+
+ make check
or you can check the status of the installed library using
-
- make check-install
+
+ make check-install
in the libbuilddir directory.
These commands will create a 'testsuite' directory underneath
libbuilddir containing the results of the tests. We are
@@ -280,10 +280,10 @@
-
+
See license.html for copying conditions.
Comments and suggestions are welcome, and may be sent to
-the mailing list.
+the libstdc++ mailing list.