Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo
The C++ Programming Language, Fourth Edition

Book Description

The new C++11 standard allows programmers to express ideas more clearly, simply, and directly, and to write faster, more efficient code. Bjarne Stroustrup, the designer and original implementer of C++, has reorganized, extended, and completely rewritten his definitive reference and tutorial for programmers who want to use C++ most effectively.

The C++ Programming Language, Fourth Edition, delivers meticulous, richly explained, and integrated coverage of the entire language—its facilities, abstraction mechanisms, standard libraries, and key design techniques. Throughout, Stroustrup presents concise, “pure C++11” examples, which have been carefully crafted to clarify both usage and program design. To promote deeper understanding, the author provides extensive cross-references, both within the book and to the ISO standard.

New C++11 coverage includes

  • Support for concurrency

  • Regular expressions, resource management pointers, random numbers, and improved containers

  • General and uniform initialization, simplified for-statements, move semantics, and Unicode support

  • Lambdas, general constant expressions, control over class defaults, variadic templates, template aliases, and user-defined literals

  • Compatibility issues 

  • Topics addressed in this comprehensive book include

  • Basic facilities: type, object, scope, storage, computation fundamentals, and more

  • Modularity, as supported by namespaces, source files, and exception handling

  • C++ abstraction, including classes, class hierarchies, and templates in support of a synthesis of traditional programming, object-oriented programming, and generic programming

  • Standard Library: containers, algorithms, iterators, utilities, strings, stream I/O, locales, numerics, and more

  • The C++ basic memory model, in depth 

  • This fourth edition makes C++11 thoroughly accessible to programmers moving from C++98 or other languages, while introducing insights and techniques that even cutting-edge C++11 programmers will find indispensable.

    This book features an enhanced, layflat binding, which allows the book to stay open more easily when placed on a flat surface. This special binding method—noticeable by a small space inside the spine—also increases durability.

    Table of Contents

    1. About This eBook
    2. Title Page
    3. Copyright Page
    4. Contents
    5. Preface
      1. Acknowledgments
    6. Preface to the Third Edition
      1. Acknowledgments
    7. Preface to the Second Edition
      1. Acknowledgments
    8. Preface to the First Edition
      1. Acknowledgments
    9. Part I: Introduction
      1. 1. Notes to the Reader
        1. 1.1. The Structure of This Book
          1. 1.1.1. Introduction
          2. 1.1.2. Basic Facilities
          3. 1.1.3. Abstraction Mechanisms
          4. 1.1.4. The Standard Library
          5. 1.1.5. Examples and References
        2. 1.2. The Design of C++
          1. 1.2.1. Programming Style
          2. 1.2.2. Type Checking
          3. 1.2.3. C Compatibility
          4. 1.2.4. Language, Libraries, and Systems
        3. 1.3. Learning C++
          1. 1.3.1. Programming in C++
          2. 1.3.2. Suggestions for C++ Programmers
          3. 1.3.3. Suggestions for C Programmers
          4. 1.3.4. Suggestions for Java Programmers
        4. 1.4. History
          1. 1.4.1. Timeline
          2. 1.4.2. The Early Years
          3. 1.4.3. The 1998 Standard
          4. 1.4.4. The 2011 Standard
          5. 1.4.5. What is C++ used for?
        5. 1.5. Advice
        6. 1.6. References
      2. 2. A Tour of C++: The Basics
        1. 2.1. Introduction
        2. 2.2. The Basics
          1. 2.2.1. Hello, World!
          2. 2.2.2. Types, Variables, and Arithmetic
          3. 2.2.3. Constants
          4. 2.2.4. Tests and Loops
          5. 2.2.5. Pointers, Arrays, and Loops
        3. 2.3. User-Defined Types
          1. 2.3.1. Structures
          2. 2.3.2. Classes
          3. 2.3.3. Enumerations
        4. 2.4. Modularity
          1. 2.4.1. Separate Compilation
          2. 2.4.2. Namespaces
          3. 2.4.3. Error Handling
        5. 2.5. Postscript
        6. 2.6. Advice
      3. 3. A Tour of C++: Abstraction Mechanisms
        1. 3.1. Introduction
        2. 3.2. Classes
          1. 3.2.1. Concrete Types
          2. 3.2.2. Abstract Types
          3. 3.2.3. Virtual Functions
          4. 3.2.4. Class Hierarchies
        3. 3.3. Copy and Move
          1. 3.3.1. Copying Containers
          2. 3.3.2. Moving Containers
          3. 3.3.3. Resource Management
          4. 3.3.4. Suppressing Operations
        4. 3.4. Templates
          1. 3.4.1. Parameterized Types
          2. 3.4.2. Function Templates
          3. 3.4.3. Function Objects
          4. 3.4.4. Variadic Templates
          5. 3.4.5. Aliases
        5. 3.5. Advice
      4. 4. A Tour of C++: Containers and Algorithms
        1. 4.1. Libraries
          1. 4.1.1. Standard-Library Overview
          2. 4.1.2. The Standard-library Headers and Namespace
        2. 4.2. Strings
        3. 4.3. Stream I/O
          1. 4.3.1. Output
          2. 4.3.2. Input
          3. 4.3.3. I/O of User-Defined Types
        4. 4.4. Containers
          1. 4.4.1. vector
          2. 4.4.2. list
          3. 4.4.3. map
          4. 4.4.4. unordered_map
          5. 4.4.5. Container Overview
        5. 4.5. Algorithms
          1. 4.5.1. Use of Iterators
          2. 4.5.2. Iterator Types
          3. 4.5.3. Stream Iterators
          4. 4.5.4. Predicates
          5. 4.5.5. Algorithm Overview
          6. 4.5.6. Container Algorithms
        6. 4.6. Advice
      5. 5. A Tour of C++: Concurrency and Utilities
        1. 5.1. Introduction
        2. 5.2. Resource Management
          1. 5.2.1. unique_ptr and shared_ptr
        3. 5.3. Concurrency
          1. 5.3.1. Tasks and threads
          2. 5.3.2. Passing Arguments
          3. 5.3.3. Returning Results
          4. 5.3.4. Sharing Data
          5. 5.3.5. Communicating Tasks
        4. 5.4. Small Utility Components
          1. 5.4.1. Time
          2. 5.4.2. Type Functions
          3. 5.4.3. pair and tuple
        5. 5.5. Regular Expressions
        6. 5.6. Math
          1. 5.6.1. Mathematical Functions and Algorithms
          2. 5.6.2. Complex Numbers
          3. 5.6.3. Random Numbers
          4. 5.6.4. Vector Arithmetic
          5. 5.6.5. Numeric Limits
        7. 5.7. Advice
    10. Part II: Basic Facilities
      1. 6. Types and Declarations
        1. 6.1. The ISO C++ Standard
          1. 6.1.1. Implementations
          2. 6.1.2. The Basic Source Character Set
        2. 6.2. Types
          1. 6.2.1. Fundamental Types
          2. 6.2.2. Booleans
          3. 6.2.3. Character Types
          4. 6.2.4. Integer Types
          5. 6.2.5. Floating-Point Types
          6. 6.2.6. Prefixes and Suffixes
          7. 6.2.7. void
          8. 6.2.8. Sizes
          9. 6.2.9. Alignment
        3. 6.3. Declarations
          1. 6.3.1. The Structure of Declarations
          2. 6.3.2. Declaring Multiple Names
          3. 6.3.3. Names
          4. 6.3.4. Scope
          5. 6.3.5. Initialization
          6. 6.3.6. Deducing a Type: auto and decltype()
        4. 6.4. Objects and Values
          1. 6.4.1. Lvalues and Rvalues
          2. 6.4.2. Lifetimes of Objects
        5. 6.5. Type Aliases
        6. 6.6. Advice
      2. 7. Pointers, Arrays, and References
        1. 7.1. Introduction
        2. 7.2. Pointers
          1. 7.2.1. void*
          2. 7.2.2. nullptr
        3. 7.3. Arrays
          1. 7.3.1. Array Initializers
          2. 7.3.2. String Literals
        4. 7.4. Pointers into Arrays
          1. 7.4.1. Navigating Arrays
          2. 7.4.2. Multidimensional Arrays
          3. 7.4.3. Passing Arrays
        5. 7.5. Pointers and const
        6. 7.6. Pointers and Ownership
        7. 7.7. References
          1. 7.7.1. Lvalue References
          2. 7.7.2. Rvalue References
          3. 7.7.3. References to References
          4. 7.7.4. Pointers and References
        8. 7.8. Advice
      3. 8. Structures, Unions, and Enumerations
        1. 8.1. Introduction
        2. 8.2. Structures
          1. 8.2.1. struct Layout
          2. 8.2.2. struct Names
          3. 8.2.3. Structures and Classes
          4. 8.2.4. Structures and Arrays
          5. 8.2.5. Type Equivalence
          6. 8.2.6. Plain Old Data
          7. 8.2.7. Fields
        3. 8.3. Unions
          1. 8.3.1. Unions and Classes
          2. 8.3.2. Anonymous unions
        4. 8.4. Enumerations
          1. 8.4.1. enum classes
          2. 8.4.2. Plain enums
          3. 8.4.3. Unnamed enums
        5. 8.5. Advice
      4. 9. Statements
        1. 9.1. Introduction
        2. 9.2. Statement Summary
        3. 9.3. Declarations as Statements
        4. 9.4. Selection Statements
          1. 9.4.1. if Statements
          2. 9.4.2. switch Statements
          3. 9.4.3. Declarations in Conditions
        5. 9.5. Iteration Statements
          1. 9.5.1. Range-for Statements
          2. 9.5.2. for Statements
          3. 9.5.3. while Statements
          4. 9.5.4. do Statements
          5. 9.5.5. Loop Exit
        6. 9.6. goto Statements
        7. 9.7. Comments and Indentation
        8. 9.8. Advice
      5. 10. Expressions
        1. 10.1. Introduction
        2. 10.2. A Desk Calculator
          1. 10.2.1. The Parser
          2. 10.2.2. Input
          3. 10.2.3. Low-Level Input
          4. 10.2.4. Error Handling
          5. 10.2.5. The Driver
          6. 10.2.6. Headers
          7. 10.2.7. Command-Line Arguments
          8. 10.2.8. A Note on Style
        3. 10.3. Operator Summary
          1. 10.3.1. Results
          2. 10.3.2. Order of Evaluation
          3. 10.3.3. Operator Precedence
          4. 10.3.4. Temporary Objects
        4. 10.4. Constant Expressions
          1. 10.4.1. Symbolic Constants
          2. 10.4.2. consts in Constant Expressions
          3. 10.4.3. Literal Types
          4. 10.4.4. Reference Arguments
          5. 10.4.5. Address Constant Expressions
        5. 10.5. Implicit Type Conversion
          1. 10.5.1. Promotions
          2. 10.5.2. Conversions
          3. 10.5.3. Usual Arithmetic Conversions
        6. 10.6. Advice
      6. 11. Select Operations
        1. 11.1. Etc. Operators
          1. 11.1.1. Logical Operators
          2. 11.1.2. Bitwise Logical Operators
          3. 11.1.3. Conditional Expressions
          4. 11.1.4. Increment and Decrement
        2. 11.2. Free Store
          1. 11.2.1. Memory Management
          2. 11.2.2. Arrays
          3. 11.2.3. Getting Memory Space
          4. 11.2.4. Overloading new
        3. 11.3. Lists
          1. 11.3.1. Implementation Model
          2. 11.3.2. Qualified Lists
          3. 11.3.3. Unqualified Lists
        4. 11.4. Lambda Expressions
          1. 11.4.1. Implementation Model
          2. 11.4.2. Alternatives to Lambdas
          3. 11.4.3. Capture
          4. 11.4.4. Call and Return
          5. 11.4.5. The Type of a Lambda
        5. 11.5. Explicit Type Conversion
          1. 11.5.1. Construction
          2. 11.5.2. Named Casts
          3. 11.5.3. C-Style Cast
          4. 11.5.4. Function-Style Cast
        6. 11.6. Advice
      7. 12. Functions
        1. 12.1. Function Declarations
          1. 12.1.1. Why Functions?
          2. 12.1.2. Parts of a Function Declaration
          3. 12.1.3. Function Definitions
          4. 12.1.4. Returning Values
          5. 12.1.5. inline Functions
          6. 12.1.6. constexpr Functions
          7. 12.1.7. [[noreturn]] Functions
          8. 12.1.8. Local Variables
        2. 12.2. Argument Passing
          1. 12.2.1. Reference Arguments
          2. 12.2.2. Array Arguments
          3. 12.2.3. List Arguments
          4. 12.2.4. Unspecified Number of Arguments
          5. 12.2.5. Default Arguments
        3. 12.3. Overloaded Functions
          1. 12.3.1. Automatic Overload Resolution
          2. 12.3.2. Overloading and Return Type
          3. 12.3.3. Overloading and Scope
          4. 12.3.4. Resolution for Multiple Arguments
          5. 12.3.5. Manual Overload Resolution
        4. 12.4. Pre- and Postconditions
        5. 12.5. Pointer to Function
        6. 12.6. Macros
          1. 12.6.1. Conditional Compilation
          2. 12.6.2. Predefined Macros
          3. 12.6.3. Pragmas
        7. 12.7. Advice
      8. 13. Exception Handling
        1. 13.1. Error Handling
          1. 13.1.1. Exceptions
          2. 13.1.2. Traditional Error Handling
          3. 13.1.3. Muddling Through
          4. 13.1.4. Alternative Views of Exceptions
          5. 13.1.5. When You Can’t Use Exceptions
          6. 13.1.6. Hierarchical Error Handling
          7. 13.1.7. Exceptions and Efficiency
        2. 13.2. Exception Guarantees
        3. 13.3. Resource Management
          1. 13.3.1. Finally
        4. 13.4. Enforcing Invariants
        5. 13.5. Throwing and Catching Exceptions
          1. 13.5.1. Throwing Exceptions
          2. 13.5.2. Catching Exceptions
          3. 13.5.3. Exceptions and Threads
        6. 13.6. A vector Implementation
          1. 13.6.1. A Simple vector
          2. 13.6.2. Representing Memory Explicitly
          3. 13.6.3. Assignment
          4. 13.6.4. Changing Size
        7. 13.7. Advice
      9. 14. Namespaces
        1. 14.1. Composition Problems
        2. 14.2. Namespaces
          1. 14.2.1. Explicit Qualification
          2. 14.2.2. using-Declarations
          3. 14.2.3. using-Directives
          4. 14.2.4. Argument-Dependent Lookup
          5. 14.2.5. Namespaces Are Open
        3. 14.3. Modularization and Interfaces
          1. 14.3.1. Namespaces as Modules
          2. 14.3.2. Implementations
          3. 14.3.3. Interfaces and Implementations
        4. 14.4. Composition Using Namespaces
          1. 14.4.1. Convenience vs. Safety
          2. 14.4.2. Namespace Aliases
          3. 14.4.3. Namespace Composition
          4. 14.4.4. Composition and Selection
          5. 14.4.5. Namespaces and Overloading
          6. 14.4.6. Versioning
          7. 14.4.7. Nested Namespaces
          8. 14.4.8. Unnamed Namespaces
          9. 14.4.9. C Headers
        5. 14.5. Advice
      10. 15. Source Files and Programs
        1. 15.1. Separate Compilation
        2. 15.2. Linkage
          1. 15.2.1. File-Local Names
          2. 15.2.2. Header Files
          3. 15.2.3. The One-Definition Rule
          4. 15.2.4. Standard-Library Headers
          5. 15.2.5. Linkage to Non-C++ Code
          6. 15.2.6. Linkage and Pointers to Functions
        3. 15.3. Using Header Files
          1. 15.3.1. Single-Header Organization
          2. 15.3.2. Multiple-Header Organization
          3. 15.3.3. Include Guards
        4. 15.4. Programs
          1. 15.4.1. Initialization of Nonlocal Variables
          2. 15.4.2. Initialization and Concurrency
          3. 15.4.3. Program Termination
        5. 15.5. Advice
    11. Part III: Abstraction Mechanisms
      1. 16. Classes
        1. 16.1. Introduction
        2. 16.2. Class Basics
          1. 16.2.1. Member Functions
          2. 16.2.2. Default Copying
          3. 16.2.3. Access Control
          4. 16.2.4. class and struct
          5. 16.2.5. Constructors
          6. 16.2.6. explicit Constructors
          7. 16.2.7. In-Class Initializers
          8. 16.2.8. In-Class Function Definitions
          9. 16.2.9. Mutability
          10. 16.2.10. Self-Reference
          11. 16.2.11. Member Access
          12. 16.2.12. [static] Members
          13. 16.2.13. Member Types
        3. 16.3. Concrete Classes
          1. 16.3.1. Member Functions
          2. 16.3.2. Helper Functions
          3. 16.3.3. Overloaded Operators
          4. 16.3.4. The Significance of Concrete Classes
        4. 16.4. Advice
      2. 17. Construction, Cleanup, Copy, and Move
        1. 17.1. Introduction
        2. 17.2. Constructors and Destructors
          1. 17.2.1. Constructors and Invariants
          2. 17.2.2. Destructors and Resources
          3. 17.2.3. Base and Member Destructors
          4. 17.2.4. Calling Constructors and Destructors
          5. 17.2.5. virtual Destructors
        3. 17.3. Class Object Initialization
          1. 17.3.1. Initialization Without Constructors
          2. 17.3.2. Initialization Using Constructors
          3. 17.3.3. Default Constructors
          4. 17.3.4. Initializer-List Constructors
        4. 17.4. Member and Base Initialization
          1. 17.4.1. Member Initialization
          2. 17.4.2. Base Initializers
          3. 17.4.3. Delegating Constructors
          4. 17.4.4. In-Class Initializers
          5. 17.4.5. static Member Initialization
        5. 17.5. Copy and Move
          1. 17.5.1. Copy
          2. 17.5.2. Move
        6. 17.6. Generating Default Operations
          1. 17.6.1. Explicit Defaults
          2. 17.6.2. Default Operations
          3. 17.6.3. Using Default Operations
          4. 17.6.4. deleted Functions
        7. 17.7. Advice
      3. 18. Operator Overloading
        1. 18.1. Introduction
        2. 18.2. Operator Functions
          1. 18.2.1. Binary and Unary Operators
          2. 18.2.2. Predefined Meanings for Operators
          3. 18.2.3. Operators and User-Defined Types
          4. 18.2.4. Passing Objects
          5. 18.2.5. Operators in Namespaces
        3. 18.3. A Complex Number Type
          1. 18.3.1. Member and Nonmember Operators
          2. 18.3.2. Mixed-Mode Arithmetic
          3. 18.3.3. Conversions
          4. 18.3.4. Literals
          5. 18.3.5. Accessor Functions
          6. 18.3.6. Helper Functions
        4. 18.4. Type Conversion
          1. 18.4.1. Conversion Operators
          2. 18.4.2. explicit Conversion Operators
          3. 18.4.3. Ambiguities
        5. 18.5. Advice
      4. 19. Special Operators
        1. 19.1. Introduction
        2. 19.2. Special Operators
          1. 19.2.1. Subscripting
          2. 19.2.2. Function Call
          3. 19.2.3. Dereferencing
          4. 19.2.4. Increment and Decrement
          5. 19.2.5. Allocation and Deallocation
          6. 19.2.6. User-defined Literals
        3. 19.3. A String Class
          1. 19.3.1. Essential Operations
          2. 19.3.2. Access to Characters
          3. 19.3.3. Representation
          4. 19.3.4. Member Functions
          5. 19.3.5. Helper Functions
          6. 19.3.6. Using Our String
        4. 19.4. Friends
          1. 19.4.1. Finding Friends
          2. 19.4.2. Friends and Members
        5. 19.5. Advice
      5. 20. Derived Classes
        1. 20.1. Introduction
        2. 20.2. Derived Classes
          1. 20.2.1. Member Functions
          2. 20.2.2. Constructors and Destructors
        3. 20.3. Class Hierarchies
          1. 20.3.1. Type Fields
          2. 20.3.2. Virtual Functions
          3. 20.3.3. Explicit Qualification
          4. 20.3.4. Override Control
          5. 20.3.5. using Base Members
          6. 20.3.6. Return Type Relaxation
        4. 20.4. Abstract Classes
        5. 20.5. Access Control
          1. 20.5.1. protected Members
          2. 20.5.2. Access to Base Classes
          3. 20.5.3. using-Declarations and Access Control
        6. 20.6. Pointers to Members
          1. 20.6.1. Pointers to Function Members
          2. 20.6.2. Pointers to Data Members
          3. 20.6.3. Base and Derived Members
        7. 20.7. Advice
      6. 21. Class Hierarchies
        1. 21.1. Introduction
        2. 21.2. Design of Class Hierarchies
          1. 21.2.1. Implementation Inheritance
          2. 21.2.2. Interface Inheritance
          3. 21.2.3. Alternative Implementations
          4. 21.2.4. Localizing Object Creation
        3. 21.3. Multiple Inheritance
          1. 21.3.1. Multiple Interfaces
          2. 21.3.2. Multiple Implementation Classes
          3. 21.3.3. Ambiguity Resolution
          4. 21.3.4. Repeated Use of a Base Class
          5. 21.3.5. Virtual Base Classes
          6. 21.3.6. Replicated vs. Virtual Bases
        4. 21.4. Advice
      7. 22. Run-Time Type Information
        1. 22.1. Introduction
        2. 22.2. Class Hierarchy Navigation
          1. 22.2.1. dynamic_cast
          2. 22.2.2. Multiple Inheritance
          3. 22.2.3. static_cast and dynamic_cast
          4. 22.2.4. Recovering an Interface
        3. 22.3. Double Dispatch and Visitors
          1. 22.3.1. Double Dispatch
          2. 22.3.2. Visitors
        4. 22.4. Construction and Destruction
        5. 22.5. Type Identification
          1. 22.5.1. Extended Type Information
        6. 22.6. Uses and Misuses of RTTI
        7. 22.7. Advice
      8. 23. Templates
        1. 23.1. Introduction and Overview
        2. 23.2. A Simple String Template
          1. 23.2.1. Defining a Template
          2. 23.2.2. Template Instantiation
        3. 23.3. Type Checking
          1. 23.3.1. Type Equivalence
          2. 23.3.2. Error Detection
        4. 23.4. Class Template Members
          1. 23.4.1. Data Members
          2. 23.4.2. Member Functions
          3. 23.4.3. Member Type Aliases
          4. 23.4.4. static Members
          5. 23.4.5. Member Types
          6. 23.4.6. Member Templates
          7. 23.4.7. Friends
        5. 23.5. Function Templates
          1. 23.5.1. Function Template Arguments
          2. 23.5.2. Function Template Argument Deduction
          3. 23.5.3. Function Template Overloading
        6. 23.6. Template Aliases
        7. 23.7. Source Code Organization
          1. 23.7.1. Linkage
        8. 23.8. Advice
      9. 24. Generic Programming
        1. 24.1. Introduction
        2. 24.2. Algorithms and Lifting
        3. 24.3. Concepts
          1. 24.3.1. Discovering a Concept
          2. 24.3.2. Concepts and Constraints
        4. 24.4. Making Concepts Concrete
          1. 24.4.1. Axioms
          2. 24.4.2. Multi-argument Concepts
          3. 24.4.3. Value Concepts
          4. 24.4.4. Constraints Checks
          5. 24.4.5. Template Definition Checking
        5. 24.5. Advice
      10. 25. Specialization
        1. 25.1. Introduction
        2. 25.2. Template Parameters and Arguments
          1. 25.2.1. Types as Arguments
          2. 25.2.2. Values as Arguments
          3. 25.2.3. Operations as Arguments
          4. 25.2.4. Templates as Arguments
          5. 25.2.5. Default Template Arguments
        3. 25.3. Specialization
          1. 25.3.1. Interface Specialization
          2. 25.3.2. The Primary Template
          3. 25.3.3. Order of Specialization
          4. 25.3.4. Function Template Specialization
        4. 25.4. Advice
      11. 26. Instantiation
        1. 26.1. Introduction
        2. 26.2. Template Instantiation
          1. 26.2.1. When Is Instantiation Needed?
          2. 26.2.2. Manual Control of Instantiation
        3. 26.3. Name Binding
          1. 26.3.1. Dependent Names
          2. 26.3.2. Point-of-Definition Binding
          3. 26.3.3. Point-of-Instantiation Binding
          4. 26.3.4. Multiple Instantiation Points
          5. 26.3.5. Templates and Namespaces
          6. 26.3.6. Overaggressive ADL
          7. 26.3.7. Names from Base Classes
        4. 26.4. Advice
      12. 27. Templates and Hierarchies
        1. 27.1. Introduction
        2. 27.2. Parameterization and Hierarchy
          1. 27.2.1. Generated Types
          2. 27.2.2. Template Conversions
        3. 27.3. Hierarchies of Class Templates
          1. 27.3.1. Templates as Interfaces
        4. 27.4. Template Parameters as Base Classes
          1. 27.4.1. Composing Data Structures
          2. 27.4.2. Linearizing Class Hierarchies
        5. 27.5. Advice
      13. 28. Metaprogramming
        1. 28.1. Introduction
        2. 28.2. Type Functions
          1. 28.2.1. Type Aliases
          2. 28.2.2. Type Predicates
          3. 28.2.3. Selecting a Function
          4. 28.2.4. Traits
        3. 28.3. Control Structures
          1. 28.3.1. Selection
          2. 28.3.2. Iteration and Recursion
          3. 28.3.3. When to Use Metaprogramming
        4. 28.4. Conditional Definition: Enable_if
          1. 28.4.1. Use of Enable_if
          2. 28.4.2. Implementing Enable_if
          3. 28.4.3. Enable_if and Concepts
          4. 28.4.4. More Enable_if Examples
        5. 28.5. A Compile-Time List: Tuple
          1. 28.5.1. A Simple Output Function
          2. 28.5.2. Element Access
          3. 28.5.3. make_tuple
        6. 28.6. Variadic Templates
          1. 28.6.1. A Type-Safe printf()
          2. 28.6.2. Technical Details
          3. 28.6.3. Forwarding
          4. 28.6.4. The Standard-Library tuple
        7. 28.7. SI Units Example
          1. 28.7.1. Units
          2. 28.7.2. Quantitys
          3. 28.7.3. Unit Literals
          4. 28.7.4. Utility Functions
        8. 28.8. Advice
      14. 29. A Matrix Design
        1. 29.1. Introduction
          1. 29.1.1. Basic Matrix Uses
          2. 29.1.2. Matrix Requirements
        2. 29.2. A Matrix Template
          1. 29.2.1. Construction and Assignment
          2. 29.2.2. Subscripting and Slicing
        3. 29.3. Matrix Arithmetic Operations
          1. 29.3.1. Scalar Operations
          2. 29.3.2. Addition
          3. 29.3.3. Multiplication
        4. 29.4. Matrix Implementation
          1. 29.4.1. slice()
          2. 29.4.2. Matrix Slices
          3. 29.4.3. Matrix_ref
          4. 29.4.4. Matrix List Initialization
          5. 29.4.5. Matrix Access
          6. 29.4.6. Zero-Dimensional Matrix
        5. 29.5. Solving Linear Equations
          1. 29.5.1. Classical Gaussian Elimination
          2. 29.5.2. Pivoting
          3. 29.5.3. Testing
          4. 29.5.4. Fused Operations
        6. 29.6. Advice
    12. Part IV: The Standard Library
      1. 30. Standard-Library Overview
        1. 30.1. Introduction
          1. 30.1.1. Standard-Library Facilities
          2. 30.1.2. Design Constraints
          3. 30.1.3. Description Style
        2. 30.2. Headers
        3. 30.3. Language Support
          1. 30.3.1. initializer_list Support
          2. 30.3.2. Range-for Support
        4. 30.4. Error Handling
          1. 30.4.1. Exceptions
          2. 30.4.2. Assertions
          3. 30.4.3. system_error
        5. 30.5. Advice
      2. 31. STL Containers
        1. 31.1. Introduction
        2. 31.2. Container Overview
          1. 31.2.1. Container Representation
          2. 31.2.2. Element Requirements
        3. 31.3. Operations Overview
          1. 31.3.1. Member Types
          2. 31.3.2. Constructors, Destructor, and Assignments
          3. 31.3.3. Size and Capacity
          4. 31.3.4. Iterators
          5. 31.3.5. Element Access
          6. 31.3.6. Stack Operations
          7. 31.3.7. List Operations
          8. 31.3.8. Other Operations
        4. 31.4. Containers
          1. 31.4.1. vector
          2. 31.4.2. Lists
          3. 31.4.3. Associative Containers
        5. 31.5. Container Adaptors
          1. 31.5.1. stack
          2. 31.5.2. queue
          3. 31.5.3. priority_queue
        6. 31.6. Advice
      3. 32. STL Algorithms
        1. 32.1. Introduction
        2. 32.2. Algorithms
          1. 32.2.1. Sequences
        3. 32.3. Policy Arguments
          1. 32.3.1. Complexity
        4. 32.4. Nonmodifying Sequence Algorithms
          1. 32.4.1. for_each()
          2. 32.4.2. Sequence Predicates
          3. 32.4.3. count()
          4. 32.4.4. find()
          5. 32.4.5. equal() and mismatch()
          6. 32.4.6. search()
        5. 32.5. Modifying Sequence Algorithms
          1. 32.5.1. copy()
          2. 32.5.2. unique()
          3. 32.5.3. remove() and replace()
          4. 32.5.4. rotate(), random_shuffle(), and partition()
          5. 32.5.5. Permutations
          6. 32.5.6. fill()
          7. 32.5.7. swap()
        6. 32.6. Sorting and Searching
          1. 32.6.1. Binary Search
          2. 32.6.2. merge()
          3. 32.6.3. Set Algorithms
          4. 32.6.4. Heaps
          5. 32.6.5. lexicographical_compare()
        7. 32.7. Min and Max
        8. 32.8. Advice
      4. 33. STL Iterators
        1. 33.1. Introduction
          1. 33.1.1. Iterator Model
          2. 33.1.2. Iterator Categories
          3. 33.1.3. Iterator Traits
          4. 33.1.4. Iterator Operations
        2. 33.2. Iterator Adaptors
          1. 33.2.1. Reverse Iterator
          2. 33.2.2. Insert Iterators
          3. 33.2.3. Move Iterator
        3. 33.3. Range Access Functions
        4. 33.4. Function Objects
        5. 33.5. Function Adaptors
          1. 33.5.1. bind()
          2. 33.5.2. mem_fn()
          3. 33.5.3. function
        6. 33.6. Advice
      5. 34. Memory and Resources
        1. 34.1. Introduction
        2. 34.2. “Almost Containers”
          1. 34.2.1. array
          2. 34.2.2. bitset
          3. 34.2.3. vector<bool>
          4. 34.2.4. Tuples
        3. 34.3. Resource Management Pointers
          1. 34.3.1. unique_ptr
          2. 34.3.2. shared_ptr
          3. 34.3.3. weak_ptr
        4. 34.4. Allocators
          1. 34.4.1. The Default Allocator
          2. 34.4.2. Allocator Traits
          3. 34.4.3. Pointer Traits
          4. 34.4.4. Scoped Allocators
        5. 34.5. The Garbage Collection Interface
        6. 34.6. Uninitialized Memory
          1. 34.6.1. Temporary Buffers
          2. 34.6.2. raw_storage_iterator
        7. 34.7. Advice
      6. 35. Utilities
        1. 35.1. Introduction
        2. 35.2. Time
          1. 35.2.1. duration
          2. 35.2.2. time_point
          3. 35.2.3. Clocks
          4. 35.2.4. Time Traits
        3. 35.3. Compile-Time Rational Arithmetic
        4. 35.4. Type Functions
          1. 35.4.1. Type Traits
          2. 35.4.2. Type Generators
        5. 35.5. Minor Utilities
          1. 35.5.1. move() and forward()
          2. 35.5.2. swap()
          3. 35.5.3. Relational Operators
          4. 35.5.4. Comparing and Hashing type_info
        6. 35.6. Advice
      7. 36. Strings
        1. 36.1. Introduction
        2. 36.2. Character Classification
          1. 36.2.1. Classification Functions
          2. 36.2.2. Character Traits
        3. 36.3. Strings
          1. 36.3.1. string vs. C-Style Strings
          2. 36.3.2. Constructors
          3. 36.3.3. Fundamental Operations
          4. 36.3.4. String I/O
          5. 36.3.5. Numeric Conversions
          6. 36.3.6. STL-like Operations
          7. 36.3.7. The find Family
          8. 36.3.8. Substrings
        4. 36.4. Advice
      8. 37. Regular Expressions
        1. 37.1. Regular Expressions
          1. 37.1.1. Regular Expression Notation
        2. 37.2. regex
          1. 37.2.1. Match Results
          2. 37.2.2. Formatting
        3. 37.3. Regular Expression Functions
          1. 37.3.1. regex_match()
          2. 37.3.2. regex_search()
          3. 37.3.3. regex_replace()
        4. 37.4. Regular Expression Iterators
          1. 37.4.1. regex_iterator
          2. 37.4.2. regex_token_iterator
        5. 37.5. regex_traits
        6. 37.6. Advice
      9. 38. I/O Streams
        1. 38.1. Introduction
        2. 38.2. The I/O Stream Hierarchy
          1. 38.2.1. File Streams
          2. 38.2.2. String Streams
        3. 38.3. Error Handling
        4. 38.4. I/O Operations
          1. 38.4.1. Input Operations
          2. 38.4.2. Output Operations
          3. 38.4.3. Manipulators
          4. 38.4.4. Stream State
          5. 38.4.5. Formatting
        5. 38.5. Stream Iterators
        6. 38.6. Buffering
          1. 38.6.1. Output Streams and Buffers
          2. 38.6.2. Input Streams and Buffers
          3. 38.6.3. Buffer Iterators
        7. 38.7. Advice
      10. 39. Locales
        1. 39.1. Handling Cultural Differences
        2. 39.2. Class locale
          1. 39.2.1. Named locales
          2. 39.2.2. Comparing strings
        3. 39.3. Class facet
          1. 39.3.1. Accessing facets in a locale
          2. 39.3.2. A Simple User-Defined facet
          3. 39.3.3. Uses of locales and facets
        4. 39.4. Standard facets
          1. 39.4.1. string Comparison
          2. 39.4.2. Numeric Formatting
          3. 39.4.3. Money Formatting
          4. 39.4.4. Date and Time Formatting
          5. 39.4.5. Character Classification
          6. 39.4.6. Character Code Conversion
          7. 39.4.7. Messages
        5. 39.5. Convenience Interfaces
          1. 39.5.1. Character Classification
          2. 39.5.2. Character Conversions
          3. 39.5.3. String Conversions
          4. 39.5.4. Buffer Conversions
        6. 39.6. Advice
      11. 40. Numerics
        1. 40.1. Introduction
        2. 40.2. Numerical Limits
          1. 40.2.1. Limit Macros
        3. 40.3. Standard Mathematical Functions
        4. 40.4. complex Numbers
        5. 40.5. A Numerical Array: valarray
          1. 40.5.1. Constructors and Assignments
          2. 40.5.2. Subscripting
          3. 40.5.3. Operations
          4. 40.5.4. Slices
          5. 40.5.5. slice_array
          6. 40.5.6. Generalized Slices
        6. 40.6. Generalized Numerical Algorithms
          1. 40.6.1. accumulate()
          2. 40.6.2. inner_product()
          3. 40.6.3. partial_sum() and adjacent_difference()
          4. 40.6.4. iota()
        7. 40.7. Random Numbers
          1. 40.7.1. Engines
          2. 40.7.2. Random Device
          3. 40.7.3. Distributions
          4. 40.7.4. C-Style Random Numbers
        8. 40.8. Advice
      12. 41. Concurrency
        1. 41.1. Introduction
        2. 41.2. Memory Model
          1. 41.2.1. Memory Location
          2. 41.2.2. Instruction Reordering
          3. 41.2.3. Memory Order
          4. 41.2.4. Data Races
        3. 41.3. Atomics
          1. 41.3.1. atomic Types
          2. 41.3.2. Flags and Fences
        4. 41.4. volatile
        5. 41.5. Advice
      13. 42. Threads and Tasks
        1. 42.1. Introduction
        2. 42.2. Threads
          1. 42.2.1. Identity
          2. 42.2.2. Construction
          3. 42.2.3. Destruction
          4. 42.2.4. join()
          5. 42.2.5. detach()
          6. 42.2.6. Namespace this_thread
          7. 42.2.7. Killing a thread
          8. 42.2.8. thread_local Data
        3. 42.3. Avoiding Data Races
          1. 42.3.1. Mutexes
          2. 42.3.2. Multiple Locks
          3. 42.3.3. call_once()
          4. 42.3.4. Condition Variables
        4. 42.4. Task-Based Concurrency
          1. 42.4.1. future and promise
          2. 42.4.2. promise
          3. 42.4.3. packaged_task
          4. 42.4.4. future
          5. 42.4.5. shared_future
          6. 42.4.6. async()
          7. 42.4.7. A Parallel find() Example
        5. 42.5. Advice
      14. 43. The C Standard Library
        1. 43.1. Introduction
        2. 43.2. Files
        3. 43.3. The printf() Family
        4. 43.4. C-Style Strings
        5. 43.5. Memory
        6. 43.6. Date and Time
        7. 43.7. Etc.
        8. 43.8. Advice
      15. 44. Compatibility
        1. 44.1. Introduction
        2. 44.2. C++11 Extensions
          1. 44.2.1. Language Features
          2. 44.2.2. Standard_Library Components
          3. 44.2.3. Deprecated Features
          4. 44.2.4. Coping with Older C++ Implementations
        3. 44.3. C/C++ Compatibility
          1. 44.3.1. C and C++ Are Siblings
          2. 44.3.2. “Silent” Differences
          3. 44.3.3. C Code That Is Not C++
          4. 44.3.4. C++ Code That Is Not C
        4. 44.4. Advice
    13. Preparation for Programming in the Real World
    14. Index