The C++ Programming Language, Third Edition and Special Edition

Bjarne Stroustrup


Table of Contents


Preface

Preface to Second Edition

Preface Preface to First Edition

Contents

Introductory Material: ... pg 1
1 Notes to the Reader
1.1 The Structure of This Book
1.1.1 Examples and References
1.1.2 Exercises
1.1.3 Implementation Note
1.2 Learning C++
1.3 The Design of C++
1.3.1 Efficiency and Structure
1.3.2 Philosophical Note
1.4 Historical Note
1.5 Use of C++
1.6 C and C++
1.6.1 Suggestions for C Programmers
1.6.2 Suggestions for C++ Programmers
1.7 Thinking about Programming in C++
1.8 Advice
1.8.1 References
2 A Tour of C++
2.1 What is C++
2.2 Programming Paradigms
2.3 Procedural Programming
2.3.1 Variables and Arithmetic
2.3.2 Tests and Loops
2.3.3 Pointers and Arrays
2.4 Modular Programming
2.4.1 Separate Compilation
2.4.2 Exception Handling
2.5 Data Abstraction
2.5.1 Modules Defining Types
2.5.2 User-Defined Types
2.5.3 Concrete Types
2.5.4 Abstract Types
2.5.5 Virtual Functions
2.6 Object-Oriented Programming
2.6.1 Problems with Concrete Types
2.6.2 Class Hierarchies
2.7 Generic Programming
2.7.1 Containers
2.7.2 Generic Algorithms
2.8 Postscript
2.9 Advice
3 A Tour of the Standard Library
3.1 Introduction
3.2 Hello, world!
3.3 The Standard Library Namespace
3.4 Output
3.5 Strings
3.5.1 C-Style Strings
3.6 Input
3.7 Containers
3.7.1 Vector
3.7.2 Range Checking
3.7.3 List
3.7.4 Map
3.7.5 Standard Containers
3.8 Algorithms
3.8.1 Use of Iterators
3.8.2 Iterator Types
3.8.3 Iterators and I/O
3.8.4 Traversals and Predicates
3.8.5 Algorithms Using Member Functions
3.8.6 Standard Library Algorithms
3.9 Math
3.9.1 Complex Numbers 3.9.2 Vector Arithmetic
3.9.3 Basic Numeric Support
3.10 Standard Library Facilities
3.11 Advice

Part I: Basic Facilities ... pg 67
4 Types and Declarations
4.1 Types
4.1.1 Fundamental Types
4.2 Booleans
4.3 Character Types
4.3.1 Character Literals
4.4 Integer Types
4.4.1 Integer Literals
4.5 Floating-Point Types
4.5.1 Floating-Point Literals
4.6 Sizes
4.7 Void
4.8 Enumerations
4.9 Declarations
4.9.1 The Structure of a Declaration
4.9.2 Declaring Multiple Names
4.9.3 Names
4.9.4 Scope
4.9.5 Initialization
4.9.6 Objects and Lvalues
4.9.7 Typedef
4.10 Advice
4.11 Exercises
5 Pointers, Arrays, and Structures
5.1 Pointers
5.1.1 Zero
5.2 Arrays
5.2.1 Array Initializers 5.2.2 String Literals
5.3 Pointers into Arrays
5.3.1 Navigating Arrays
5.4 Constants
5.4.1 Pointers and Constants
5.5 References
5.6 Pointer to Void
5.7 Structures
5.7.1 Type Equivalence
5.8 Advice
5.9 Exercises
6 Expressions and Statements
6.1 A Desk Calculator
6.1.1 The Parser
6.1.2 The Input Function
6.1.3 Low-level Input
6.1.4 Error Handling
6.1.5 The Driver
6.1.6 Headers
6.1.7 Command-Line Arguments
6.1.8 A Note on Style
6.2 Operator Summary
6.2.1 Results
6.2.2 Evaluation Order
6.2.3 Operator Precedence
6.2.4 Bitwise Logical Operators
6.2.5 Increment and Decrement
6.2.6 Free Store
6.2.6.1 Arrays
6.2.6.2 Memory Exhaustion
6.2.7 Explicit Type Conversion
6.2.8 Constructors
6.3 Statement Summary
6.3.1 Declarations as Statements
6.3.2 Selection Statements
6.3.2.1 Declarations in Conditions
6.3.3 Iteration Statements
6.3.3.1 Declarations in For-Statements
6.3.4 Goto
6.4 Comments and Indentation
6.5 Advice
6.6 Exercises
7 Functions
7.1 Function Declarations
7.1.1 Function Definitions
7.1.2 Static Variables
7.2 Argument Passing
7.2.1 Array Arguments
7.3 Value Return
7.4 Overloaded Function Names
7.4.1 Overloading and Return Type
7.4.2 Overloading and Scopes
7.4.3 Manual Ambiguity Resolution
7.4.4 Resolution for Multiple Arguments
7.5 Default Arguments
7.6 Unspecified Number of Arguments
7.7 Pointer to Function
7.8 Macros
7.8.1 Conditional Compilation
7.9 Advice
7.10 Exercises
8 Namespaces and Exceptions
8.1 Modularization and Interfaces
8.2 Namespaces
8.2.1 Qualified Names
8.2.2 Using Declarations
8.2.3 Using Directives
8.2.4 Multiple Interfaces
8.2.4.1 Interface Design Alternatives
8.2.5 Avoiding Name Clashes
8.2.5.1 Unnamed Namespaces
8.2.6 Name Lookup
8.2.7 Namespace Aliases
8.2.8 Namespace Composition
8.2.8.1 Selection
8.2.8.2 Composition and Selection
8.2.9 Namespaces and Old Code
8.2.9.1 Namespaces and C
8.2.9.2 Namespaces and Overloading
8.2.9.3 Namespaces Are Open
8.3 Exceptions
8.3.1 Throw and Catch
8.3.2 Discrimination of Exceptions
8.3.3 Exceptions in the Calculator
8.3.3.1 Alternative Error-Handling Strategies
8.4 Advice
8.5 Exercises
9 Source Files and Programs
9.1 Separate Compilation
9.2 Linkage
9.2.1 Header Files
9.2.2 Standard Library Headers
9.2.3 The One-Definition Rule
9.2.4 Linkage to Non-C++ Code
9.2.5 Linkage and Pointers to Functions
9.3 Using Header Files
9.3.1 Single Header File
9.3.2 Multiple Header Files
9.3.2.1 Other Calculator Modules
9.3.2.2 Use of Headers
9.3.3 Include Guards
9.4 Programs
9.4.1 Initialization of Nonlocal Variables
9.4.1.1 Program Termination
9.5 Advice
9.6 Exercises

Part II: Abstraction Mechanisms ... pg 221
10 Classes
10.1 Introduction
10.2 Classes
10.2.1 Member Functions
10.2.2 Access Control
10.2.3 Constructors
10.2.4 Static Members
10.2.5 Copying Class Objects
10.2.6 Constant Member Functions
10.2.7 Self-Reference
10.2.7.1 Physical and Logical Constness
10.2.7.2 Mutable
10.2.8 Structures and Classes
10.2.9 In-Class Function Definitions
10.3 Efficient User-Defined Types
10.3.1 Member Functions
10.3.2 Helper Functions
10.3.3 Overloaded Operators
10.3.4 The Significance of Concrete Classes
10.4 Objects
10.4.1 Destructors
10.4.2 Default Constructors
10.4.3 Construction and Destruction
10.4.4 Local Variables
10.4.4.1 Copying Objects
10.4.5 Free Store
10.4.6 Class Objects as Members
10.4.6.1 Necessary Member Initialization
10.4.6.2 Member Constants
10.4.6.3 Copying Members
10.4.7 Arrays
10.4.8 Local Static Store
10.4.9 Nonlocal Store
10.4.10 Temporary Objects
10.4.11 Placement of Objects
10.4.12 Unions
10.5 Advice
10.6 Exercises
11 Operator Overloading
11.1 Introduction
11.2 Operator Functions
11.2.1 Binary and Unary Operators
11.2.2 Predefined Meanings for Operators
11.2.3 Operators and User-Defined Types
11.2.4 Operators in Namespaces
11.3 A Complex Number Type
11.3.1 Member and Nonmember Operators
11.3.2 Mixed-Mode Arithmetic
11.3.3 Initialization
11.3.4 Copying
11.3.5 Constructors and Conversions
11.3.6 Literals
11.3.7 Additional Member Functions
11.3.8 Helper Functions
11.4 Conversion Operators
11.4.1 Ambiguities
11.5 Friends
11.5.1 Finding Friends
11.5.2 Friends and Members
11.6 Large Objects
11.7 Essential Operators
11.7.1 Explicit Constructors
11.8 Subscripting
11.9 Function Call
11.10 Dereferencing
11.11 Increment and Decrement
11.12 A String Class
11.13 Advice
11.14 Exercises
12 Derived Classes
12.1 Introduction
12.2 Derived Classes
12.2.1 Member Functions
12.2.2 Constructors and Destructors
12.2.3 Copying
12.2.4 Class Hierarchies
12.2.5 Type Fields
12.2.6 Virtual Functions
12.3 Abstract Classes
12.4 Design of Class Hierarchies
12.4.1 A Traditional Class Hierarchy
12.4.1.1 Critique
12.4.2 Abstract Classes
12.4.3 Alternative Implementations
12.4.3.1 Critique
12.4.4 Localizing Object Creation
12.5 Class Hierarchies and Abstract Classes
12.6 Advice
12.7 Exercises
13 Templates
13.1 Introduction
13.2 A Simple String Template
13.2.1 Defining a Template
13.2.2 Template Instantiation
13.2.3 Template Parameters
13.2.4 Type Equivalence
13.2.5 Type Checking
13.3 Function Templates
13.3.1 Function Template Arguments
13.3.2 Function Template Overloading
13.4 Using Template Arguments to Specify Policy
13.4.1 Default Template Parameters
13.5 Specialization
13.5.1 Order of Specializations
13.5.2 Template Function Specialization
13.6 Derivation and Templates
13.6.1 Parameterization and Inheritance
13.6.2 Member Templates
13.6.3 Inheritance Relationships
13.6.3.1 Template Conversions
13.7 Source Code Organization
13.8 Advice
13.9 Exercises
14 Exception Handling
14.1 Error Handling
14.1.1 Alternative Views on Exceptions
14.2 Grouping of Exceptions
14.2.1 Derived Exceptions
14.2.2 Composite Exceptions
14.3 Catching Exceptions
14.3.1 Re-Throw
14.3.2 Catch Every Exception
14.3.2.1 Order of Handlers
14.4 Resource Management
14.4.1 Using Constructors and Destructors
14.4.2 Auto_ptr
14.4.3 Caveat
14.4.4 Exceptions and New
14.4.5 Resource Exhaustion
14.4.6 Exceptions in Constructors
14.4.6.1 Exceptions and Member Initialization
14.4.6.1 Exceptions and Copying
14.4.7 Exceptions in Destructors
14.5 Exceptions That Are Not Errors
14.6 Exception Specifications
14.6.1 Checking Exception Specifications
14.6.2 Unexpected Exceptions
14.6.3 Mapping Exceptions
14.6.3.1 User Mapping of Exceptions
14.6.3.2 Recovering the Type of an Exception
14.7 Uncaught Exceptions
14.8 Exceptions and Efficiency
14.9 Error-Handling Alternatives
14.10 Standard Exceptions
14.11 Advice
14.12 Exercises
15 Class Hierarchies
15.1 Introduction and Overview
15.2 Multiple Inheritance
15.2.1 Ambiguity Resolution
15.2.2 Inheritance and Using-Declarations
15.2.3 Replicated Base Classes
15.2.3.1 Overriding
15.2.4 Virtual Base Classes
15.2.4.1 Programming Virtual Bases
15.2.5 Using Multiple Inheritance
15.2.5.1 Overriding Virtual Base Functions
15.3 Access Control
15.3.1 Protected Members
15.3.1.1 Use of Protected Members
15.3.2 Access to Base Classes
15.3.2.1 Multiple Inheritance and Access Control
15.3.2.2 Using-Declarations and Access Control
15.4 Run-Time Type Information
15.4.1 Dynamic_cast
15.4.1.1 Dynamic_cast of References
15.4.2 Navigating Class Hierarchies
15.4.2.1 Static and Dynamic Casts
15.4.3 Class Object Construction and Destruction
15.4.4 Typeid and Extended Type Information
15.4.4.1 Extended Type Information
15.4.5 Uses and Misuses of RTTI
15.5 Pointers to Members
15.5.1 Base and Derived Classes
15.6 Free Store
15.6.1 Array Allocation
15.6.2 ``Virtual Constructors''
15.7 Advice
15.8 Exercises

Part III: The Standard Library ... pg 427
16 Library Organization and Containers
16.1 Standard Library Design
16.1.1 Design Constraints
16.1.2 Standard Library Organization
16.1.3 Language Support
16.2 Container Design
16.2.1 Specialized Containers and Iterators
16.2.2 Based Containers
16.2.3 STL Containers
16.3 Vector
16.3.1 Types
16.3.2 Iterators
16.3.3 Element Access
16.3.4 Constructors
16.3.5 Stack Operations
16.3.6 List Operations
16.3.7 Addressing Elements
16.3.8 Size and Capacity
16.3.9 Other Member Functions
16.3.10 Helper Functions
16.3.11 Vector
16.4 Advice
16.5 Exercises
17 Standard Containers
17.1 Standard Containers
17.1.1 Operations Summary
17.1.2 Container Summary
17.1.3 Representation
17.1.4 Element Requirements
17.1.4.1 Comparisons
17.1.4.2 Other Relational Operators
17.2 Sequences
17.2.1 Vector
17.2.2 List
17.2.2.1 Splice, Sort, and Merge
17.2.2.2 Front Operations
17.2.2.3 Other Operations
17.2.3 Deque
17.3 Sequence Adapters
17.3.1 Stack
17.3.2 Queue
17.3.3 Priority Queue
17.4 Associative Containers
17.4.1 Map
17.4.1.1 Types
17.4.1.2 Iterators and Pairs
17.4.1.3 Subscripting
17.4.1.4 Constructors
17.4.1.5 Comparisons
17.4.1.6 Map Operations
17.4.1.7 List Operations
17.4.1.8 Other Functions
17.4.2 Multimap
17.4.3 Set
17.4.4 Multiset
17.5 Almost Containers
17.5.1 String
17.5.2 Valarray
17.5.3 Bitset
17.5.3.1 Constructors
17.5.3.2 Bit Manipulation Operations
17.5.3.3 Other Operations
17.5.4 Built-In Arrays
17.6 Defining a New Container
17.6.1 Hash_map
17.6.2 Representation and Construction
17.6.2.1 Lookup
17.6.2.2 Erase and Resize
17.6.2.3 Hashing
17.6.3 Other Hashed Associative Containers
17.7 Advice
17.8 Exercises
18 Algorithms and Function Objects
18.1 Introduction
18.2 Overview of Standard Library Algorithms
18.3 Sequences and Containers
18.3.1 Input Sequences
18.4 Function Objects
18.4.1 Function Object Bases
18.4.2 Predicates
18.4.2.1 Overview of Predicates
18.4.3 Arithmetic Function Objects
18.4.4 Binders, Adapters, and Negaters
18.4.4.1 Binders
18.4.4.2 Member Function Adapters
18.4.4.3 Pointer to Function Adapters
18.4.4.4 Negaters
18.5 Nonmodifying Sequence Algorithms
18.5.1 For_each
18.5.2 The Find Family
18.5.3 Count
18.5.4 Equal and Mismatch
18.5.5 Search
18.6 Modifying Sequence Algorithms
18.6.1 Copy
18.6.2 Transform
18.6.3 Unique
18.6.3.1 Sorting Criteria
18.6.4 Replace
18.6.5 Remove
18.6.6 Fill and Generate
18.6.7 Reverse and Rotate
18.6.8 Swap
18.7 Sorted Sequences
18.7.1 Sorting
18.7.2 Binary Search
18.7.3 Merge
18.7.4 Partitions
18.7.5 Set Operations on Sequences
18.8 Heaps
18.9 Min and Max
18.10 Permutations
18.11 C-Style Algorithms
18.12 Advice
18.13 Exercises
19 Iterators and Allocators
19.1 Introduction
19.2 Iterators and Sequences
19.2.1 Iterator Operations
19.2.2 Iterator Traits
19.2.3 Iterator Categories
19.2.4 Inserters
19.2.5 Reverse Iterators
19.2.6 Stream Iterators
19.2.6.1 Stream Buffers
19.3 Checked Iterators
19.3.1 Exceptions, Containers, and Algorithms
19.4 Allocators
19.4.1 The Standard Allocator
19.4.2 A User-Defined Allocator
19.4.3 Generalized Allocators
19.4.4 Uninitialized Memory
19.4.5 Dynamic Memory
19.4.6 C-Style Allocation
19.5 Advice
19.6 Exercises 20 Strings
20.1 Introduction
20.2 Characters
20.2.1 Character Traits
20.3 Basic_string
20.3.1 Types
20.3.2 Iterators
20.3.3 Element Access
20.3.4 Constructors
20.3.5 Errors
20.3.6 Assignment
20.3.7 Conversion to C-Style Strings
20.3.8 Comparisons
20.3.9 Insert
20.3.10 Concatenation
20.3.11 Find
20.3.12 Replace
20.3.13 Substrings
20.3.14 Size and Capacity
20.3.15 I/O Operations
20.3.16 Swap
20.4 The C Standard Library
20.4.1 C-Style Strings
20.4.2 Character Classification
20.5 Advice
20.6 Exercises
21 Streams
21.1 Introduction
21.2 Output
21.2.1 Output Streams
21.2.2 Output of Built-In Types
21.2.3 Output of User-Defined Types
21.2.3.1 Virtual Output Functions
21.3 Input
21.3.1 Input Streams
21.3.2 Input of Built-In Types
21.3.3 Stream State
21.3.4 Input of Characters
21.3.5 Input of User-Defined Types
21.3.6 Exceptions
21.3.7 Tying of Streams
21.3.8 Sentries
21.4 Formatting
21.4.1 Format State
21.4.1.1 Copying Format State
21.4.2 Integer Output
21.4.3 Floating-Point Output
21.4.4 Output Fields
21.4.5 Field Adjustment
21.4.6 Manipulators
21.4.6.1 Manipulators Taking Arguments
21.4.6.2 Standard I/O Manipulators
21.4.6.3 User-Defined Manipulators
21.5 File Streams and String Streams
21.5.1 File Streams
21.5.2 Closing of Streams
21.5.3 String Streams
21.6 Buffering
21.6.1 Output Streams and Buffers
21.6.2 Input Streams and Buffers
21.6.3 Streams and Buffers
21.6.4 Stream Buffers
21.7 Locale
21.7.1 Stream Callbacks
21.8 C Input/Output
21.9 Advice
21.10 Exercises
22 Numerics
22.1 Introduction
22.2 Numeric Limits
22.2.1 Limit Macros
22.3 Standard Mathematical Functions
22.4 Vector Arithmetic
22.4.1 Valarray Construction
22.4.2 Valarray Subscripting and Assignment
22.4.3 Member Operations
22.4.4 Nonmember Operations
22.4.5 Slices
22.4.6 Slice_array
22.4.7 Temporaries, Copying, and Loops
22.4.8 Generalized Slices
22.4.9 Masks
22.4.10 Indirect Arrays
22.5 Complex Arithmetic
22.6 Generalized Numeric Algorithms
22.6.1 Accumulate
22.6.2 Inner_product
22.6.3 Incremental Change
22.7 Random Numbers
22.8 Advice
22.9 Exercises

Part IV: Design Using C++ ... pg 689
23 Development and Design
23.1 Overview
23.2 Introduction
23.3 Aims and Means
23.4 The Development Process
23.4.1 The Development Cycle
23.4.2 Design Aims
23.4.3 Design Steps
23.4.3.1 Step 1: Find Classes
23.4.3.2 Step 2: Specify Operations
23.4.3.3 Step 3: Specify Dependencies
23.4.3.4 Step 4: Specify Interfaces
23.4.3.5 Reorganization of Class Hierarchies
23.4.3.6 Use of Models
23.4.4 Experimentation and Analysis
23.4.5 Testing
23.4.6 Software Maintenance
23.4.7 Efficiency
23.5 Management
23.5.1 Reuse
23.5.2 Scale
23.5.3 Individuals
23.5.4 Hybrid Design
23.6 Annotated Bibliography
23.7 Advice
24 Design and Programming
24.1 Overview
24.2 Design and Programming Language
24.2.1 Ignoring Classes
24.2.2 Avoiding Inheritance
24.2.3 Ignoring Static Type Checking
24.2.4 Avoiding Programming
24.2.5 Using Class Hierarchies Exclusively
24.3 Classes
24.3.1 What Do Classes Represent?
24.3.2 Class Hierarchies
24.3.2.1 Dependencies within a Class Hierarchy
24.3.3 Containment Relationships
24.3.4 Containment and Inheritance
24.3.4.1 Member/Hierarchy Tradeoffs
24.3.4.2 Containment/Hierarchy Tradeoffs
24.3.5 Use Relationships
24.3.6 Programmed-In Relationships
24.3.7 Relationships within a Class
24.3.7.1 Invariants
24.3.7.2 Assertions
24.3.7.3 Preconditions and Postconditions
24.3.7.4 Encapsulation
24.4 Components
24.4.1 Templates
24.4.2 Interfaces and Implementations
24.4.3 Fat Interfaces
24.5 Advice
25 Roles of Classes
25.1 Kinds of Classes
25.2 Concrete Types
25.2.1 Reuse of Concrete Types
25.3 Abstract Types
25.4 Node Classes
25.4.1 Changing Interfaces
25.5 Actions
25.6 Interface Classes
25.6.1 Adjusting Interfaces
25.7 Handle Classes
25.7.1 Operations in Handles
25.8 Application Frameworks
25.9 Advice
25.10 Exercises

Appendices:
A The C++ Grammar ... pg 793
A.1 Introduction
A.2 Keywords
A.3 Lexical Conventions
A.4 Programs
A.5 Expressions
A.6 Statements
A.7 Declarations
A.7.1 Declarators
A.8 Classes
A.8.1 Derived Classes
A.8.2 Special Member Functions
A.8.3 Overloading
A.9 Templates
A.10 Exception Handling
A.11 Preprocessing Directives
B Compatibility
B.1 Introduction
B.2 C/C++ Compatibility
B.2.1 ``Silent'' Differences
B.2.2 C Code That Is Not C++
B.2.3 Deprecated Features
B.2.4 C++ Code That Is Not C
B.3 Coping with Older C++ Implementations
B.3.1 Headers
B.3.2 The Standard Library
B.3.3 Namespaces
B.3.4 Allocation Errors
B.3.5 Templates
B.3.6 For-Statement Initializers
C Technicalities
C.1 Introduction and Overview
C.2 The Standard
C.3 Character Sets
C.3.1 Restricted Character Sets
C.3.2 Escape Characters
C.3.3 Large Character Sets
C.3.4 Signed and Unsigned Characters
C.4 Types of Integer Literals
C.5 Constant Expressions
C.6 Implicit Type Conversion
C.6.1 Promotions
C.6.2 Conversions
C.6.2.1 Integral Conversions
C.6.2.2 Floating-Point Conversions
C.6.2.3 Pointer and Reference Conversions
C.6.2.4 Pointer-to-Member Conversions
C.6.2.5 Boolean Conversions
C.6.2.6 Floating-Integral Conversions
C.6.3 Usual Arithmetic Conversions
C.7 Multidimensional Arrays
C.7.1 Vectors
C.7.2 Arrays
C.7.3 Passing Multidimensional Arrays
C.8 Saving Space
C.8.1 Fields
C.8.2 Unions
C.8.3 Unions and Classes
C.9 Memory Management
C.9.1 Automatic Garbage Collection
C.9.1.1 Disguised Pointers
C.9.1.2 Delete
C.9.1.3 Destructors
C.9.1.4 Memory Fragmentation
C.10 Namespaces
C.10.1 Convenience vs. Safety
C.10.2 Nesting of Namespaces
C.10.3 Namespaces and Classes
C.11 Access Control
C.11.1 Access to Members
C.11.2 Access to Base Classes
C.11.3 Access to Member Class
C.11.4 Friendship
C.12 Pointers to Data Members
C.13 Templates
C.13.1 Static Members
C.13.2 Friends
C.13.3 Templates as Template Parameters
C.13.4 Typename and Template
C.13.6 Template as a Qualifier
C.13.7 Instantiation
C.13.8 Name Binding
C.13.8.1 Dependent Names
C.13.8.2 Point of Definition Binding
C.13.8.3 Point of Instantiation Binding
C.13.8.4 Templates and Namespaces
C.13.9 When Is a Specialization Needed?
C.13.9.1 Template Function Instantiation
C.13.10 Explicit Instantiation
C.14 Advice
D Locales
D.1 Handling Cultural Differences
D.1.1 Programming Cultural Differences
D.2 The locale Class
D.2.1 Named Locales
D.2.1.1 Constructing New Locales
D.2.2 Copying and Comparing Locales
D.2.3 The global() and the classic() Locales
D.2.4 Comparing Strings
D.3 Facets
D.3.1 Accessing Facets in a Locale
D.3.2 A Simple User-Defined Facet
D.3.3 Uses of Locales and Facets
D.4 Standard Facets
D.4.1 String Comparison
D.4.1.1 Named Collate
D.4.2 Numeric Input and Output
D.4.2.1 Numeric Punctuation
D.4.2.2 Numeric Output
D.4.2.3 Numeric Input
D.4.3 Input and Output of Monetary Values
D.4.3.1 Money Punctuation
D.4.3.2 Money Output
D.4.3.3 Money Input
D.4.4 Date and Time Input and Output
D.4.4.1 Clocks and Timers
D.4.4.2 A Date Class
D.4.4.3 Date and Time Output
D.4.4.4 Date and Time Input
D.4.4.5 A More Flexible Date Class
D.4.4.6 Specifying a Date Format
D.4.4.7 A Date Input Facet
D.4.5 Character Classification
D.4.5.1 Convenience Interfaces
D.4.6 Character Code Conversion
D.4.7 Messages
D.4.7.1 Using Messages from Other Facets
D.5 Advice
D.6 Exercises
E Standard-Library Exception Safety
E.1 Introduction
E.2 Exception Safety
E.3 Exception-Safe Implementation Techniques
E.3.1 A Simple Vector
E.3.2 Representing Memory Explicitly
E.3.3 Assignment
E.3.4 push_back()
E.3.5 Constructors and Invariants
E.3.5.1 Using init() Functions
E.3.5.2 Relying on a Default Valid State
E.3.5.3 Delaying resource acquisition
E.4 Standard Container Guarantees
E.4.1 Insertion and Removal of Elements
E.4.2 Guarantees and Tradeoffs
E.4.3 Swap
E.4.4 Initialization and Iterators
E.4.5 References to Elements
E.4.6 Predicates
E.5 The Rest of the Standard Library
E.5.1 Strings
E.5.2 Streams
E.5.3 Algorithms
E.5.4 Valarray and Complex
E.5.5 The C Standard Library
E.6 Implications for Library Users
E.7 Advice
E.8 Exercises
Index ... pg 969