Copyright (C) 1993 Free Software Foundation, Inc.

The author of this software is David M. Gay.

Copyright (c) 1991 by AT&T.

Permission to use, copy, modify, and distribute this software for any purpose without fee is hereby granted, provided that this entire notice is included in all copies of any software which is or includes a copy or modification of this software and in all copies of the supporting documentation for such software.

THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.

Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.

Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.

Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.


1 Introduction

IOstreams provide the standard input and output facilities of the Standard Template Library (STL). These facilities are  analogous with those defined by the C `stdio' functions. IOstreams use an abstraction called streams for handling input and output operations on sequences of characters. A stream can represent a file, block of memory or console.

The four predefined IOstreams are:

Note: All the predefined IOstreams are fully buffered, except for cerr.

The library provides a common set of interfaces for handling streams. A generic representation of streams is shown in Figure 1 below:

The buffer and translator components of IOstreams handle the conversion of individual bits from the I/O device into structured data of the object (can be a built-in type such as integer or user defined type).

The user of the library is usually transparent to these components. However, the user will need to check the state of the components after I/O operations to check if the I/O operation succeeded or not.