Tables/Figures/Examples
1: Overview
1.1 Welcome
1.2 Product Overview
1.2.1 Components
1.2.2 STL Not Object-Oriented
1.3 Usage Notes
1.3.1 Compatibility Issues
1.3.2 The std Namespace
1.4 Documentation Overview
1.4.1 Locations of Online Documentation
1.5 About This Manual
1.5.1 Assumptions
1.5.2 Conventions
1.5.3 Organization
1.5.4 Reading Suggestion
1.6 Consulting Services and Training
1.7 Technical Support
1.7.1 To Obtain Technical Support
1.7.2 How to Contact Technical Support
2: Iterators
2.1 Introduction to Iterators
2.2 Varieties of Iterators
2.2.1 Input Iterators
2.2.1.1 Kinds of Input Iterators
2.2.2 Output Iterators
2.2.3 Forward Iterators
2.2.4 Bidirectional Iterators
2.2.5 Random Access Iterators
2.2.6 Reverse Iterators
2.3 Stream Iterators
2.3.1 Input Stream Iterators
2.3.2 Output Stream Iterators
2.4 Insert Iterators
2.5 Iterator Operations
3: Functions and Predicates
3.1 Functions
3.2 Function Objects
3.2.1 Definition
3.2.2 Use
3.2.2.1 To Employ Existing C++ Standard Library Function Objects
3.2.2.2 To Improve Execution
3.2.2.3 To Access or Set State Information
3.3 Predicates
3.4 Function Adaptors
3.4.1 Definition
3.4.2 Adapting Non-member or Static Member Functions
3.4.3 Adapting Member Functions
3.5 Negators and Binders
4: Container Classes
4.1 Overview
4.2 Selecting a Container
4.3 Memory Management Issues
4.4 Container Types Not Found in the C++ Standard Library
5: vector and vector<bool>
5.1 The vector Data Abstraction
5.1.1 Include Files
5.2 vector Operations
5.2.1 Declaration and Initialization of vectors
5.2.2 Type Definitions
5.2.3 Subscripting a vector
5.2.4 Extent and Size-Changing Operations
5.2.5 Inserting and Removing Elements
5.2.6 Iteration
5.2.7 Test for Inclusion
5.2.8 Sorting and Sorted vector Operations
5.2.9 Useful Generic Algorithms
5.3 Boolean Vectors
5.4 Example Program: The Sieve of Eratosthenes
6: list
6.1 The list Data Abstraction
6.1.1 Include files
6.2 list Operations
6.2.1 Declaration and Initialization of lists
6.2.2 Type Definitions
6.2.3 Placing Elements into a list
6.2.3.1 Splicing
6.2.4 Removing Elements
6.2.5 Extent and Size-Changing Operations
6.2.6 Access and Iteration
6.2.7 Test for Inclusion
6.2.8 Sorting and Sorted list Operations
6.2.9 Searching Operations
6.2.10 In-Place Transformations
6.2.11 Other Operations
6.3 Example Program: An Inventory System
7: deque
7.1 The deque Data Abstraction
7.1.1 Include Files
7.2 deque Operations
7.3 Example Program: Radix Sort
8: set, multiset, and bitset
8.1 The set Data Abstraction
8.1.1 Include Files
8.2 set and multiset Operations
8.2.1 Declaration and Initialization of set
8.2.2 Type Definitions
8.2.3 Insertion
8.2.4 Removal of Elements from a set
8.2.5 Searching and Counting
8.2.6 Iterators
8.2.7 set Operations
8.2.7.1 Subset test
8.2.7.2 Set Union or Intersection
8.2.7.3 Set Difference
8.2.8 Other Generic Algorithms
8.3 Example Program: A Spelling Checker
8.4 The bitset Abstraction
8.4.1 Include Files
8.4.2 Declaration and Initialization of bitset
8.4.3 Accessing and Testing Elements
8.4.4 set Operations
8.4.5 Conversions
9: map and multimap
9.1 The map Data Abstraction
9.1.1 Include files
9.2 map and multimap Operations
9.2.1 Declaration and Initialization of map
9.2.2 Type Definitions
9.2.3 Insertion and Access
9.2.4 Removal of Values
9.2.5 Iterators
9.2.6 Searching and Counting
9.2.7 Element Comparisons
9.2.8 Other map Operations
9.3 Example Programs
9.3.1 Example: A Telephone Database
9.3.2 An Example: Graphs
9.3.3 Example: A Concordance
10: The Container Adaptors stack and queue
10.1 Overview
10.2 The stack Data Abstraction
10.2.1 Include Files
10.2.2 Declaration and Initialization of stack
10.2.3 Example Program: An RPN Calculator
10.3 The queue Data Abstraction
10.3.1 Include Files
10.3.2 Declaration and Initialization of queue
10.3.3 Example Program: Bank Teller Simulation
11: The Container Adaptor priority queue
11.1 The priority queue Data Abstraction
11.1.1 Include Files
11.2 The priority queue Operations
11.2.1 Declaration and Initialization of priority queue
11.3 Example Program: Event-Driven Simulation
11.3.1 Example Program: An Ice Cream Store Simulation
12: string
12.1 The string Abstraction
12.1.1 Include Files
12.2 string Operations
12.2.1 Declaration and Initialization of string
12.2.2 Resetting Size and Capacity
12.2.3 Assignment, Append, and Swap
12.2.4 Character Access
12.2.5 Iterators
12.2.6 Insertion, Removal, and Replacement
12.2.7 Copy and Substring
12.2.8 string Comparisons
12.2.9 Searching Operations
12.3 Example Function: Split a Line into Words
13: Generic Algorithms
13.1 Overview
13.1.1 Include Files
13.2 Initialization Algorithms
13.2.1 Fill a Sequence with An Initial Value
13.2.2 Copy One Sequence Into Another Sequence
13.2.3 Initialize a Sequence with Generated Values
13.2.4 Swap Values from Two Parallel Ranges
13.3 Searching Operations
13.3.1 Find an Element Satisfying a Condition
13.3.2 Find Consecutive Duplicate Elements
13.3.3 Find the First Occurrence of Any Value from a Sequence
13.3.4 Find a Sub-Sequence within a Sequence
13.3.5 Find the Last Occurrence of a Sub-Sequence
13.3.6 Locate Maximum or Minimum Element
13.3.7 Locate the First Mismatched Elements in Parallel Sequences
13.4 In-Place Transformations
13.4.1 Reverse Elements in a Sequence
13.4.2 Replace Certain Elements With Fixed Value
13.4.3 Rotate Elements Around a Midpoint
13.4.4 Partition a Sequence into Two Groups
13.4.5 Generate Permutations in Sequence
13.4.6 Merge Two Adjacent Sequences into One
13.4.7 Randomly Rearrange Elements in a Sequence
13.5 Removal Algorithms
13.5.1 Remove Unwanted Elements
13.5.2 Remove Runs of Similar Values
13.6 Scalar-Producing Algorithms
13.6.1 Count the Number of Elements That Satisfy a Condition
13.6.2 Reduce Sequence to a Single Value
13.6.3 Generalized Inner Product
13.6.4 Test Two Sequences for Pairwise Equality
13.6.5 Lexical Comparison
13.7 Sequence-Generating Algorithms
13.7.1 Transform One or Two Sequences
13.7.2 Partial Sums
13.7.3 Adjacent Differences
13.8 The for_each() Algorithm
14: Ordered Collection Algorithms
14.1 Overview
14.1.1 Include Files
14.2 Sorting Algorithms
14.2.1 Partial Sort
14.3 nth Element
14.4 Binary Search
14.5 Merge Ordered Sequences
14.6 set Operations
14.7 heap Operations
15: Using Allocators
15.1 Overview
15.2 Using Allocators with Existing C++ Standard Library Containers
15.3 Building Your Own Allocators
15.3.1 Using the Standard Allocator Interface
16: Building Containers and Algorithms
16.1 Extending the C++ Standard Library
16.2 Building on the Standard Containers
16.2.1 Inheritance
16.2.2 Generic Inheritance
16.2.3 Generic Composition
16.3 Creating Your Own Containers
16.3.1 Meeting the Container Requirements
16.3.2 Meeting the Allocator Interface Requirements
16.3.3 Iterator Requirements
16.4 Tips and Techniques for Building Algorithms
16.4.1 The iterator_traits Template
16.4.2 The distance and advance Primitives
17: The Traits Parameter
17.1 Defining the Problem
17.2 Using the Traits Technique
18: Exception Handling
18.1 Overview
18.1.1 Include Files
18.2 The Standard Exception Hierarchy
18.3 Using Exceptions
18.4 Example Program: Exceptions
19: auto_ptr
19.1 Overview
19.1.1 Include File
19.2 Declaration and Initialization of Autopointers
20: complex
20.1 Overview
20.1.1 Include Files
20.2 Creating and Using Complex Numbers
20.2.1 Declaring Complex Numbers
20.2.2 Accessing Complex Number Values
20.2.3 Arithmetic Operations
20.2.4 Comparing Complex Values
20.2.5 Stream Input and Output
20.2.6 Norm and Absolute Value
20.2.7 Trigonometric Functions
20.2.8 Transcendental Functions
20.3 Example Program: Roots of a Polynomial
21: numeric_limits
21.1 Overview
21.2 Fundamental Datatypes
21.3 numeric_limits Members
21.3.1 Members Common to All Types
21.3.2 Members Specific to Floating Point Values
22: valarray
22.1 Overview
22.1.1 Performance Issues
22.1.2 Type Restrictions
22.1.2.1 A Class That Meets the Type Restrictions
22.1.2.2 A Class That Doesn't Meet the Type Restrictions
22.1.3 Other Unique Features
22.1.4 Header Files
22.2 Declaring a valarray
22.3 Assignment Operators
22.4 Element and Subset Access
22.4.1 Ordinary Index Operators
22.4.2 Subset Operators
22.4.2.1 The Slice Operation
22.4.2.2 The gslice Operation
22.4.2.3 Boolean Mask
22.4.2.4 Indirect Operation
22.4.3 Unary Operators
22.5 Computed Assignment Operators
22.6 Member Functions
22.7 Non-Member Functions
22.7.1 Binary Operators
22.7.2 Transcendental Functions
23: Internationalization and Localization
23.1 Defining the Terms
23.2 Localizing Cultural Conventions
23.2.1 Language
23.2.2 Numbers
23.2.3 Currency
23.2.4 Time and Date
23.2.5 Ordering
23.3 Character Encodings for Localizing Alphabets
23.3.1 Multibyte Encodings
23.3.1.1 JIS Encoding
23.3.1.2 Shift-JIS Encoding
23.3.1.3 EUC Encoding
23.3.1.4 Uses of the Three Multibyte Encodings
23.3.2 Wide Characters
23.3.3 Conversion between Multibyte and Wide Characters
23.4 Summary
24: The C and C++ Locales
24.1 The C Locale
24.2 The C++ Locales
24.2.1 Facets
24.2.1.1 The Standard Facets
24.3 Differences between the C Locale and the C++ Locales
24.3.1 Common Uses of the C locale
24.3.2 Common Uses of C++ Locales
24.3.3 The Relationship between the C Locale and the C++ Locale
24.4 The Locale Object
25: Facets
25.1 Understanding Facet Types
25.2 Facet Lifetimes
25.3 Accessing a Locale's Facets
25.4 Using a Stream's Facet
25.5 Modifying a Standard Facet's Behavior
25.6 Creating a New Base Facet Class
26: Building Your Own Facet Class
26.1 An Example of Formatting Phone Numbers
26.2 A Phone Number Class
26.3 A Phone Number Formatting Facet Class
26.4 An Inserter for Phone Numbers
26.5 The Phone Number Facet Class Revisited
26.5.1 Adding Data Members
26.5.2 Adding Country Codes
26.6 An Example of a Derived Facet Class
26.7 Using Phone Number Facets
26.8 Formatting Phone Numbers
26.9 Improving the Inserter Function
26.9.1 Primitive Caching
26.9.2 Registration of a Callback Function
26.9.3 Improving the Inserter
27: The Architecture of Iostreams
27.1 The Standard Iostreams
27.1.1 Type Safety
27.1.2 Extensibility to New Types
27.2 How the Standard Iostreams Work
27.2.1 The Iostream Layers
27.2.1.1 The Formatting Layer
27.2.1.2 The Transport Layer
27.2.1.3 Locales
27.2.2 File and In-Memory I/O
27.3 How the Standard Iostreams Help Solve Problems
27.4 The Internal Structure of the Iostreams Layers
27.4.1 The Internal Structure of the Formatting Layer
27.4.1.1 Iostreams Base Class ios_base
27.4.1.2 The Iostreams Character Type-Dependent Base Class
27.4.1.3 Character Traits
27.4.1.4 The Input and Output Streams
27.4.1.5 The File Streams
27.4.1.6 The String Streams
27.4.2 The Transport Layer's Internal Structure
27.4.2.1 The Stream Buffer
27.4.2.2 The File Buffer
27.4.2.3 The String Stream Buffer
27.4.3 Collaboration of Streams and Stream Buffers
27.4.4 Collaboration of Locales and Iostreams
28: Formatted Input and Output
28.1 The Predefined Streams
28.2 Input and Output Operators
28.3 Format Control Using the Stream's Format State
28.3.1 Format Parameters
28.3.1.1 Parameters That Can Have an Arbitrary Value
28.3.1.2 Parameters That Can Have Only a Few Different Values
28.3.2 Manipulators
28.4 Localization Using the Stream's Locale
28.5 Formatted Input
28.5.1 Skipping Characters
28.5.2 Input of Strings
29: Error State of Streams
29.1 About Flags
29.2 Checking the Stream State
29.3 Catching Exceptions
30: File Input and Output
30.1 About File Streams
30.1.1 Code Conversion in Wide Character Streams
30.2 Working with File Streams
30.2.1 Creating and Opening File Stream Objects
30.2.2 Checking a File Stream's Status
30.2.3 Closing a File Stream
30.3 The Open Mode
30.3.1 The Open Mode Flags
30.3.1.1 The in and out Open Modes
30.3.1.2 The Open modes ate, app, and trunc
30.3.1.3 The binary Open Mode
30.3.2 Combining Open Modes
30.3.3 Default Open Modes
30.4 Binary and Text Mode
30.5 File Positioning
30.5.1 How Positioning Works with the Iostream Architecture
31: Input and Output In Memory
31.1 About String Streams
31.2 The Internal Buffer
31.3 The Open Modes
32: Input and Output of User Types
32.1 A Note on User-Defined Types
32.2 An Example with a User-Defined Type
32.3 A Simple Extractor and Inserter for the Example
32.4 Improved Extractors and Inserters
32.5 More Improved Extractors and Inserters
32.5.1 Applying the Recommendations to the Example
32.5.2 An Afterthought
32.6 Patterns for Extractors and Inserters of User-Defined Types
33: Manipulators
33.1 A Recap of Manipulators
33.2 Manipulators without Parameters
33.2.1 Examples of Manipulators without Parameters
33.2.2 A Remark on the Manipulator endl
33.3 Manipulators with Parameters
33.3.1 The Standard Manipulators
33.3.2 The Principle of Manipulators with Parameters
33.3.3 Examples of Manipulators with Parameters
34: Streams and Stream Buffers
34.1 Streams as Objects
34.2 Copying and Assigning Stream Objects
34.2.1 Copying a Stream's Data Members
34.2.2 Sharing Stream Buffers Inadvertently
34.2.3 Using Pointers or References to Streams
34.3 Sharing a Stream Buffer Among Streams
34.3.1 Several Format Settings for the Same Stream
34.3.2 Several Locales for the Same Stream
34.3.3 Input and Output to the Same Stream
34.4 Copies of the Stream Buffer
35: Synchronizing Streams
35.1 Sharing Files Among Streams
35.2 Explicit Synchronization
35.2.1 Output Streams
35.2.2 Input Streams
35.3 Implicit Synchronization Using the unitbuf Format Flag
35.4 Implicit Synchronization by Tying Streams
35.5 Synchronizing the Standard Iostream Objects
35.6 Synchronization with the C Standard I/O
36: Stream Storage for Private Use
36.1 Adding Data to a Stream
36.2 An Example: Storing a Date Format String
36.3 Another Look at the Date Format String
36.4 Caveat
37: Registration of Callback Functions
37.1 Defining Callback Functions
37.2 An Example
38: Creating New Stream Classes by Derivation
38.1 Deriving a New Stream Type
38.2 Choosing a Base Class
38.3 Construction and Initialization
38.3.1 Derivation from File Stream or String Stream Classes std::{i,o}fstream or std::{i,o}stringstream
38.3.2 Derivation from the Stream Classes std::basic_{i,o}stream
38.4 The Example
38.4.1 The Derived Stream Template
38.4.2 The Date Inserter
38.4.3 The Manipulator
38.4.4 A Remark on Performance
38.5 Using iword/pword for RTTI in Derived Streams
39: Stream Buffers
39.1 Class basic_streambuf: the Sequence Abstraction
39.1.1 The streambuf Hierarchy
39.1.2 The streambuf Interface
39.2 Deriving New Stream Buffer Classes
39.3 Connecting iostream and streambuf Objects
40: Defining A Code Conversion Facet
40.1 Overview
40.2 Categories of Code Conversions
40.3 Example 1: Defining a Narrow Character Code Conversion (ASCII <-> EBCDIC)
40.3.1 Derive a New Facet Type
40.3.2 Specialize the New Facet Type and Implement the Member Functions
40.3.3 Use the New Code Conversion Facet
40.4 Error Indication in Code Conversion Facets
40.5 Example 2: Defining a Multibyte Character Code Conversion (JIS <-> Unicode)
40.5.1 Define a New Conversion State Type
40.5.2 Define a New Character Traits Type
40.5.3 Define the Code Conversion Facet
40.5.4 Use the New Code Conversion Facet
41: Defining Your Own Character Types
41.1 User-Defined Character Types
41.1.1 Requirements for User-Defined Character Types
41.2 Defining Traits and Facets for User-Defined Types
41.3 Creating and Using Streams Instantiated on User-Defined Types
42: Imbuing Locales
42.1 Locales and Iostreams
42.2 When to Imbue a New Locale
42.3 An Example
43: Stream Iterators
43.1 Definition
43.2 Differences between Stream Iterators and Container Iterators
43.3 Error Indication by Stream Iterators
43.4 Several Iterators on One Stream
44: Iostreams and Multithreading
44.1 Multithread-Safe: Level 2
44.2 The Locking Mechanism
44.2.1 Protecting the Buffer
45: Standard vs. Traditional Iostreams
45.1 The Character Type
45.2 Internationalization
45.3 File Streams
45.3.1 Connecting Files and Streams
45.3.2 The File Buffer
45.4 String Streams
45.5 Streams with Assign
46: Standard vs. Apache C++ Standard Library Iostreams
46.1 Extensions
46.1.1 File Descriptors
46.1.2 Multithreaded Environments
|