gogogo
Syndetics cover image
Image from Syndetics

The C++ standard library : a tutorial and handbook / Nicolai M. Josuttis.

By: Material type: TextTextPublication details: Reading, Mass. : Addison-Wesley, c1999.Description: xx, 799 p. : ill. ; 25 cmISBN:
  • 0201379260
Other title:
  • C++ standard library, a tutorial and reference [Cover title]
  • C plus plus standard library
Subject(s): DDC classification:
  • 005.133 JOS
Holdings
Item type Current library Call number Copy number Status Date due Barcode
Standard Loan Thurles Library Main Collection 005.133 JOS (Browse shelf(Opens below)) 1 Available R17456KKRC
Standard Loan Thurles Library Main Collection 005.133 JOS (Browse shelf(Opens below)) 1 Available R18106PKRC

Enhanced descriptions from Syndetics:

The C++ standard library provides a set of common classes and interfaces that greatly extend the core C++ language. The library, however, is not self-explanatory. To make full use of its components-and to benefit from their power-you need a resource that does far more than list the classes and their functions. The C++ Standard Library not only provides comprehensive documentation of each library component, it also offers clearly written explanations of complex concepts, describes the practical programming details needed for effective use, and gives example after example of working code. This thoroughly up-to-date book reflects the newest elements of the C++ standard library incorporated into the full ANSI/ISO C++ language standard. In particular, the text focuses on the Standard Template Library (STL), examining containers, iterators, function objects, and STL algorithms. You will also find detailed coverage of special containers, strings, numerical classes, internationalization, and the IOStream library. Each component is presented in depth, with an introduction to its purpose and design, examples, a detailed description, traps and pitfalls, and the exact signature and definition

Includes bibliographical references (p. [745]-746) and index.

Table of contents provided by Syndetics

  • Preface (p. xvii)
  • Acknowledgments (p. xix)
  • 1 About this Book (p. 1)
  • 1.1 Why this Book (p. 1)
  • 1.2 What You Should Know Before Reading this Book (p. 2)
  • 1.3 Style and Structure of the Book (p. 2)
  • 1.4 How to Read this Book (p. 4)
  • 1.5 State of the Art (p. 5)
  • 1.6 Example Code and Additional Information (p. 5)
  • 1.7 Feedback (p. 5)
  • 2 Introduction to C++ and the Standard Library (p. 7)
  • 2.1 History (p. 7)
  • 2.2 New Language Features (p. 9)
  • 2.2.1 Templates (p. 9)
  • 2.2.2 Explicit Initialization for Fundamental Types (p. 14)
  • 2.2.3 Exception Handling (p. 15)
  • 2.2.4 Namespaces (p. 16)
  • 2.2.5 Type bool (p. 18)
  • 2.2.6 Keyword explicit (p. 18)
  • 2.2.7 New Operators for Type Conversion (p. 19)
  • 2.2.8 Initialization of Constant Static Members (p. 20)
  • 2.2.9 Definition of main() (p. 21)
  • 2.3 Complexity and the Big-O Notation (p. 21)
  • 3 General Concepts (p. 23)
  • 3.1 Namespace std (p. 23)
  • 3.2 Header Files (p. 24)
  • 3.3 Error and Exception Handling (p. 25)
  • 3.3.1 Standard Exception Classes (p. 25)
  • 3.3.2 Members of Exception Classes (p. 28)
  • 3.3.3 Throwing Standard Exceptions (p. 29)
  • 3.3.4 Deriving Standard Exception Classes (p. 30)
  • 3.4 Allocators (p. 31)
  • 4 Utilities (p. 33)
  • 4.1 Pairs (p. 33)
  • 4.1.1 Convenience Function make_pair() (p. 36)
  • 4.1.2 Examples of Pair Usage (p. 37)
  • 4.2 Class auto_ptr (p. 38)
  • 4.2.1 Motivation of Class auto_ptr (p. 38)
  • 4.2.2 Transfer of Ownership by auto_ptr (p. 40)
  • 4.2.3 auto_ptrs as Members (p. 44)
  • 4.2.4 Misusing auto_ptrs (p. 46)
  • 4.2.5 auto_ptr Examples (p. 47)
  • 4.2.6 Class auto_ptr in Detail (p. 51)
  • 4.3 Numeric Limits (p. 59)
  • 4.4 Auxiliary Functions (p. 66)
  • 4.4.1 Processing the Minimum and Maximum (p. 66)
  • 4.4.2 Swapping Two Values (p. 67)
  • 4.5 Supplementary Comparison Operators (p. 69)
  • 4.6 Header Files [cstddef] and [cstdlib] (p. 71)
  • 4.6.1 Definitions in [cstddef] (p. 71)
  • 4.6.2 Definitions in [cstdlib] (p. 71)
  • 5 The Standard Template Library (p. 73)
  • 5.1 STL Components (p. 73)
  • 5.2 Containers (p. 75)
  • 5.2.1 Sequence Containers (p. 76)
  • 5.2.2 Associative Containers (p. 81)
  • 5.2.3 Container Adapters (p. 82)
  • 5.3 Iterators (p. 83)
  • 5.3.1 Examples of Using Associative Containers (p. 86)
  • 5.3.2 Interator Categories (p. 93)
  • 5.4 Algorithms (p. 94)
  • 5.4.1 Ranges (p. 97)
  • 5.4.2 Handling Multiple Ranges (p. 101)
  • 5.5 Iterator Adapters (p. 104)
  • 5.5.1 Insert Iterators (p. 104)
  • 5.5.2 Stream Iterators (p. 107)
  • 5.5.3 Reverse Iterators (p. 109)
  • 5.6 Manipulating Algorithms (p. 111)
  • 5.6.1 "Removing" Elements (p. 111)
  • 5.6.2 Manipulating Algorithms and Associative Containers (p. 115)
  • 5.6.3 Algorithms versus Member Functions (p. 116)
  • 5.7 User-Defined Generic Functions (p. 117)
  • 5.8 Functions as Algorithm Arguments (p. 119)
  • 5.8.1 Examples of Using Functions as Algorithm Arguments (p. 119)
  • 5.8.2 Predicates (p. 121)
  • 5.9 Function Objects (p. 124)
  • 5.9.1 What Are Function Objects? (p. 124)
  • 5.9.2 Predefined Function Objects (p. 131)
  • 5.10 Container Elements (p. 134)
  • 5.10.1 Requirements for Container Elements (p. 134)
  • 5.10.2 Value Semantics or Reference Semantics (p. 135)
  • 5.11 Errors and Exceptions Inside the STL (p. 136)
  • 5.11.1 Error Handling (p. 137)
  • 5.11.2 Exception Handling (p. 139)
  • 5.12 Extending the STL (p. 141)
  • 6 STL Containers (p. 143)
  • 6.1 Common Container Abilities and Operations (p. 144)
  • 6.1.1 Common Container Abilities (p. 144)
  • 6.1.2 Common Container Operations (p. 144)
  • 6.2 Vectors (p. 148)
  • 6.2.1 Abilities of Vectors (p. 148)
  • 6.2.2 Vector Operations (p. 150)
  • 6.2.3 Using Vectors as Ordinary Arrays (p. 155)
  • 6.2.4 Exception Handling (p. 155)
  • 6.2.5 Examples of Using Vectors (p. 156)
  • 6.2.6 Class vector[bool] (p. 158)
  • 6.3 Deques (p. 160)
  • 6.3.1 Abilities of Deques (p. 161)
  • 6.3.2 Deque Operations (p. 162)
  • 6.3.3 Exception Handling (p. 164)
  • 6.3.4 Examples of Using Deques (p. 164)
  • 6.4 Lists (p. 166)
  • 6.4.1 Abilities of Lists (p. 166)
  • 6.4.2 List Operations (p. 167)
  • 6.4.3 Exception Handling (p. 172)
  • 6.4.4 Examples of Using Lists (p. 172)
  • 6.5 Sets and Multisets (p. 175)
  • 6.5.1 Abilities of Sets and Multisets (p. 176)
  • 6.5.2 Set and Multiset Operations (p. 177)
  • 6.5.3 Exception Handling (p. 185)
  • 6.5.4 Examples of Using Sets and Multisets (p. 186)
  • 6.5.5 Example of Specifying the Sorting Criterion at Runtime (p. 191)
  • 6.6 Maps and Multimaps (p. 194)
  • 6.6.1 Abilities of Maps and Multimaps (p. 195)
  • 6.6.2 Map and Multimap Operations (p. 196)
  • 6.6.3 Using Maps as Associative Arrays (p. 205)
  • 6.6.4 Exception Handling (p. 207)
  • 6.6.5 Examples of Using Maps and Multimaps (p. 207)
  • 6.6.6 Example with Maps, Strings, and Sorting Criterion at Runtime (p. 213)
  • 6.7 Other STL Containers (p. 217)
  • 6.7.1 Strings as STL Containers (p. 217)
  • 6.7.2 Ordinary Arrays as STL Containers (p. 218)
  • 6.7.3 Hash Tables (p. 221)
  • 6.8 Implementing Reference Semantics (p. 222)
  • 6.9 When to Use which Container (p. 226)
  • 6.10 Container Types and Members in Detail (p. 230)
  • 6.10.1 Type Definitions (p. 230)
  • 6.10.2 Create, Copy, and Destroy Operations (p. 231)
  • 6.10.3 Nonmodifying Operations (p. 233)
  • 6.10.4 Assignments (p. 236)
  • 6.10.5 Direct Element Access (p. 237)
  • 6.10.6 Operations to Generate Iterators (p. 239)
  • 6.10.7 Inserting and Removing Elements (p. 240)
  • 6.10.8 Special Member Functions for Lists (p. 244)
  • 6.10.9 Allocator Support (p. 246)
  • 6.10.10 Overview of Exception Handling in STL Containers (p. 248)
  • 7 STL Iterators
  • 7.1 Header Files for Iterators (p. 251)
  • 7.2 Iterator Categories (p. 251)
  • 7.2.1 Input Iterators (p. 252)
  • 7.2.2 Output Iterators (p. 253)
  • 7.2.3 Forward Iterators (p. 254)
  • 7.2.4 Bidirectional Iterators (p. 255)
  • 7.2.5 Random Access Iterators (p. 255)
  • 7.2.6 The Increment and Decrement Problem of Vector Iterators (p. 258)
  • 7.3 Auxiliary Iterator Functions (p. 259)
  • 7.3.1 Stepping Iterators Using advance() (p. 259)
  • 7.3.2 Processing Iterator Distance Using distance() (p. 261)
  • 7.3.3 Swapping Iterator Values Using iter_swap() (p. 263)
  • 7.4 Iterator Adapters (p. 264)
  • 7.4.1 Reverse Iterators (p. 264)
  • 7.4.2 Insert Iterators (p. 271)
  • 7.4.3 Stream Iterators (p. 277)
  • 7.5 Iterator Traits (p. 283)
  • 7.5.1 Writing Generic Functions for Iterators (p. 285)
  • 7.5.2 User-Defined Iterators (p. 288)
  • 8 STL Function Objects (p. 293)
  • 8.1 The Concept of Function Objects (p. 293)
  • 8.1.1 Function Objects as Sorting Criteria (p. 294)
  • 8.1.2 Function Objects with Internal State (p. 296)
  • 8.1.3 The Return Value of for_each() (p. 300)
  • 8.1.4 Predicates versus Function Objects (p. 302)
  • 8.2 Predefined Function Objects (p. 305)
  • 8.2.1 Function Adapters (p. 306)
  • 8.2.2 Function Adapters for Member Functions (p. 307)
  • 8.2.3 Function Adapters for Ordinary Functions (p. 309)
  • 8.2.4 User-Defined Function Objects for Function Adapters (p. 310)
  • 8.3 Supplementary Composing Function Objects (p. 313)
  • 8.3.1 Unary Compose Function Object Adapters (p. 314)
  • 8.3.2 Binary Compose Function Object Adapters (p. 318)
  • 9 STL Algorithms (p. 321)
  • 9.1 Algorithm Header Files (p. 321)
  • 9.2 Algorithm Overview (p. 322)
  • 9.2.1 A Brief Introduction (p. 322)
  • 9.2.2 Classification of Algorithms (p. 323)
  • 9.3 Auxiliary Functions (p. 332)
  • 9.4 The for_each () Algorithm (p. 334)
  • 9.5 Nonmodifying Algorithms (p. 338)
  • 9.5.1 Counting Elements (p. 338)
  • 9.5.2 Minimum and Maximum (p. 339)
  • 9.5.3 Searching Elements (p. 341)
  • 9.5.4 Comparing Ranges (p. 356)
  • 9.6 Modifying Algorithms (p. 363)
  • 9.6.1 Copying Elements (p. 363)
  • 9.6.2 Transforming and Combining Elements (p. 366)
  • 9.6.3 Swapping Elements (p. 370)
  • 9.6.4 Assigning New Values (p. 372)
  • 9.6.5 Replacing Elements (p. 375)
  • 9.7 Removing Algorithms (p. 378)
  • 9.7.1 Removing Certain Values (p. 378)
  • 9.7.2 Removing Duplicates (p. 381)
  • 9.8 Mutating Algorithms (p. 386)
  • 9.8.1 Reversing the Order of Elements (p. 386)
  • 9.8.2 Rotating Elements (p. 388)
  • 9.8.3 Permuting Elements (p. 391)
  • 9.8.4 Shuffling Elements (p. 393)
  • 9.8.5 Moving Elements to the Front (p. 395)
  • 9.9 Sorting Algorithms (p. 397)
  • 9.9.1 Sorting All Elements (p. 397)
  • 9.9.2 Partial Sorting (p. 400)
  • 9.9.3 Sorting According to the nth Element (p. 404)
  • 9.9.4 Heap Algorithms (p. 406)
  • 9.10 Sorted Range Algorithms (p. 409)
  • 9.10.1 Searching Elements (p. 410)
  • 9.10.2 Merging Elements (p. 416)
  • 9.11 Numeric Algorithms (p. 425)
  • 9.11.1 Processing Results (p. 425)
  • 9.11.2 Converting Relative and Absolute Values (p. 429)
  • 10 Special Containers (p. 435)
  • 10.1 Stacks (p. 435)
  • 10.1.1 The Core Interface (p. 436)
  • 10.1.2 Example of Using Stacks (p. 437)
  • 10.1.3 Class stack[] in Detail (p. 438)
  • 10.1.4 A User-Defined Stack Class (p. 441)
  • 10.2 Queues (p. 444)
  • 10.2.1 The Core Interface (p. 445)
  • 10.2.2 Example of Using Queues (p. 446)
  • 10.2.3 Class queue[] in Detail (p. 447)
  • 10.2.4 A User-Defined Queue Class (p. 450)
  • 10.3 Priority Queues (p. 453)
  • 10.3.1 The Core Interface (p. 455)
  • 10.3.2 Example of Using Priority Queues (p. 455)
  • 10.3.3 Class priority_queue[] in Detail (p. 456)
  • 10.4 Bitsets (p. 460)
  • 10.4.1 Examples of Using Bitsets (p. 460)
  • 10.4.2 Class bitset in Detail (p. 463)
  • 11 Strings (p. 471)
  • 11.1 Motivation (p. 471)
  • 11.1.1 A First Example: Extracting a Temporary File Name (p. 472)
  • 11.1.2 A Second Example: Extracting Words and Printing Them Backward (p. 476)
  • 11.2 Description of the String Classes (p. 479)
  • 11.2.1 String Types (p. 479)
  • 11.2.2 Operation Overview (p. 481)
  • 11.2.3 Constructors and Destructors (p. 483)
  • 11.2.4 Strings and C-Strings (p. 484)
  • 11.2.5 Size and Capacity (p. 485)
  • 11.2.6 Element Access (p. 487)
  • 11.2.7 Comparisons (p. 488)
  • 11.2.8 Modifiers (p. 489)
  • 11.2.9 Substrings and String Concatenation (p. 492)
  • 11.2.10 Input/Output Operators (p. 492)
  • 11.2.11 Searching and Finding (p. 493)
  • 11.2.12 The Value npos (p. 495)
  • 11.2.13 Iterator Support for Strings (p. 497)
  • 11.2.14 Internationalization (p. 503)
  • 11.2.15 Performance (p. 506)
  • 11.2.16 Strings and Vectors (p. 506)
  • 11.3 String Class in Detail (p. 507)
  • 11.3.1 Type Definitions and Static Values (p. 507)
  • 11.3.2 Create, Copy, and Destroy Operations (p. 508)
  • 11.3.3 Operations for Size and Capacity (p. 510)
  • 11.3.4 Comparisons (p. 511)
  • 11.3.5 Character Access (p. 512)
  • 11.3.6 Generating C-Strings and Character Arrays (p. 513)
  • 11.3.7 Modifying Operations (p. 514)
  • 11.3.8 Searching and Finding (p. 520)
  • 11.3.9 Substrings and String Concatenation (p. 524)
  • 11.3.10 Input/Output Functions (p. 524)
  • 11.3.11 Generating Iterators (p. 525)
  • 11.3.12 Allocator Support (p. 526)
  • 12 Numerics (p. 529)
  • 12.1 Complex Numbers (p. 529)
  • 12.1.1 Examples Using Class Complex (p. 530)
  • 12.1.2 Operations for Complex Numbers (p. 533)
  • 12.1.3 Class complex[] in Detail (p. 541)
  • 12.2 Valarrays (p. 547)
  • 12.2.1 Getting to Know Valarrays (p. 547)
  • 12.2.2 Valarray Subsets (p. 553)
  • 12.2.3 Class valarray in Detail (p. 569)
  • 12.2.4 Valarray Subset Classes in Detail (p. 575)
  • 12.3 Global Numeric Functions (p. 581)
  • 13 Input/Output Using Stream Classes (p. 583)
  • 13.1 Common Background of I/O Streams (p. 584)
  • 13.1.1 Stream Objects (p. 584)
  • 13.1.2 Stream Classes (p. 584)
  • 13.1.3 Global Stream Objects (p. 585)
  • 13.1.4 Stream Operators (p. 586)
  • 13.1.5 Manipulators (p. 586)
  • 13.1.6 A Simple Example (p. 587)
  • 13.2 Fundamental Stream Classes and Objects (p. 588)
  • 13.2.1 Classes and Class Hierarchy (p. 588)
  • 13.2.2 Global Stream Objects (p. 591)
  • 13.2.3 Header Files (p. 592)
  • 13.3 Standard Stream Operators [[and]] (p. 593)
  • 13.3.1 Output Operator [[ (p. 593)
  • 13.3.2 Input Operator]] (p. 594)
  • 13.3.3 Input/Output of Special Types (p. 595)
  • 13.4 State of Streams (p. 597)
  • 13.4.1 Constants for the State of Streams (p. 597)
  • 13.4.2 Member Functions Accessing the State of Streams (p. 598)
  • 13.4.3 Stream State and Boolean Conditions (p. 600)
  • 13.4.4 Stream State and Exceptions (p. 602)
  • 13.5 Standard Input/Output Functions (p. 607)
  • 13.5.1 Member Functions for Input (p. 607)
  • 13.5.2 Member Functions for Output (p. 610)
  • 13.5.3 Example Uses (p. 611)
  • 13.6 Manipulators (p. 612)
  • 13.6.1 How Manipulators Work (p. 612)
  • 13.6.2 User-Defined Manipulators (p. 614)
  • 13.7 Formatting (p. 615)
  • 13.7.1 Format Flags (p. 615)
  • 13.7.2 Input/Output Format of Boolean Values (p. 617)
  • 13.7.3 Field Width, Fill Character, and Adjustment (p. 618)
  • 13.7.4 Positive Sign and Uppercase Letters (p. 620)
  • 13.7.5 Numeric Base (p. 621)
  • 13.7.6 Floating-Point Notation (p. 623)
  • 13.7.7 General Formatting Definitions (p. 625)
  • 13.8 Internationalization (p. 625)
  • 13.9 File Access (p. 627)
  • 13.9.1 File Flags (p. 631)
  • 13.9.2 Random Access (p. 634)
  • 13.9.3 Using File Descriptors (p. 637)
  • 13.10 Connecting Input and Output Streams (p. 637)
  • 13.10.1 Loose Coupling Using tie() (p. 637)
  • 13.10.2 Tight Coupling Using Stream Buffers (p. 638)
  • 13.10.3 Redirecting Standard Streams (p. 641)
  • 13.10.4 Streams for Reading and Writing (p. 643)
  • 13.11 Stream Classes for Strings (p. 645)
  • 13.11.1 String Stream Classes (p. 645)
  • 13.11.2 char* Stream Classes (p. 649)
  • 13.12 Input/Output Operators for User-Defined Types (p. 652)
  • 13.12.1 Implementing Output Operators (p. 652)
  • 13.12.2 Implementing Input Operators (p. 654)
  • 13.12.3 Input/Output Using Auxiliary Functions (p. 656)
  • 13.12.4 User-Defined Operators Using Unformatted Functions (p. 658)
  • 13.12.5 User-Defined Format Flags (p. 659)
  • 13.12.6 Conventions for User-Defined Input/Output Operators (p. 662)
  • 13.13 The Stream Buffer Classes (p. 663)
  • 13.13.1 User's View of Stream Buffers (p. 663)
  • 13.13.2 Stream Buffer Iterators (p. 665)
  • 13.13.3 User-Defined Stream Buffers (p. 668)
  • 13.14 Performance Issues (p. 681)
  • 13.14.1 Synchronization with C's Standard Streams (p. 682)
  • 13.14.2 Buffering in Stream Buffers (p. 682)
  • 13.14.3 Using Stream Buffers Directly (p. 683)
  • 14 Internationalization (p. 685)
  • 14.1 Different Character Encodings (p. 686)
  • 14.1.1 Wide-Character and Multibyte Text (p. 686)
  • 14.1.2 Character Traits (p. 687)
  • 14.1.3 Internationalization of Special Characters (p. 691)
  • 14.2 The Concept of Locales (p. 692)
  • 14.2.1 Using Locales (p. 693)
  • 14.2.2 Locale Facets (p. 698)
  • 14.3 Locales in Detail (p. 700)
  • 14.4 Facets in Detail (p. 704)
  • 14.4.1 Numeric Formatting (p. 705)
  • 14.4.2 Time and Date Formatting (p. 708)
  • 14.4.3 Monetary Formatting (p. 711)
  • 14.4.4 Character Classification and Conversion (p. 715)
  • 14.4.5 String Collation (p. 724)
  • 14.4.6 Internationalized Messages (p. 725)
  • 15 Allocators (p. 727)
  • 15.1 Using Allocators as an Application Programmer (p. 727)
  • 15.2 Using Allocators as a Library Programmer (p. 728)
  • 15.3 The Default Allocator (p. 732)
  • 15.4 A User-Defined Allocator (p. 735)
  • 15.5 Allocators in Detail (p. 737)
  • 15.5.1 Type Definitions (p. 737)
  • 15.5.2 Operations (p. 739)
  • 15.6 Utilities for Uninitialized Memory in Detail (p. 740)
  • Internet Resources (p. 743)
  • Bibliography (p. 745)
  • Index (p. 747)

Excerpt provided by Syndetics

In the beginning, I only planned to write a small German book (400 pages or so) about the C++ Standard Library. That was in 1993. Now, in 1999 you see the result--an English book with more than 800 pages of facts, figures, and examples. My goal is to describe the C++ Standard Library so that all (or almost all) your programming questions are answered before you think of the question. Note, however, that this is not a complete description of all aspects of the C++ Standard Library. Instead, I present the most important topics necessary for learning and programming in C++by using its standard library. Each topic is described based on the general concepts;this discussion then leads to the specific details needed to support everyday programming tasks. Specific code examples are provided to help you understand the concepts and the details. That's it--in a nutshell. I hope you get as much pleasure from reading this book as I did from writing it. Enjoy! Acknowledgments This book presents ideas, concepts,solutions, and examples from many sources. In a way it does not seem fair that my name is the only name on the cover. Thus, I'd like to thank all the people and companies who helped and supported me during the past few years. First, I'd like to thank Dietmar Kuhl. Dietmar is an expert on C++, especially on input/output streams and internationalization (he implemented an I/O stream library just for fun). He not only translated major parts of this book from German to English, he also wrote sections of this book using his expertise. In addition, he provided me with invaluable feedback over the years. Second, I'd like to thank all the reviewers and everyone else who gave me their opinion. These people endow the book with a quality it would never have had without their input. (Because the list is extensive, please forgive me for any oversight.) The reviewers for the English version of this book included Chuck Allison, Greg Comeau, James A. Crotinger, Gabriel Dos Reis, Alan Ezust, Nathan Meyers, Werner Mossner, Todd Veldhuizen, Chichiang Wan, Judy Ward, and Thomas Wikehult. The German reviewers included Ralf Boecker, Dirk Herrmann, Dietmar Kuhl, Edda Lorke, Herbert Scheubner, Dominik Strasser, and Martin Weitzel. Additional input was provided by Matt Austern, Valentin Bonnard, Greg Colvin, Beman Dawes, Bill Gibbons, Lois Goldthwaite, Andrew Koenig, Steve Rumbsby, Bjarne Stroustrup, and David Vandevoorde. Special thanks to Dave Abrahams, Janet Cocker, Catherine Ohala, and Maureen Willard who reviewed and edited the whole book very carefully. Their feedback was an incredible contribution to the quality of this book. A special thanks goes to my "personal living dictionary"--Herb Sutter--the author of the famous "Guru of the Week" (a regular series of C++ programming problems that is published on thecomp.std.c++.moderatedInternet newsgroup). I'd also like to thank all the people and companies who gave me the opportunity to test my examples on different platforms with different compilers. Many thanks to Steve Adamczyk, Mike Anderson, and John Spicer from EDG for their great compiler and their support. It was a big help during the standardization process and the writing of this book. Many thanks to P. J. Plauger and Dinkumware, Ltd, for their early standard-conforming implementation of the C++ Standard Library. Many thanks to Andreas Hommel and Metrowerks for an evaluative version of their CodeWarrior Programming Environment. Many thanks to all the developers of the free GNU and egcs compilers. Many thanks to Microsoft for an evaluative version of Visual C++. Many thanks to Roland Hartinger from Siemens Nixdorf Informations Systems AG for a test version of their C++ compiler. Many thanks to Topjects GmbH for an evaluative version of the ObjectSpace library implementation. And, of course many thanks for those who invented, designed, or implemented C++ or parts of the library. Among others are Bjarne Stroustrup, Alexander Stepanov, Meng Lee, Matt Austern, Boris P. Fomichev, and all the other guys who wrote the SGI STL and the STLport. Many thanks to everyone from Addison Wesley Longman who worked with me. Among others this includes Janet Cocker, Mike Hendrickson, Debbie Lafferty, Marina Lang, Chanda Leary, Catherine Ohala, Marty Rabinowitz, Susanne Spitzer,and Maureen Willard. It was fun. In addition, I'd like to thank the people at BREDEX GmbH and all the people in the C++ community, particularly those involved with the standardization process, for their support and patience (sometimes I ask really silly questions). Last but not least, many thanks and kisses for my family: Ulli, Lucas, Anica, and Frederic. I definitely did not have enough time for them due to the writing of this book. Have fun and be human! About this Book Soon after its introduction, C++ became a de facto standard in object-oriented programming. This led to the goal of standardization. Only by having a standard, could programs be written that would run on different platforms--from PCs to mainframes. Furthermore, a standard C++ library would enable programmers to use general components and a higher level of abstraction without losing portability, rather than having to develop all code from scratch. The standardization process was started in 1989 by an international ANSI/ISO committee. It developed the standard based on Bjarne Stroustrup's books ( The C++ Programming Language ) and ( The Annotated C++ Reference Manual) . After the standard was completed in 1997,several formal motions by different countries made it an international ISO and ANSI standard in 1998. The standardization process included the development of a C++ Standard Library. The library extends the core language to provide some general components. By using C++'s ability to program new abstract and generic types, the library provides a set of common classes and interfaces. This gives programmers a higher level of abstraction. The library provides the ability to use string types, different data structures (such as dynamic arrays, linked lists, and binary trees), different algorithms (such as different sorting algorithms), numeric classes, input/output (I/O) classes, and classes for internationalization support. All of these are supported by a fairly simple programming interface. These components are very important for many programs. These days, data processing often means inputting, computing, processing, and outputting large amounts of data, which are often strings. The library is not self-explanatory. To use these components and to benefit from their power,you need a good introduction that explains the concepts and the important details instead of simply listing the classes and their functions. This book is written exactly for that purpose. First, it introduces the library and all of its components from a conceptional point of view. Next, it describes the details needed for practical programming. Examples are included to demonstrate the exact usage of the components. Thus, this book is a detailed introduction to the C++ library for both the beginner and the practical programmer. Armed with the data provided herein, you should be able to take full advantage of the C++ Standard Library. Caveat I don't promise that everything described is easy and self-explanatory. The library provides a lot of flexibility,but flexibility for nontrivial purposes has a price. Beware that the library has traps and pitfalls,which I point out when we encounter them and suggest ways of avoiding them. What You Should Know Before Reading this Book To get the most from this book you should already know C++. (The book describes the standard components of C++, but not the language itself.) You should be familiar with the concepts of classes, inheritance,templates, and exception handling. However, you don't have to know all of the minor details about the language. The important details are described in the book (the minor details about the language are more important for people who want to implement the library rather than use it). Note that the language has changed during the standardization process,so your knowledge might not be up to date. The section on newlang features provides a brief overview and introduction of the latest language features that are important for using the library. You should read this section if you are not sure whether you know all the new features of C++ (such as the keyword{{\tt typename}}and the concept of namespaces). Style and Structure of the Book The C++ Standard Library provides different components that are somewhat but not totally independent of each other,so there is no easy way to describe each part without mentioning others. I considered several different approaches for presenting the contents of this book. One was on the order of the C++ standard. However, this is not the best way to explain the components of the C++ Standard Library from scratch. Another was to start with an overview of all components followed by chapters that provided more details. Alternatively, I could have sorted the components, trying to find an order that had a minimum of cross-references to other sections. My solution was to use a mixture of all three approaches. I start with a brief introduction of the general concepts and the utilities that are used by the library. Then, I describe all the components, each in one or more chapters. The first component is the standard template library (STL). There is no doubt that the STL is the most powerful, most complex, and most exciting part of the library. Its design influences other components heavily. Then I describe the more self-explanatory components, such as special containers, strings,and numeric classes. The next component discussed is one you probably know and use already: theiostreamlib{{}}. It is followed by a discussion of internationalization, which had some influence on theiostreamlib{{}}. Each component description begins with the component's purpose, design, and some examples. Next, a detailed description follows that begins with different ways to use the component, as well as any traps and pitfalls associated with it. The description usually ends with a reference section, in which you can find the exact signature and definition of a component's classes and its functions. How to Read this Book This book is a mix of introductory user's guide and structured reference manual regarding the C++ Standard Library. The individual components of the C++ Standard Library are independent of each other, to some extent, so after reading Chapters 2 through 4 you could read the chapters that discuss the individual components in any order. Bear in mind,that Chapters 5 through 9 all describe the same component. To understand the other STL chapters, you should start with the introduction to the STL in chapter 5. If you are a C++ programmer who wants to know, in general, the concepts and all parts of the library, you could simply read the book from the beginning to the end. However, you should skip the reference sections (which usually are named something like "...{{}}in detail}}"). To program with certain components of the C++ Standard Library, the best way to find something is to use the index. I have tried to make the index very comprehensive to save you time when you are looking for something. I can't explain all aspects at the same time, so you will find many cross references. It is always a problem to decide whether to follow them. If the cross reference refers to a section that will follow soon, take it as hint that I return to an aspect later. You should follow the cross reference only if you are searching for certain aspects or details and the cross reference seems to lead to details concerning your problem or its solution. In my experience, the best way to learn something new is to look at examples. Therefore, you'll find a lot of examples throughout the book. They may be a few lines of code or complete programs. In the latter case, you'll find the name of the file containing the program's first comment line. You can find the files on the Internet at my Web site http://www.josuttis.com/libbook/ . State of the Art While I was writing this book,the C++ standard was completed. Please bear in mind that some compilers might not yet confirm to it. This will most likely change in the near future. As a consequence, you might discover that not all things covered in this book work as described on your system,and you may have to change example programs to fit your specific environment. I can compile almost all example programs with version 2.8 or higher of the EGCS compiler, which is free for almost all platforms and available on the Internet (see http://egcs.cygnus.com/ ) and on several software CDs. Example Code and Additional Information You can access all example programs and acquire more informations about this book and the C++ Standard Library from my Web site at http://www.josuttis.com/libbook/ . Please read the{{\tt README}}file for further details. Also, you can find a lot of additional information about this topic on the Internet. See Internet Resources on page 743 for details. Feedback I welcome your feedback (good and bad) on this book. I tried to prepare it carefully; however, I'm human, and at some time I have to stop writing and tweaking. So, you may find some errors, inconsistencies, or subjects that could be described better. Your feedback will give me the chance to improve later editions. The best way to reach me is by Email: libbook@josuttis . You can also reach me by phone, fax, or "snail" mail: Nicolai M. Josuttis Berggarten 9 D--38108 Braunschweig Germany Phone: +49 5309 5747 Fax: +49 5309 5774 Many thanks. 0201379260P04062001 Excerpted from The C++ Standard Library: A Tutorial and Reference by Nicolai M. Josuttis All rights reserved by the original copyright owners. Excerpts are provided for display purposes only and may not be reproduced, reprinted or distributed without the written permission of the publisher.

Author notes provided by Syndetics

Nicolai M. Josuttis is an independent technical consultant who designs object-oriented software for the telecommunication, traffic, finance, and manufacturing industries. He is an active member of the C++ Standard Committee library working group and a partner at System Bauhaus, a German group of recognized object-oriented system development experts. Josuttis has written several books on object-oriented programming and C++, including Die C++-Standardbibliothek and Objektorientiertes Programmieren in C++.

Powered by Koha