The C Standard Library 2nd Edition Nicolai M.
Josuttis download pdf
https://ebookultra.com/download/the-c-standard-library-2nd-edition-
nicolai-m-josuttis/
Visit ebookultra.com today to download the complete set of
ebook or textbook!
We believe these products will be a great fit for you. Click
the link to download now, or visit ebookultra.com
to discover even more!
Python Standard Library Fredrik Lundh
https://ebookultra.com/download/python-standard-library-fredrik-lundh/
The Python Standard Library by Example 1st Edition
Hellmann
https://ebookultra.com/download/the-python-standard-library-by-
example-1st-edition-hellmann/
STL Tutorial and Reference Guide C Programming With the
Standard Template Library 2 (Draft) Edition David R.
Musser
https://ebookultra.com/download/stl-tutorial-and-reference-guide-c-
programming-with-the-standard-template-library-2-draft-edition-david-
r-musser/
The Standard ML Basis Library 1st Edition Emden R. Gansner
https://ebookultra.com/download/the-standard-ml-basis-library-1st-
edition-emden-r-gansner/
Core JSTL Mastering the JSP Standard Tag Library 1st
Edition Geary
https://ebookultra.com/download/core-jstl-mastering-the-jsp-standard-
tag-library-1st-edition-geary/
Lessons Learned A Guide to Improved Aircraft Design 1st
Edition Leland M. Nicolai
https://ebookultra.com/download/lessons-learned-a-guide-to-improved-
aircraft-design-1st-edition-leland-m-nicolai/
Standard handbook of petroleum natural gas engineering 2nd
ed Edition William C Lyons
https://ebookultra.com/download/standard-handbook-of-petroleum-
natural-gas-engineering-2nd-ed-edition-william-c-lyons/
Learning OpenCV 2nd Edition Computer Vision in C with the
OpenCV Library Adrian Kaehler
https://ebookultra.com/download/learning-opencv-2nd-edition-computer-
vision-in-c-with-the-opencv-library-adrian-kaehler/
Data Structures Using C C 2nd Edition Edition Aaron M.
Tenebaum
https://ebookultra.com/download/data-structures-using-c-c-2nd-edition-
edition-aaron-m-tenebaum/
The C Standard Library 2nd Edition Nicolai M. Josuttis
Digital Instant Download
Author(s): Nicolai M. Josuttis
ISBN(s): 9780321623218, 0321623215
Edition: 2nd
File Details: PDF, 4.50 MB
Year: 2012
Language: english
The C++ Standard Library
A Tutorial and Reference
Second Edition
Nicolai M. Josuttis
Visit us on the Web: informit.com/aw
Library of Congress Cataloging-in-Publication Data
Josuttis, Nicolai M.
The C++ standard library : a tutorial and reference / Nicolai M. Josuttis.—2nd ed.
p. cm.
Includes bibliographical references and index.
ISBN 978-0-321-62321-8 (hardcover : alk. paper)
1. C++ (Computer program language) I. Title.
QA76.73.C153J69 2012
005.13’3-dc23
2011045071
c 2012 Pearson Education, Inc.
Copyright
ISBN-13: 978-0-321-62321-8
ISBN-10: 0-321-62321-5
Text printed in the United States
First printing, March 2012
Contents
Preface to the Second Edition xxiii
Preface to the First Edition xxv
1 About This Book 1
1.1 Why This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Before Reading This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 Style and Structure of the Book . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 How to Read This Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.5 State of the Art . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
1.6 Example Code and Additional Information . . . . . . . . . . . . . . . . . . . . . 5
1.7 Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2 Introduction to C++ and the Standard Library 7
2.1 History of the C++ Standards . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.1.1 Common Questions about the C++11 Standard . . . . . . . . . . . . . . 8
2.1.2 Compatibility between C++98 and C++11 . . . . . . . . . . . . . . . . . 9
2.2 Complexity and Big-O Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3 New Language Features 13
3.1 New C++11 Language Features . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.1.1 Important Minor Syntax Cleanups . . . . . . . . . . . . . . . . . . . . . 13
3.1.2 Automatic Type Deduction with auto . . . . . . . . . . . . . . . . . . . 14
3.1.3 Uniform Initialization and Initializer Lists . . . . . . . . . . . . . . . . . 15
3.1.4 Range-Based for Loops . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.1.5 Move Semantics and Rvalue References . . . . . . . . . . . . . . . . . . 19
3.1.6 New String Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
3.1.7 Keyword noexcept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.1.8 Keyword constexpr . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.1.9 New Template Features . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.1.10 Lambdas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3.1.11 Keyword decltype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.1.12 New Function Declaration Syntax . . . . . . . . . . . . . . . . . . . . . 32
3.1.13 Scoped Enumerations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
3.1.14 New Fundamental Data Types . . . . . . . . . . . . . . . . . . . . . . . 33
3.2 Old “New” Language Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
3.2.1 Explicit Initialization for Fundamental Types . . . . . . . . . . . . . . . 37
3.2.2 Definition of main() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
4 General Concepts 39
4.1 Namespace std . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
4.2 Header Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.3 Error and Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.3.1 Standard Exception Classes . . . . . . . . . . . . . . . . . . . . . . . . . 41
4.3.2 Members of Exception Classes . . . . . . . . . . . . . . . . . . . . . . . 44
4.3.3 Passing Exceptions with Class exception_ptr . . . . . . . . . . . . . . 52
4.3.4 Throwing Standard Exceptions . . . . . . . . . . . . . . . . . . . . . . . 53
4.3.5 Deriving from Standard Exception Classes . . . . . . . . . . . . . . . . . 54
4.4 Callable Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
4.5 Concurrency and Multithreading . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
4.6 Allocators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
5 Utilities 59
5.1 Pairs and Tuples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.1.1 Pairs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
5.1.2 Tuples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
5.1.3 I/O for Tuples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
5.1.4 Conversions between tuples and pairs . . . . . . . . . . . . . . . . . . 75
5.2 Smart Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
5.2.1 Class shared_ptr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
5.2.2 Class weak_ptr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84
5.2.3 Misusing Shared Pointers . . . . . . . . . . . . . . . . . . . . . . . . . . 89
5.2.4 Shared and Weak Pointers in Detail . . . . . . . . . . . . . . . . . . . . . 92
5.2.5 Class unique_ptr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
5.2.6 Class unique_ptr in Detail . . . . . . . . . . . . . . . . . . . . . . . . 110
5.2.7 Class auto_ptr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113
5.2.8 Final Words on Smart Pointers . . . . . . . . . . . . . . . . . . . . . . . 114
5.3 Numeric Limits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
5.4 Type Traits and Type Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
5.4.1 Purpose of Type Traits . . . . . . . . . . . . . . . . . . . . . . . . . . . 122
5.4.2 Type Traits in Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125
5.4.3 Reference Wrappers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132
5.4.4 Function Type Wrappers . . . . . . . . . . . . . . . . . . . . . . . . . . 133
5.5 Auxiliary Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134
5.5.1 Processing the Minimum and Maximum . . . . . . . . . . . . . . . . . . 134
5.5.2 Swapping Two Values . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
5.5.3 Supplementary Comparison Operators . . . . . . . . . . . . . . . . . . . 138
5.6 Compile-Time Fractional Arithmetic with Class ratio<> . . . . . . . . . . . . . 140
5.7 Clocks and Timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143
5.7.1 Overview of the Chrono Library . . . . . . . . . . . . . . . . . . . . . . 143
5.7.2 Durations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144
5.7.3 Clocks and Timepoints . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
5.7.4 Date and Time Functions by C and POSIX . . . . . . . . . . . . . . . . . 157
5.7.5 Blocking with Timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160
5.8 Header Files <cstddef>, <cstdlib>, and <cstring> . . . . . . . . . . . . . . 161
5.8.1 Definitions in <cstddef> . . . . . . . . . . . . . . . . . . . . . . . . . . 161
5.8.2 Definitions in <cstdlib> . . . . . . . . . . . . . . . . . . . . . . . . . . 162
5.8.3 Definitions in <cstring> . . . . . . . . . . . . . . . . . . . . . . . . . . 163
6 The Standard Template Library 165
6.1 STL Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165
6.2 Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
6.2.1 Sequence Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169
6.2.2 Associative Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
6.2.3 Unordered Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
6.2.4 Associative Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
6.2.5 Other Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187
6.2.6 Container Adapters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
6.3 Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
6.3.1 Further Examples of Using Associative and Unordered Containers . . . . 193
6.3.2 Iterator Categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198
6.4 Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
6.4.1 Ranges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
6.4.2 Handling Multiple Ranges . . . . . . . . . . . . . . . . . . . . . . . . . 207
6.5 Iterator Adapters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
6.5.1 Insert Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 210
6.5.2 Stream Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212
6.5.3 Reverse Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
6.5.4 Move Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
6.6 User-Defined Generic Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 216
6.7 Manipulating Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217
6.7.1 “Removing” Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
6.7.2 Manipulating Associative and Unordered Containers . . . . . . . . . . . 221
6.7.3 Algorithms versus Member Functions . . . . . . . . . . . . . . . . . . . 223
6.8 Functions as Algorithm Arguments . . . . . . . . . . . . . . . . . . . . . . . . . 224
6.8.1 Using Functions as Algorithm Arguments . . . . . . . . . . . . . . . . . 224
6.8.2 Predicates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 226
6.9 Using Lambdas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
6.10 Function Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233
6.10.1 Definition of Function Objects . . . . . . . . . . . . . . . . . . . . . . . 233
6.10.2 Predefined Function Objects . . . . . . . . . . . . . . . . . . . . . . . . 239
6.10.3 Binders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
6.10.4 Function Objects and Binders versus Lambdas . . . . . . . . . . . . . . . 243
6.11 Container Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 244
6.11.1 Requirements for Container Elements . . . . . . . . . . . . . . . . . . . 244
6.11.2 Value Semantics or Reference Semantics . . . . . . . . . . . . . . . . . . 245
6.12 Errors and Exceptions inside the STL . . . . . . . . . . . . . . . . . . . . . . . . 245
6.12.1 Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 246
6.12.2 Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 248
6.13 Extending the STL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250
6.13.1 Integrating Additional Types . . . . . . . . . . . . . . . . . . . . . . . . 250
6.13.2 Deriving from STL Types . . . . . . . . . . . . . . . . . . . . . . . . . . 251
7 STL Containers 253
7.1 Common Container Abilities and Operations . . . . . . . . . . . . . . . . . . . . 254
7.1.1 Container Abilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
7.1.2 Container Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
7.1.3 Container Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 260
7.2 Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
7.2.1 Abilities of Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 261
7.2.2 Array Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263
7.2.3 Using arrays as C-Style Arrays . . . . . . . . . . . . . . . . . . . . . . 267
7.2.4 Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
7.2.5 Tuple Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 268
7.2.6 Examples of Using Arrays . . . . . . . . . . . . . . . . . . . . . . . . . 268
7.3 Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
7.3.1 Abilities of Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270
7.3.2 Vector Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273
7.3.3 Using Vectors as C-Style Arrays . . . . . . . . . . . . . . . . . . . . . . 278
7.3.4 Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 278
7.3.5 Examples of Using Vectors . . . . . . . . . . . . . . . . . . . . . . . . . 279
7.3.6 Class vector<bool> . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281
7.4 Deques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283
7.4.1 Abilities of Deques . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284
7.4.2 Deque Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285
7.4.3 Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 288
7.4.4 Examples of Using Deques . . . . . . . . . . . . . . . . . . . . . . . . . 288
7.5 Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
7.5.1 Abilities of Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 290
7.5.2 List Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291
7.5.3 Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 296
7.5.4 Examples of Using Lists . . . . . . . . . . . . . . . . . . . . . . . . . . 298
7.6 Forward Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 300
7.6.1 Abilities of Forward Lists . . . . . . . . . . . . . . . . . . . . . . . . . . 300
7.6.2 Forward List Operations . . . . . . . . . . . . . . . . . . . . . . . . . . 302
7.6.3 Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 311
7.6.4 Examples of Using Forward Lists . . . . . . . . . . . . . . . . . . . . . . 312
7.7 Sets and Multisets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 314
7.7.1 Abilities of Sets and Multisets . . . . . . . . . . . . . . . . . . . . . . . 315
7.7.2 Set and Multiset Operations . . . . . . . . . . . . . . . . . . . . . . . . . 316
7.7.3 Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325
7.7.4 Examples of Using Sets and Multisets . . . . . . . . . . . . . . . . . . . 325
7.7.5 Example of Specifying the Sorting Criterion at Runtime . . . . . . . . . . 328
7.8 Maps and Multimaps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 331
7.8.1 Abilities of Maps and Multimaps . . . . . . . . . . . . . . . . . . . . . . 332
7.8.2 Map and Multimap Operations . . . . . . . . . . . . . . . . . . . . . . . 333
7.8.3 Using Maps as Associative Arrays . . . . . . . . . . . . . . . . . . . . . 343
7.8.4 Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345
7.8.5 Examples of Using Maps and Multimaps . . . . . . . . . . . . . . . . . . 345
7.8.6 Example with Maps, Strings, and Sorting Criterion at Runtime . . . . . . 351
7.9 Unordered Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 355
7.9.1 Abilities of Unordered Containers . . . . . . . . . . . . . . . . . . . . . 357
7.9.2 Creating and Controlling Unordered Containers . . . . . . . . . . . . . . 359
7.9.3 Other Operations for Unordered Containers . . . . . . . . . . . . . . . . 367
7.9.4 The Bucket Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . 374
7.9.5 Using Unordered Maps as Associative Arrays . . . . . . . . . . . . . . . 374
7.9.6 Exception Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375
7.9.7 Examples of Using Unordered Containers . . . . . . . . . . . . . . . . . 375
7.10 Other STL Containers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385
7.10.1 Strings as STL Containers . . . . . . . . . . . . . . . . . . . . . . . . . 385
7.10.2 Ordinary C-Style Arrays as STL Containers . . . . . . . . . . . . . . . . 386
7.11 Implementing Reference Semantics . . . . . . . . . . . . . . . . . . . . . . . . . 388
7.12 When to Use Which Container . . . . . . . . . . . . . . . . . . . . . . . . . . . . 392
8 STL Container Members in Detail 397
8.1 Type Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 397
8.2 Create, Copy, and Destroy Operations . . . . . . . . . . . . . . . . . . . . . . . . 400
8.3 Nonmodifying Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
8.3.1 Size Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403
8.3.2 Comparison Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . 404
8.3.3 Nonmodifying Operations for Associative and Unordered Containers . . . 404
8.4 Assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 406
8.5 Direct Element Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 408
8.6 Operations to Generate Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . 410
8.7 Inserting and Removing Elements . . . . . . . . . . . . . . . . . . . . . . . . . . 411
8.7.1 Inserting Single Elements . . . . . . . . . . . . . . . . . . . . . . . . . . 411
8.7.2 Inserting Multiple Elements . . . . . . . . . . . . . . . . . . . . . . . . . 416
8.7.3 Removing Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
8.7.4 Resizing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420
8.8 Special Member Functions for Lists and Forward Lists . . . . . . . . . . . . . . . 420
8.8.1 Special Member Functions for Lists (and Forward Lists) . . . . . . . . . 420
8.8.2 Special Member Functions for Forward Lists Only . . . . . . . . . . . . 423
8.9 Container Policy Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 427
8.9.1 Nonmodifying Policy Functions . . . . . . . . . . . . . . . . . . . . . . 427
8.9.2 Modifying Policy Functions . . . . . . . . . . . . . . . . . . . . . . . . 428
8.9.3 Bucket Interface for Unordered Containers . . . . . . . . . . . . . . . . . 429
8.10 Allocator Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 430
8.10.1 Fundamental Allocator Members . . . . . . . . . . . . . . . . . . . . . . 430
8.10.2 Constructors with Optional Allocator Parameters . . . . . . . . . . . . . 430
9 STL Iterators 433
9.1 Header Files for Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
9.2 Iterator Categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
9.2.1 Output Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433
9.2.2 Input Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 435
9.2.3 Forward Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436
9.2.4 Bidirectional Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . 437
9.2.5 Random-Access Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . 438
9.2.6 The Increment and Decrement Problem of Vector Iterators . . . . . . . . 440
9.3 Auxiliary Iterator Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
9.3.1 advance() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 441
9.3.2 next() and prev() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 443
9.3.3 distance() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445
9.3.4 iter_swap() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446
9.4 Iterator Adapters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448
9.4.1 Reverse Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448
9.4.2 Insert Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454
9.4.3 Stream Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 460
9.4.4 Move Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466
9.5 Iterator Traits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 466
9.5.1 Writing Generic Functions for Iterators . . . . . . . . . . . . . . . . . . . 468
9.6 Writing User-Defined Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . 471
10 STL Function Objects and Using Lambdas 475
10.1 The Concept of Function Objects . . . . . . . . . . . . . . . . . . . . . . . . . . 475
10.1.1 Function Objects as Sorting Criteria . . . . . . . . . . . . . . . . . . . . 476
10.1.2 Function Objects with Internal State . . . . . . . . . . . . . . . . . . . . 478
10.1.3 The Return Value of for_each() . . . . . . . . . . . . . . . . . . . . . 482
10.1.4 Predicates versus Function Objects . . . . . . . . . . . . . . . . . . . . . 483
10.2 Predefined Function Objects and Binders . . . . . . . . . . . . . . . . . . . . . . 486
10.2.1 Predefined Function Objects . . . . . . . . . . . . . . . . . . . . . . . . 486
10.2.2 Function Adapters and Binders . . . . . . . . . . . . . . . . . . . . . . . 487
10.2.3 User-Defined Function Objects for Function Adapters . . . . . . . . . . . 495
10.2.4 Deprecated Function Adapters . . . . . . . . . . . . . . . . . . . . . . . 497
10.3 Using Lambdas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 499
10.3.1 Lambdas versus Binders . . . . . . . . . . . . . . . . . . . . . . . . . . 499
10.3.2 Lambdas versus Stateful Function Objects . . . . . . . . . . . . . . . . . 500
10.3.3 Lambdas Calling Global and Member Functions . . . . . . . . . . . . . . 502
10.3.4 Lambdas as Hash Function, Sorting, or Equivalence Criterion . . . . . . . 504
11 STL Algorithms 505
11.1 Algorithm Header Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505
11.2 Algorithm Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505
11.2.1 A Brief Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 506
11.2.2 Classification of Algorithms . . . . . . . . . . . . . . . . . . . . . . . . 506
11.3 Auxiliary Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517
11.4 The for_each() Algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 519
11.5 Nonmodifying Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524
11.5.1 Counting Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 524
11.5.2 Minimum and Maximum . . . . . . . . . . . . . . . . . . . . . . . . . . 525
11.5.3 Searching Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 528
11.5.4 Comparing Ranges . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 542
11.5.5 Predicates for Ranges . . . . . . . . . . . . . . . . . . . . . . . . . . . . 550
11.6 Modifying Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557
11.6.1 Copying Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 557
11.6.2 Moving Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561
11.6.3 Transforming and Combining Elements . . . . . . . . . . . . . . . . . . 563
11.6.4 Swapping Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 566
11.6.5 Assigning New Values . . . . . . . . . . . . . . . . . . . . . . . . . . . 568
11.6.6 Replacing Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 571
11.7 Removing Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 575
11.7.1 Removing Certain Values . . . . . . . . . . . . . . . . . . . . . . . . . . 575
11.7.2 Removing Duplicates . . . . . . . . . . . . . . . . . . . . . . . . . . . . 578
11.8 Mutating Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 583
11.8.1 Reversing the Order of Elements . . . . . . . . . . . . . . . . . . . . . . 583
11.8.2 Rotating Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 584
11.8.3 Permuting Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587
11.8.4 Shuffling Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 589
11.8.5 Moving Elements to the Front . . . . . . . . . . . . . . . . . . . . . . . 592
11.8.6 Partition into Two Subranges . . . . . . . . . . . . . . . . . . . . . . . . 594
11.9 Sorting Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596
11.9.1 Sorting All Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 596
11.9.2 Partial Sorting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 599
11.9.3 Sorting According to the nth Element . . . . . . . . . . . . . . . . . . . 602
11.9.4 Heap Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 604
11.10 Sorted-Range Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 608
11.10.1 Searching Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 608
11.10.2 Merging Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 614
11.11 Numeric Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 623
11.11.1 Processing Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 623
11.11.2 Converting Relative and Absolute Values . . . . . . . . . . . . . . . . . . 627
12 Special Containers 631
12.1 Stacks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 632
12.1.1 The Core Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633
12.1.2 Example of Using Stacks . . . . . . . . . . . . . . . . . . . . . . . . . . 633
12.1.3 A User-Defined Stack Class . . . . . . . . . . . . . . . . . . . . . . . . . 635
12.1.4 Class stack<> in Detail . . . . . . . . . . . . . . . . . . . . . . . . . . 637
12.2 Queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 638
12.2.1 The Core Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 639
12.2.2 Example of Using Queues . . . . . . . . . . . . . . . . . . . . . . . . . 640
12.2.3 A User-Defined Queue Class . . . . . . . . . . . . . . . . . . . . . . . . 641
12.2.4 Class queue<> in Detail . . . . . . . . . . . . . . . . . . . . . . . . . . 641
12.3 Priority Queues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 641
12.3.1 The Core Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643
12.3.2 Example of Using Priority Queues . . . . . . . . . . . . . . . . . . . . . 643
12.3.3 Class priority_queue<> in Detail . . . . . . . . . . . . . . . . . . . . 644
12.4 Container Adapters in Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645
12.4.1 Type Definitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 645
12.4.2 Constructors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 646
12.4.3 Supplementary Constructors for Priority Queues . . . . . . . . . . . . . . 646
12.4.4 Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 647
12.5 Bitsets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 650
12.5.1 Examples of Using Bitsets . . . . . . . . . . . . . . . . . . . . . . . . . 651
12.5.2 Class bitset in Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . 653
13 Strings 655
13.1 Purpose of the String Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 656
13.1.1 A First Example: Extracting a Temporary Filename . . . . . . . . . . . . 656
13.1.2 A Second Example: Extracting Words and Printing Them Backward . . . 660
13.2 Description of the String Classes . . . . . . . . . . . . . . . . . . . . . . . . . . 663
13.2.1 String Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 663
13.2.2 Operation Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 666
13.2.3 Constructors and Destructor . . . . . . . . . . . . . . . . . . . . . . . . 667
13.2.4 Strings and C-Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 668
13.2.5 Size and Capacity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 669
13.2.6 Element Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 671
13.2.7 Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 672
13.2.8 Modifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 673
13.2.9 Substrings and String Concatenation . . . . . . . . . . . . . . . . . . . . 676
13.2.10 Input/Output Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . 677
13.2.11 Searching and Finding . . . . . . . . . . . . . . . . . . . . . . . . . . . 678
13.2.12 The Value npos . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 680
13.2.13 Numeric Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 681
13.2.14 Iterator Support for Strings . . . . . . . . . . . . . . . . . . . . . . . . . 684
13.2.15 Internationalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 689
13.2.16 Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 692
13.2.17 Strings and Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 692
13.3 String Class in Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 693
13.3.1 Type Definitions and Static Values . . . . . . . . . . . . . . . . . . . . . 693
13.3.2 Create, Copy, and Destroy Operations . . . . . . . . . . . . . . . . . . . 694
13.3.3 Operations for Size and Capacity . . . . . . . . . . . . . . . . . . . . . . 696
13.3.4 Comparisons . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 697
13.3.5 Character Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 699
13.3.6 Generating C-Strings and Character Arrays . . . . . . . . . . . . . . . . 700
13.3.7 Modifying Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 700
13.3.8 Searching and Finding . . . . . . . . . . . . . . . . . . . . . . . . . . . 708
13.3.9 Substrings and String Concatenation . . . . . . . . . . . . . . . . . . . . 711
13.3.10 Input/Output Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 712
13.3.11 Numeric Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 713
13.3.12 Generating Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 714
13.3.13 Allocator Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 715
14 Regular Expressions 717
14.1 The Regex Match and Search Interface . . . . . . . . . . . . . . . . . . . . . . . 717
14.2 Dealing with Subexpressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . 720
14.3 Regex Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 726
14.4 Regex Token Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 727
14.5 Replacing Regular Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . 730
14.6 Regex Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 732
14.7 Regex Exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 735
14.8 The Regex ECMAScript Grammar . . . . . . . . . . . . . . . . . . . . . . . . . 738
14.9 Other Grammars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 739
14.10 Basic Regex Signatures in Detail . . . . . . . . . . . . . . . . . . . . . . . . . . 740
15 Input/Output Using Stream Classes 743
15.1 Common Background of I/O Streams . . . . . . . . . . . . . . . . . . . . . . . . 744
15.1.1 Stream Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 744
15.1.2 Stream Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 744
15.1.3 Global Stream Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 745
15.1.4 Stream Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745
15.1.5 Manipulators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 746
15.1.6 A Simple Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 746
15.2 Fundamental Stream Classes and Objects . . . . . . . . . . . . . . . . . . . . . . 748
15.2.1 Classes and Class Hierarchy . . . . . . . . . . . . . . . . . . . . . . . . 748
15.2.2 Global Stream Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 751
15.2.3 Header Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 752
15.3 Standard Stream Operators << and >> . . . . . . . . . . . . . . . . . . . . . . . . 753
15.3.1 Output Operator << . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 753
15.3.2 Input Operator >> . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 754
15.3.3 Input/Output of Special Types . . . . . . . . . . . . . . . . . . . . . . . 755
15.4 State of Streams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 758
15.4.1 Constants for the State of Streams . . . . . . . . . . . . . . . . . . . . . 758
15.4.2 Member Functions Accessing the State of Streams . . . . . . . . . . . . . 759
15.4.3 Stream State and Boolean Conditions . . . . . . . . . . . . . . . . . . . 760
15.4.4 Stream State and Exceptions . . . . . . . . . . . . . . . . . . . . . . . . 762
15.5 Standard Input/Output Functions . . . . . . . . . . . . . . . . . . . . . . . . . . 767
15.5.1 Member Functions for Input . . . . . . . . . . . . . . . . . . . . . . . . 768
15.5.2 Member Functions for Output . . . . . . . . . . . . . . . . . . . . . . . 771
15.5.3 Example Uses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 772
15.5.4 sentry Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 772
15.6 Manipulators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 774
15.6.1 Overview of All Manipulators . . . . . . . . . . . . . . . . . . . . . . . 774
15.6.2 How Manipulators Work . . . . . . . . . . . . . . . . . . . . . . . . . . 776
15.6.3 User-Defined Manipulators . . . . . . . . . . . . . . . . . . . . . . . . . 777
15.7 Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 779
15.7.1 Format Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 779
15.7.2 Input/Output Format of Boolean Values . . . . . . . . . . . . . . . . . . 781
15.7.3 Field Width, Fill Character, and Adjustment . . . . . . . . . . . . . . . . 781
15.7.4 Positive Sign and Uppercase Letters . . . . . . . . . . . . . . . . . . . . 784
15.7.5 Numeric Base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 785
15.7.6 Floating-Point Notation . . . . . . . . . . . . . . . . . . . . . . . . . . . 787
15.7.7 General Formatting Definitions . . . . . . . . . . . . . . . . . . . . . . . 789
15.8 Internationalization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 790
15.9 File Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 791
15.9.1 File Stream Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 791
15.9.2 Rvalue and Move Semantics for File Streams . . . . . . . . . . . . . . . 795
15.9.3 File Flags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 796
15.9.4 Random Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 799
15.9.5 Using File Descriptors . . . . . . . . . . . . . . . . . . . . . . . . . . . 801
15.10 Stream Classes for Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 802
15.10.1 String Stream Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 802
15.10.2 Move Semantics for String Streams . . . . . . . . . . . . . . . . . . . . . 806
15.10.3 char* Stream Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 807
15.11 Input/Output Operators for User-Defined Types . . . . . . . . . . . . . . . . . . . 810
15.11.1 Implementing Output Operators . . . . . . . . . . . . . . . . . . . . . . 810
15.11.2 Implementing Input Operators . . . . . . . . . . . . . . . . . . . . . . . 812
15.11.3 Input/Output Using Auxiliary Functions . . . . . . . . . . . . . . . . . . 814
15.11.4 User-Defined Format Flags . . . . . . . . . . . . . . . . . . . . . . . . . 815
15.11.5 Conventions for User-Defined Input/Output Operators . . . . . . . . . . . 818
15.12 Connecting Input and Output Streams . . . . . . . . . . . . . . . . . . . . . . . . 819
15.12.1 Loose Coupling Using tie() . . . . . . . . . . . . . . . . . . . . . . . . 819
15.12.2 Tight Coupling Using Stream Buffers . . . . . . . . . . . . . . . . . . . 820
15.12.3 Redirecting Standard Streams . . . . . . . . . . . . . . . . . . . . . . . . 822
15.12.4 Streams for Reading and Writing . . . . . . . . . . . . . . . . . . . . . . 824
15.13 The Stream Buffer Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 826
15.13.1 The Stream Buffer Interfaces . . . . . . . . . . . . . . . . . . . . . . . . 826
15.13.2 Stream Buffer Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . 828
15.13.3 User-Defined Stream Buffers . . . . . . . . . . . . . . . . . . . . . . . . 832
15.14 Performance Issues . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 844
15.14.1 Synchronization with C’s Standard Streams . . . . . . . . . . . . . . . . 845
15.14.2 Buffering in Stream Buffers . . . . . . . . . . . . . . . . . . . . . . . . . 845
15.14.3 Using Stream Buffers Directly . . . . . . . . . . . . . . . . . . . . . . . 846
16 Internationalization 849
16.1 Character Encodings and Character Sets . . . . . . . . . . . . . . . . . . . . . . . 850
16.1.1 Multibyte and Wide-Character Text . . . . . . . . . . . . . . . . . . . . . 850
16.1.2 Different Character Sets . . . . . . . . . . . . . . . . . . . . . . . . . . . 851
16.1.3 Dealing with Character Sets in C++ . . . . . . . . . . . . . . . . . . . . 852
16.1.4 Character Traits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 853
16.1.5 Internationalization of Special Characters . . . . . . . . . . . . . . . . . 857
16.2 The Concept of Locales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 857
16.2.1 Using Locales . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 858
16.2.2 Locale Facets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 864
16.3 Locales in Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 866
16.4 Facets in Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 869
16.4.1 Numeric Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 870
16.4.2 Monetary Formatting . . . . . . . . . . . . . . . . . . . . . . . . . . . . 874
16.4.3 Time and Date Formatting . . . . . . . . . . . . . . . . . . . . . . . . . 884
16.4.4 Character Classification and Conversion . . . . . . . . . . . . . . . . . . 891
16.4.5 String Collation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 904
16.4.6 Internationalized Messages . . . . . . . . . . . . . . . . . . . . . . . . . 905
17 Numerics 907
17.1 Random Numbers and Distributions . . . . . . . . . . . . . . . . . . . . . . . . . 907
17.1.1 A First Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 908
17.1.2 Engines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 912
17.1.3 Engines in Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 915
17.1.4 Distributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 917
17.1.5 Distributions in Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . 921
17.2 Complex Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 925
17.2.1 Class complex<> in General . . . . . . . . . . . . . . . . . . . . . . . . 925
17.2.2 Examples Using Class complex<> . . . . . . . . . . . . . . . . . . . . . 926
17.2.3 Operations for Complex Numbers . . . . . . . . . . . . . . . . . . . . . 928
17.2.4 Class complex<> in Detail . . . . . . . . . . . . . . . . . . . . . . . . . 935
17.3 Global Numeric Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 941
17.4 Valarrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 943
18 Concurrency 945
18.1 The High-Level Interface: async() and Futures . . . . . . . . . . . . . . . . . . 946
18.1.1 A First Example Using async() and Futures . . . . . . . . . . . . . . . 946
18.1.2 An Example of Waiting for Two Tasks . . . . . . . . . . . . . . . . . . . 955
18.1.3 Shared Futures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 960
18.2 The Low-Level Interface: Threads and Promises . . . . . . . . . . . . . . . . . . 964
18.2.1 Class std::thread . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 964
18.2.2 Promises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 969
18.2.3 Class packaged_task<> . . . . . . . . . . . . . . . . . . . . . . . . . . 972
18.3 Starting a Thread in Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 973
18.3.1 async() in Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 974
18.3.2 Futures in Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 975
18.3.3 Shared Futures in Detail . . . . . . . . . . . . . . . . . . . . . . . . . . . 976
18.3.4 Class std::promise in Detail . . . . . . . . . . . . . . . . . . . . . . . 977
18.3.5 Class std::packaged_task in Detail . . . . . . . . . . . . . . . . . . . 977
18.3.6 Class std::thread in Detail . . . . . . . . . . . . . . . . . . . . . . . . 979
18.3.7 Namespace this_thread . . . . . . . . . . . . . . . . . . . . . . . . . 981
18.4 Synchronizing Threads, or the Problem of Concurrency . . . . . . . . . . . . . . 982
18.4.1 Beware of Concurrency! . . . . . . . . . . . . . . . . . . . . . . . . . . 982
18.4.2 The Reason for the Problem of Concurrent Data Access . . . . . . . . . . 983
18.4.3 What Exactly Can Go Wrong (the Extent of the Problem) . . . . . . . . . 983
18.4.4 The Features to Solve the Problems . . . . . . . . . . . . . . . . . . . . . 987
18.5 Mutexes and Locks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 989
18.5.1 Using Mutexes and Locks . . . . . . . . . . . . . . . . . . . . . . . . . . 989
18.5.2 Mutexes and Locks in Detail . . . . . . . . . . . . . . . . . . . . . . . . 998
18.5.3 Calling Once for Multiple Threads . . . . . . . . . . . . . . . . . . . . . 1000
18.6 Condition Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1003
18.6.1 Purpose of Condition Variables . . . . . . . . . . . . . . . . . . . . . . . 1003
18.6.2 A First Complete Example for Condition Variables . . . . . . . . . . . . 1004
18.6.3 Using Condition Variables to Implement a Queue for Multiple Threads . . 1006
18.6.4 Condition Variables in Detail . . . . . . . . . . . . . . . . . . . . . . . . 1009
18.7 Atomics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1012
18.7.1 Example of Using Atomics . . . . . . . . . . . . . . . . . . . . . . . . . 1012
18.7.2 Atomics and Their High-Level Interface in Detail . . . . . . . . . . . . . 1016
18.7.3 The C-Style Interface of Atomics . . . . . . . . . . . . . . . . . . . . . . 1019
18.7.4 The Low-Level Interface of Atomics . . . . . . . . . . . . . . . . . . . . 1019
19 Allocators 1023
19.1 Using Allocators as an Application Programmer . . . . . . . . . . . . . . . . . . 1023
19.2 A User-Defined Allocator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1024
19.3 Using Allocators as a Library Programmer . . . . . . . . . . . . . . . . . . . . . 1026
Bibliography 1031
Newsgroups and Forums . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1031
Books and Web Sites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1032
Index 1037
Preface to the Second Edition
I never thought that the first edition of this book would sell so long. But now, after twelve years, it’s
time for a new edition that covers C++11, the new C++ standard.
Note that this means more than simply adding new libraries. C++ has changed. Almost all typical
applications of parts of the library look a bit different now. This is not the result of a huge language
change. It’s the result of many minor changes, such as using rvalue references and move semantics,
range-based for loops, auto, and new template features. Thus, besides presenting new libraries and
supplementary features of existing libraries, almost all of the examples in this book were rewritten
at least partially. Nevertheless, to support programmers who still use “old” C++ environments, this
book will describe differences between C++ versions whenever they appear.
I learned C++11 the hard way. Because I didn’t follow the standardization as it was happening I
started to look at C++11 about two years ago. I really had trouble understanding it. But the people
on the standardization committee helped me to describe and present the new features as they are
intended to be used now.
Note, finally, that this book now has a problem: Although the book’s size grew from about 800
to more than 1,100 pages, I still can’t present the C++ standard library as a whole. The library part
of the new C++11 standard alone now has about 750 pages, written in very condensed form without
much explanation. For this reason, I had to decide which features to describe and in how much
detail. Again, many people in the C++ community helped me to make this decision. The intent was
to concentrate on what the average application programmer needs. For some missing parts, I provide
a supplementary chapter on the Web site of this book, http://www.cppstdlib.com, but you still
will find details not mentioned here in the standard.
The art of teaching is not the art of presenting everything. It’s the art of separating the wheat
from the chaff so that you get the most out of it. May the exercise succeed.
Preface to the First Edition
In the beginning, I only planned to write a small German book (400 pages or so) about the C++ stan-
dard library. That was in 1993. Now, in 1999 you see the result — a book in English 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!
Chapter 1
About This Book
1.1 Why 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 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.
Now, with the second standard, called C++11 (see Section 2.1, page 7, for the detailed history of
C++ standards), we have a huge C++ standard library whose specification requires more than double
the size of the core language features. The library enables the use of
• Input/output (I/O) classes
• String types and regular expressions
• Various data structures, such as dynamic arrays, linked lists, binary trees, and hash tables
• Various algorithms, such as a variety of sorting algorithms
• Classes for multithreading and concurrency
• Classes for internationalization support
• Numeric classes
• Plenty of utilities
However, the library is not self-explanatory. To use these components and to benefit from their
power, you need an 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 its components from a conceptual point of view. Next, the book
describes the details needed for practical programming. Examples are included to demonstrate the
exact use of the components. Thus, this book is a detailed introduction to the C++ library for both
the beginner and the practicing programmer. Armed with the data provided herein, you should be
able to take full advantage of the C++ standard library.
Random documents with unrelated
content Scribd suggests to you:
IV. The cruel and covetous. Man’s rapacity and selfishness are set
forth in verses 15 to 17 in very strong terms. His greediness and cruelty
are compared to that of a creature the sole end of whose existence is to
gorge itself with blood; to the ever open grave; to swords and knives,
etc. We know too well that this picture is not overdrawn. Nothing that
man can imagine in the form of cruelty can surpass what man has been
guilty of, and such ingenuity has he sometimes displayed in this
direction that one is constrained to believe that he has been inspired
by a supernatural power of evil, for his deeds of darkness have seemed
too black for man of himself to conceive. Some of the cruelty of man
towards man may not be the offspring of covetousness, but doubtless
much of it is. Men often care not who suffers, or how much they suffer,
so that they satisfy their own selfish desires, and all this unnatural
conduct is an evidence that there is a schism in the human race which
calls for some remedy such as that of the Gospel, whereby such savage
natures may be transformed, and “The wolf also shall dwell with the
lamb, and the leopard shall lie down with the kid,” etc. (Isa. xi. 6).
outlines and suggestive comments.
In Scripture, the word “generations” is repeatedly used to signify
particular classes or descriptions of men; for two reasons, or points of
analogy:—first, that as generation follows generation, so surely, in
every generation, a succession of such characters is to be found;—and
secondly, that they very often communicate the character to one
another, and thus keep up their respective kinds,—are successive
propagators of their species.—Wardlaw.
Verse 11. Here a new thought begins, but probably one from the same
teacher. As he had uttered what he most desired, so now he tells us
what he most abhorred, and in true harmony with the teaching of the
Ten Commandments places in the foremost rank those who rise
against the Fifth.—Plumptre.
Solon, when asked why he had made no law against parricides, replied,
that he could not conceive of anyone so impious and cruel. The Divine
lawgiver knew His creature better, that his heart was capable of
wickedness beyond conception (Jer. xvii. 9).—Bridges.
Verse 14. Yet withal, these cruel oppressors are marked by pitiful
cowardice. They vent their wantonness only where there is little or no
power of resistance. It is not the wolf with the wolf, but with the
defenceless lamb; devouring the poor and needy from off the earth,
—“eating up my people”—not like an occasional indulgence, but “as
they eat bread” their daily meal, without intermission (Ps. xiv. 4).—
Bridges.
main homiletics of the paragraph.—Verses 18–20.
Depths of Wickedness.
I. There are deeds of iniquity which leave no outward immediate
trace. The path which the eagle opens by her wings when she soars
aloft cannot be traced by the human eye. The air closes behind her as
she moves, and she leaves nothing to show that she has passed that
way. The vessel ploughs its way through the deep, and leaves a wake
behind her for a short time. But the sea, like the air, soon resumes its
former condition, and the keel leaves no lasting indication upon the
water whereby the course of the mariner can be seen. So the serpent
glides over the rock, and for a moment its shining scales are reflected
in the sun, and then it is hidden from sight and the rock bears no
footprint upon its surface. No human skill could, in any of these
instances, find any evidence by which to establish the fact that either
the thing without life or the living creatures had been there. So the sin
to which all these comparisons are linked is one which may be
concealed from the eyes of all except those concerned in it, not only at
the time of its committal, but also in the immediate future. Those who
come in contact with the guilty parties may see no more trace of the sin
than they would do of an eagle’s course, or, to use the other metaphor,
of bread that had been eaten by one who has wiped his mouth after the
meal.
II. Sin is so in opposition to the voice of the human conscience
that even those who love it must seek to hide it. The adulteress has
sunk as low in the moral scale as it is possible for a human creature to
sink, and yet she seeks to hide her shame. Men of evil deeds love
darkness rather than light, and so give evidence that there is that
within them that condemns their unholy deeds. The very denial of the
crime is a condemnation of it. There are many crimes which are not
amenable to human law which men, notwithstanding, try to hide from
human eyes, and their efforts to do this are witnesses against them and
in favour of the law which they have broken.
main homiletics of the paragraph.—Verses 21–23.
Burdens Grievous to be Borne.
I. It is sometimes dangerous to the peace of a community to raise
a person from a low to a high position. To place a man who has
never before crossed a horse, upon a high-spirited charger, is to create a
source of danger both to himself and others. There is a strong
probability that the unskilful rider will be thrown from his
unaccustomed elevation, and so injure himself. And it is also probable
that he will be the means of mischief to other travellers upon the road,
whom he will overthrow in his unskilful efforts to keep his seat. It is
generally as dangerous an experiment to lift a man at once from the
position of a servant to that of a ruler. Although faithfulness “over a few
things” is, according to the highest authority, the best qualification for
rulership “over many things” (Matt. xxv. 21), it is not always hands used
only to service are fit to hold the reins of government, either in a small
or a large society. On this subject see also on chap. xix. 10, page 569.
II. Some human creatures cannot safely be trusted with even a
sufficiency of this world’s goods. They are not only unfit to rule
others, but so unfit to rule themselves that they cannot be “filled with
meat” without becoming a centre of disturbance. Even enough of the
necessaries of life suffices to make them injurious to themselves and
insolent to their betters. This is especially true of men who are slaves to
their bodily appetites. There are men in the world who, although
peaceable and even useful citizens when they are kept in a state of
comparative want and hardship, indulge in excess and immorality as
soon as the restraint is removed. They will sometimes know this to be
true, and yet they are so wanting in moral courage and strength as not
to struggle after a higher condition of being. Such men are fools
indeed.
III. The change of disposition which change of circumstance
sometimes seems to work may be the result of deliberate
purpose. When a servant becomes a ruler he may be the occasion of
trouble simply from intellectual inability, and the fool who cannot
safely be filled with meat may be only morally weak; but the woman
here represented as developing into a curse after marriage suggests a
person who has deliberately hidden her real character for a time in
order to gain a position in which she can have more opportunities of
indulging her evil propensities. This is a step farther in wickedness,
and this domestic burden is often the most grievous of all burdens. On
this subject see on chap. xxi. 9 and 19, page 613.
outlines and suggestive comments.
Judge, then, how horrible it is that men should set the devil, or his two
angels the world and the flesh, in the throne, whiles they place God in
the footstool; or that in this commonwealth of man, reason, which is
the queen or princess over the better powers and graces of the soul,
should stoop to so base a slave as sensual lust.—T. Adams.
And now, just notice the comprehensiveness, in regard to the
happiness of human life, of the four things thus enumerated. They
begin, observe, at the throne, and come down to the domestic servant.
They embrace four great sources of the social unhappiness of mankind.
They are—incompetent rule, preposterous and besotted folly, conjugal
alienation and strife with its domestic miseries, and the unnatural
inversion of social order.—Wardlaw.
main homiletics of the paragraph.—Verses 24–28.
Lowly Teachers.
I. Men can learn from creatures far beneath him. Herein he gives
evidence both of his greatness and of his imperfection. He is often so
faulty in many respects that some of the most insignificant creatures
around him read him lessons of wisdom, and yet his capability of
receiving instruction from them shows how superior he is to them. For
creatures below man, although their actions are often marked by
something that seems very nearly akin to reason, are not capable of
receiving moral instruction, either from those above or beneath them,
and so give proof that they lack a capacity which man possesses.
II. The lessons taught him by each of these creatures. 1. From the
ant industry and forethought. On this subject see on chap. vi. 6–11, page
78. 2. From the coney (see Critical Notes) a prudent acknowledgement
of weakness. It is one of the marks of a wise man that he knows his
weakness as well as his strength, and this seems to be the lesson
conveyed by the feeble folk who, conscious of their feebleness, make
their abodes in the rocks. Foolhardiness may ruin a man as surely as
cowardice, and it is quite a different thing from courage, though it is
sometimes mistaken for it. 3. From the locust the need of unity and co-
operation. The locust is in itself a small and weak insect, yet it is well
known what mighty and terrible work can be accomplished by them
when they unite. They stand as an example of the wonderful effect of
perfect combination and unanimity in action. (See Joel ii. 2–11.) They
seem animated by a single purpose, and the myriads of individuals
seem to become one great and irresistible monster, and thus show us
what great things can be accomplished in any community when men
are of one heart and mind on any subject, and are willing to lay aside
personal preferences and individual interests in order to achieve a
common purpose. 4. From the lizard (see Critical Notes) the results of
perseverance. This little creature is constantly found in Eastern houses,
and doubtless in the palace as well as in more lowly dwellings.
Although hardly so good an example of perseverance as the spider, yet
it owes its presence in the house to its own energy in overcoming
obstacles, and its pertinacity in seeking out some means of entrance,
and may therefore be regarded as worthy of man’s imitation when
some task is set before him which calls for continuous and watchful
effort.
outlines and suggestive comments.
It has been remarked by some, that the four emblems express all that is
requisite for the conservation and well-being of a state or kingdom.
There is supply of food;—commodious and secure dwelling places;—
subordination, concord, and united exertion;—and the prevalence and
encouragement of the ingenious and useful arts. These are things that
governors and kings should look to. And we may apply the emblematic
lessons to domestic life. Before a man can prudently marry, and have a
family, he should have some suitable provision made, and something
like a fair prospect of being able to support them. Next is to be found a
suitable dwelling, adapted to the circumstances and convenience.
Then, when settled, there must be harmony, union, co-operation, in all
departments of the household. And lastly, there must be the diligent,
constant, persevering application of his skill and labour to his worldly
calling.—Wardlaw.
The ants prepare their meat in the summer, that they may not starve in
the rigours of the winter months. How despicable, compared with
these insects, are the rational creatures, who suffer the thoughts of an
endless duration to be pushed out of their minds by threescore and ten
years? The high hills are a refuge for the wild goats, and the rocks for
the conies; and has God provided no refuge for our souls? God himself
is our refuge and our strength, and those that make Him their
habitation shall be secured from the fear of evil.—Lawson.
main homiletics of the paragraph.—Verses 29–31.
Kingly Qualities.
These words seem to set forth animal qualifications needed by human
leaders.
I. They must be men of courage. A cowardly man in any position in
society will, at some time or other, be found wanting, but what is
needed in everyday life and by men in ordinary positions, is
indispensable in him who has to lead others. A king in the days of
Solomon was expected to be at the head of his army in the day of
battle, and if he was not then an example to all beneath him in this
respect, he brought disgrace and ruin upon himself and them. A king
in all ages, and under all circumstances should be to his subjects what
the lion is to the other beasts of the forest—a pattern of dignity and
courage.
II. They must be active and watchful. Both the greyhound and the
war-horse—whichever may be here meant—are characterised by
swiftness of foot and great sagacity. They are ready at any moment to
set forth on any errand, and are always on the alert when danger is
near. The goat, also, is agile in its movements, and as sure-footed as it
is fleet. All these animal qualities are symbolic of mental qualifications
which must be possessed by those who aspire to lead and rule their
fellow-men successfully. They must not be behindhand when called to
action, but they must at the same time take heed to the dangers which
may lie in wait for them. They must be ever ready at the call of duty,
but they must not be rash and hasty, and so endanger much more than
their own personal safety.
On the subject of verses 32 and 33, see on chap. xvii. 14, page 513.
remarks on the chapter as a whole.
While it appears at the first view that the flowers and fruits from the
cornucopia of Agur’s wisdom, original and in part so rarely fashioned,
are heaped up wholly without order, yet they all agree in this, that they
depict the glory and all sufficiency of the Word of God, dissuade from
adding to it by any human supplement, and most urgently commend
the fulfilling and following it by a pious life. There is hardly a single
commandment of the Decalogue that is not directly or indirectly
repeated and emphasised in these maxims. Observe the relation of the
prayer for the hallowing of God’s name (verses 7–9) to the first and
third commandments; the references contained in verse 11, and again
in verse 17 to the fifth commandment; the warnings against the
transgression of the sixth commandment in verse 14 as well as in verses
32–33; the reproving and warning aim of verses 18–20, and 23, in their
bearing upon the seventh; the allusion to the eighth in verse 9, and to
the ninth in verse 10; and finally the reference, reminding us of the
tenth in verses 15 and 16. . . . No one of these proverbs is wholly without
an ethical value; not even the two numerical proverbs (verses 24–28,
and 29–31), which at the first view stand apart as incidental reflections
on merely natural truths, but in reality hide under their ingenious
physical drapery decided moral aims. For in verses 24–28 four chief
virtues of one’s social and political avocation are specified through an
allusion to a like number of examples from the animal world, and
verses 29–31 run into a delineation of the high dignity and glory of a
king by the grace of God in contrast with the insufferable tyranny of
base upstarts (verses 21–23).—Lange’s Commentary.
CHAPTER XXXI.
Critical Notes.—Lemuel. This Hebrew word signifies “For God,” or
“belonging to God,” and is regarded by most commentators as a proper
name. The prophecy. Delitzsch, Stuart, and many other Hebrew
scholars render this word as a proper name, and read “The words of
Lemuel, king of Massa, which his mother taught him.” Miller reads the
verse, “Words in respect to the Seed-of-God, a king; a prophecy in
agreement with which his mother disciplined him,” and, as in the
preceding chapter, applies it to Christ. 2. What, etc. “An impassioned
exclamation expressing inward emotion.” (Zöckler.) “The question,”
says Delitzsch, “which is at the same time a call, is like a deep sigh from
the heart of a mother concerned for the welfare of a son.” 3. The second
clause reads literally “nor thy ways to destroy kings,” and hence some
understand it as a warning against warlike rapacity and lust of
conquest, but, as Delitzsch remarks, this does not stand well as the
parallel to the warning in the first clause. 4. Strong drink. (See on
chap xx. 1.) 5. Any of the afflicted. Literally “The sons of want.”
8. Such as are appointed to destruction. Literally “Children of
leaving,” generally understood to mean orphans. The twenty-two verses
following form an alphabetical song, each verse beginning with the
several letters of the Hebrew alphabet arranged in consecutive order.
10. Virtuous. Literally “a woman of power.” Rubies, rather “pearls.”
11. He shall have no need, etc. Rather, “He shall not fail of spoil.”
“Strictly, ‘the spoils of war,’ a strong expression to denote his rich
profit.” (Zöckler.) 15. This probably signifies the appointed task for the
day. 21. Scarlet. Delitzsch and Zöckler retain this reading; the former
remarks that “as high-coloured, it appears dignified as well as preserves
warmth.” 22. Coverings, rather “coverlets,” as in chap. vii. 16, “a part of
the furniture of the bed.” 25. She shall rejoice. Rather, “She laugheth
at the future,” i.e., she is not afraid of it, being fully prepared for all
emergencies. 26. Law of kindness. Delitzsch reads “Amiable
instruction.” 30. Favour, i.e., “outward grace.” Vain, or “a breath.”
main homiletics of the paragraph.—Verses 1–9.
Divine Commands from a Mother’s Lips.
I. Two considerations made it obligatory upon Lemuel to attend
to this counsel of his mother. 1. She was inspired to utter it. However
we may translate the word here rendered “prophecy” (see Critical
Notes), its place in the Holy Scriptures gives to it the authority of a
message from God. The words are not merely the results of a tender
and wise mother’s own observation and experience, but they are the
utterances of a spirit under the special influence of the Holy Ghost.
Although, therefore, his mother’s love, and, doubtless, her holy
example, ought to have been very powerful incentives to attention and
obedience, his obligation was increased tenfold by the conviction he
must have had that God spoke to him through her lips. 2. He was a
king. If men in every station of life are bound to keep the paths of
purity and charity, much more is it the duty of one in a high place—the
influence of whose actions stretch so far beyond his immediate
surroundings, and who holds in his hand the destinies of so many
besides his own. Because Lemuel had been called by God to a throne,
what he was and what he did concerned not a few people only, but a
nation, and this reflection ought to have added great weight to his
mother’s words.
II. The first and indispensable duty of a ruler is to rule himself.
Every man is a little kingdom made up of many different and
sometimes opposing forces—of inclinations towards the earthly, the
sensual, and even the devilish, and of aspirations towards the heavenly,
the spiritual, and the godlike. There are lawful desires which, satisfied
in a lawful manner, may lead to much enjoyment and blessing, but
which, if allowed to rule the man, or even to have any share in the
government of the life, will degrade and may almost brutalise him.
Bodily appetites have their place in the constitution of man, but it was
never intended that they should be satisfied by breaking the moral law;
and when they lead to this, moral anarchy has set in, and moral ruin is
not far off. The two great sins of the body against which Lemuel is here
warned have in all ages shown how man can turn blessings into curses
by abusing and mis-using them, and the Word of God and human
history unite in proclaiming the truth that the Divine intention is
perverted when the body rules the man and not the man the body.
Every man is bound to be king of himself, and one who aspires to be a
king over others and is yet a slave to his own unlawful passions will
being upon himself the curse of man and the judgment of God. On
this subject see also on chap. vi. 24–35, page 89, and on chap. xxiii. 29–
35, page 673.
III. The obligation next in order is succour of the needy. In former
chapters we have considered the obligation which God lays upon every
man to consider the cause of the poor and afflicted. (See on chaps.
xiv. 20, page 370, and chap. xxiv. 11, page 680.) As we remarked at the
outset, duties which men owe to their fellow-men multiply and
become binding in proportion to opportunities. The king of ancient
times was but another name for one whose direct influence over his
subjects was greater than that of monarchs in our day. His word was
law, and the power of life and death was often in his hand alone, and if
he exercised self-denial and gave of his substance to those in want, he
might often by his individual action entirely change the condition of
half his subjects. The relations of society have changed since then, and
kings have no longer so exclusively the power for good or ill, but their
influence is still very great, and if it is all exerted in favour of
benevolence and justice, and they live lives of self-denial and active
compassion on behalf of others, they will come up to the ideal picture
here drawn for their imitation.
outlines and suggestive comments.
Verse 2. There was a threefold cord of maternal love which this parent
was wont to employ, and which remained in its form as well as its
power in the memory of her son. “My son” is the outmost and
uppermost aspect of the relation. This is a bond set in nature, felt by
the parties, and obvious to all. On this she leans first when she makes
an appeal to his heart. But at the next step she goes deeper in. She
recalls the day of his birth. She goes back to that hour when nature’s
greatest sorrow is dispelled by nature’s gladdest news. “A man-child is
born into the world.” By the pains and joys of that hour she knits the
heart of her son to her own, and thereby increases her purchase upon
the direction of his life. But still one step farther back can this mother
go. Here is the “son of her vows.” Before his birth she held converse, not
with him for God, but with God for him.—Arnot.
Verse 4. It is not for kings to admit within their dominions anyone that
is stronger than themselves, and able to overthrow them. It is not for
kings to harbour anyone within their dominions that is false unto
them, and ready to betray them; much more it is not for kings to admit
within themselves any immoderate quantity of wine, which soon
proveth too strong for them, and quickly with shame overthroweth
them.—Jermin.
main homiletics of the paragraph.—Verses 10–31.
A Model Matron.
This picture of a faithful and kindly wife, mother, and mistress is here
placed before the youthful monarch as the ideal woman whom he is to
seek with all diligence, because she is well worth any pains to secure,
and with much discrimination, because she is a rarity, and because
there are many imitations of the real gem which look very much like it
before they are tested. This beautiful picture is held to his view as the
master holds some grand conception on canvas before his pupil, in
order that he may acquire a distaste for all that comes short of it. This
portrait may have been drawn by the mother of Lemuel; in any case we
may safely conclude that she was such a woman herself, and if it came
from another hand it is, probably, her likeness drawn from life. We
notice—
I. The prominent features of her character. 1. Her energy. There
seems to be within her a spring of unfailing activity, and the
completion of one task is immediately followed by the beginning of
another. In her home she is astir before the dawn, and when her
domestic duties are completed she gives her mind to the transaction of
business without—to the best market in which to sell her goods, and to
buy all that she needs for the supply of her household. We cannot
conceive of this energetic spirit in a frail and sickly body—she must
have been physically healthy and strong, and we may give her credit for
having been observant of the laws of God in this respect as in higher
matters, and be sure that she avoided whatever might weaken her body
or deaden her intellect. This being the case, her constant activity would
be a pleasure, and would in itself contribute to the maintenance of her
bodily strength. 2. Her capability. She was not only a great worker, but
there was wisdom behind the work—a brain directing the hands. There
are many people always busy, who yet accomplish but little, because
their activity is not wisely directed—indeed, energetic action without
wisdom to guide it, may be most disastrous in its effects. There is an
abundance of power in the locomotive, but if it is set in motion and left
free from wise control, it works ill instead of good. But this woman’s
intellectual capacity equalled her active energy. She was a good judge
of the merchandise that she had to sell, and knew the value of the land
that she bought. She was methodical, and so able to arrange the
employments of all the household so that no confusion should arise,
and she could also show them with her own hands how to perform
their work, for “she layeth her hands to the spindle,” and so follows up
her precept by example. Her capacity also manifested itself to her
forethought—in keeping her supply well ahead of her demand. 3. Her
loving tenderness. She might have been all that we have thus far
painted her, and yet not have made a happy home. If she had been
nothing more she might have been feared, and in some measure
respected, but she would not have been loved. Just as energy may be
dangerous without wisdom to guide it, so such capable energy may be
repellent without love to soften it. But her uncommon endowments
and attainments did not make her impatient with her inferiors, and
she was not so absorbed in providing for those at home as to forget the
poor outside. Her commands were given in a winning tone, and her
corrections in a loving spirit. She was more apt to instruct than to
reprove, and doubtless acted upon the principle that the “way to make
people better is to make the best of them.”
II. The root of all these excellencies. Although it is not absolutely
stated, it is implied that godliness was the source of this symmetrical
character—that it was the fear of the Lord which enabled her to keep
so even a balance of virtues as to stand forth a perfect pattern to the
women of every age and nation. The fear of God had given her a right
conception of her duties towards all mankind, and especially of the
sacred nature of her relationships as wife and mother. She fully entered
into the Divine idea of marriage, and this made her the true helpmeet
of her husband, and in regard to each son and daughter she heard the
voice of her God saying, “Take this child and nurse it for me.” She knew
that faithfulness in all things was expected of a servant of God, and
that true godliness consists not so much in the things done as in the
spirit in which they are performed. In this spirit of George Herbert she
could say—
“Teach me, my God and King,
In all things Thee to see;
And what I do in anything
To do it as for thee.
“All may of Thee partake;
Nothing can be so mean
Which with this tincture (for Thy sake)
Will not grow bright and clean.
“This is the famous stone
That turneth all to gold;
For that which God doth touch and own
Cannot for less be told.”
And thus living every day and always in conscious fellowship with the
Unseen, she would be too conscious of her own shortcomings to be
anything but tender towards the failings of others, and would not
forget that she owed all her success in life to the blessing of the Lord,
and held all her material good in stewardship for His service.
III. The blessed results of all. She had an abundant and lasting
reward. Her husband’s trust in her was undimmed by a single shadow;
whatever position she was called upon to sustain he felt fully confident
that she was equal to it, and that everything that he possessed—from
his reputation to his purse—was not only safe in her hands, but had
increased in worth through his connection with her. Her words of
loving counsel, and her useful and benevolent life, were not lost upon
her children, but as good seen sown in good ground brought forth an
abundant harvest in their filial reverence and noble deeds. And this
family blessedness was not a thing that could be hid, but, like a candle
of the Lord in a world of much moral darkness, it shed its light all
around, and blessed and stimulated others to fear God, and so to serve
their generation.
outlines and suggestive comments.
Verse 12. The manner of some is to do good with the one hand, and
with the evil of the other to spoil it; whereby they still remain to be evil
wives. Others will do good while the fit lasteth, but they are weary of
well-doing; whereas a good wife indeed will do good to her husband all
the days of her life. It is not said of his life, but of hers. For though he
may be dead, she will do him good while she liveth, by doing good to
his children, to his friends, to his memory.—Jermin.
Verse 16. Some consider but they buy not; some buy but they consider
not; some consider and buy, but they plant not; some consider and buy
and plant; but it is with the rapine of their hands, not the fruit of their
hands. That field is well bought, where wisdom considereth what is
bought, where ability buyeth that which hath been considered, where
care planteth that which hath been bought, and where honesty giveth a
blessing to that which hath been planted.—Jermin.
Verse 20. She doth not only open her hand, but stretcheth it (if I may
so make use of the word), as if she would hold more to give the poor if
she could. . . . And as if one hand were not enough for her it is said she
reacheth forth her hands; and if she had more than two no doubt she
would reach them all forth to the poor.—Jermin.
Verse 22. It is precisely such a woman who should wear such garments.
The silk hangs all the more gracefully on her person that it was wound
and spun by her own hands. . . . This matron is not limited to silk and
purple; strength and honour are her clothing too. She may safely wear
elegant garments, who in character and bearing is elegant without
their aid. If honour be your clothing, the suit will last a life-time, but if
clothing be your honour, it will soon be worn threadbare.—Arnot.
Verse 26. There be may false keys which open the mouths of many, as
rashness, and choler, and pride, and folly, and the like. But there is one
right key, and that is wisdom. That it is which makes a virtuous woman
courteous to all, a flatterer to none, a tale-bearer to none; that it is
which maketh her to be familiar with a few, to be just and true with
every one: that it is which maketh her respectful to her husband,
lovingly grave to her children, awfully grave to her servants; dutiful to
her superiors, affable with her equals, friendly to her neighbours, and
not disdainful to her inferiors; that it is which maketh her slow to
speak, quiet in speaking, profitable by speaking.—Jermin.
Verse 29. By the benefit of a better nature, or civil education, or for the
praise of men, or for a quiet life, sure it is that all unsanctified women,
though never so well qualified, have failed, both quoad fontem, et
quoad finem, for want of faith for the principle and God’s glory for the
aim of their virtuous actions. And, therefore, though they may be
praiseworthy, yet they are far short of this gracious matron. . . . “Better
is pale gold than glittering copper.” (Bernard.) Say the world what it
will, a drachm of holiness is worth a pound of good nature.—Trapp.
Verses 30 and 31. The lessons and where they began. Obedience is
traced up to faith. . . . As we traverse the various phases of her
character, we seem to be making our way over a well-watered and
fruitful region, until we reach at last the fountain of its fertility. . . .
Near the base of a mountain range, early in the morning of the day and
the spring of the year, you may have seen, in your solitary walk, a pillar
of cloud, pure and white, rising from the earth to heaven. In the calm
air its slender stem rises straight like a tree, and like a tree spreads out
its lofty summit. Like an angel tree in white, and not like an earthly
thing, it stands before you. You approach the spot and discover the
cause of the vision. A well of water from the warm depths bursts
through the surface there, and this is the morning incense which it
sends right upward to the throne. But the water is not all thus exhaled.
A pure stream flows over the well’s rocky edge, and trickles along the
surface, a river in miniature, marked on both sides by verdure, while
the barrenness of winter lies on the other portions of the field. . . . Such
are the two outgoings of a believer’s life. Upward rises the soul in direct
devotion; but not the less on that account does the life flow out along
the surface of the world, leaving its mark in blessings behind it
wherever it goes. You caught the spring by surprise at dawn, and saw
incense ascending. At mid-day, when the sun was up, it rose
unseen. . . . Thus is it in the experience of living Christians in the
world. . . . The upright pillar is seldom visible, but the horizontal
stream is seen and felt to be a refreshment to all within its reach.—
Arnot.
the end.
Transcriber’s Notes
Detailed changes:
“#” represents an illegible character.
Note counting convention: When a note continues from the prior page,
it is “note zero” or “same note,” (if it had been addressed in the
transcriber’s notes on the previous page). The first note that begins
new on a page is “note one,” etc.
In the Table of Contents (TOC), on page v. (unnumbered in original),
chapter i. 1–4, change “The Author, his Method and His Object” to
capitalise “His” (twice). Chapter i. 7–9, change “The Root of True
Knowledge and the Means of its Attainment” to capitalise “Its.” Chapter
i. 10–10, change “Enticement to Sin and Exhortation against yielding to
it” to capitalise “Against,” “Yielding,” and “It.” Chapter ii. 12–20, change
“The Character of those from whom Wisdom Preserves” to capitalise
“Those” and “Whom.” Chapter iii. 5, 6, change “Exhortation to
confidence in God” to capitalise “Confidence.” Chapter iii. 7–12, change
“The way” to capitalise “Way.” Chapter iii. 31–35, change “The
Oppressor not to be Envied” to capitalise “Not” and “Be.” Chapter
vi. 24–35, change “A Special Sin and its Penalties from which He who
Keeps God’s Law will be Kept” to capitalise “Its,” “Which,” “Who,”
“Will,” and “Be.” Chapter viii. 10, 11, change “Better than Wealth” to
capitalise “Than.”
TOC, page vi. (unnumbered in original), chapter x. 28, change “Hopes
Realized & Disappointed” to spell out “and.” Chapter xi. 12, 13, change
“Contempt and Tale-bearing” to capitalise “Bearing.” Chapter xi. 22,
change “Precious Things possessed by Unworthy Owners” to capitalise
“Possessed.” Chapter xii. 1, change “The Love of Knowledge and the
Proof of it” to capitalise “It.” Chapter xii. 3, change “A Right Desire and
the Means of its Attainment” to capitalise “Its.” Chapter xii. 5–8, change
“Thoughts and Words and their Result” to capitalise “Their.” Chapter
xii. 25, change “Heaviness of Heart and its Cure” to capitalise “Its.”
TOC, page vii. (unnumbered in original), chapter xiii. 23, change “Land
and its Tillers” to capitalise “Its.” Chapter xiv. 6, change “Seeking but
not Finding” to capitalise “Not.” Chapter xiv. 31, change “The Oppressed
and their Oppressors” to capitalise “Their.” Chapter xv. 16, change “A
Treasure without Trouble” to capitalise “Without.” Chapter xv. 20,
change the homiletics reference to page 137, from page 136.
TOC, page viii. (unnumbered in original), chapter xvi. 8, change the
first homiletics reference to page 405, from page 415. Chapter xvi. 27–
30, change “Different Species of the same Genus” to capitalise “Same.”
Chapter xvi. 33, change “The Lot and its Disposer” to capitalise “Its.”
Chapter xvii. 9, change “How to make Friends and How to Separate
Them” to capitalise “Make.” Chapter xvii. 10, change “Correction must
be Adapted“ to capitalise “Must.” Chapter xvii. 24, change “The Eyes of
a Fool and those of a Wise Man” to capitalise “Those.” Chapter xviii. 6–
8, change “Folly and its Results” to capitalise “Its.” Chapter xviii. 13,
change “Answering before Hearing” to capitalise “Before.” Chapter
xix. 2, 3, change “Influence leading to Sin” to capitalise “Leading.”
Chapter xix. 8–9, change the homiletics references to pages 121 and 124,
from 122 and 128. Chapter xix.%24, change the homiletics reference to
chapter xxvi. 12–16 from xxvi. 13–15. Change the reference for
“Possibilities of Human Depravity” from xxvi. 26–28 to xxvi. 26–29.
TOC, page ix. (unnumbered in original), chapter xx. 4, change
homiletics reference to page 142, from page 146. Chapter xx. 10, add
reference to chapter xi. 1. Chapter xx. 13, change homiletics reference to
page 78, from page 79. Chapter xx. 18, change “Thought before Action”
to capitalise “Before.” Chapter xx. 21, change second cross refernce from
“xxi. 5–7” to “xxi. 5, 7.” Chapter xxi. 11, change “Instruction for those
who Need It” to capitalise “Those” and “Who.” Chapter xxi.% 23,
change the homiletics reference to chapter xiii. 2–3 from xiii. 3. Chapter
xxii. 1, change “Better than Gold” to capitalise “Than.” Chapter xxii. 5, 6,
change “A Hedged-up Way” to capitalise “Up.” Chapter xxii. 10, change
“A Man who Ought to Dwell Alone” to capitalise “Who.” Chapter
xxii. 26, 27, change “Suretyship and its Dangers” to capitalise “Its.”
Chapter xxiv. 8, 9, change cross reference from “chap. vi. 12, 19” to
“chap. vi. 12–19.”
TOC, page x. (unnumbered in original), chapter xxiv. 28, 29, change
“An Uncalled-for Testimony” to capitalise “For.” Chapter xxv. 14, change
“Clouds without Rain” to capitalise “Rain.” Chapter xxv. 27, change “Too
much of a Good Thing” to capitalise “Much.” Chapter xxvi. 12–16,
change “Self-conceit and Indolence” to capitalise “Conceit.” Chapter
xxvii. 8, change “Plac” to “Place.” Chapter xxvii. 22, change second
homiletics reference to chapter xix. 26–29 from xix. 29. Chapter
xxviii. 4, 5, change “Law-keepers and Law-breakers” to “Lawkeepers
and Lawbreakers.” Chapter xxviii. 6, change page reference to 561 from
582. Chapter xxviii. 9, change page reference to 406 from 407, 408.
Chapter xxviii. 10, change reference to chapter xxvi. 23–28 from xxvi. 27
and page 721 from 722. Chapter xxviii. 12, change reference to chapter
xi. 10–11 from xi. 10. Chapter xxviii. 14, change second reference to
chapter xix. 15–18 from xiv. 16. Chapter xxviii. 18, change first reference
to chapter x. 9–10, from x. 9. Chapter xxviii. 24, change page reference
to 751 from 749. Add entry for chapter xxviii. 25a. Chapter xxviii. 25, 26,
change to 25b, and change page reference to 752 from 751. Chapter
xxviii. 28, change reference to chapter xi. 10–11 from xi. 10. Chapter
xxix. 2, change reference to chapter xi. 10–11 from xi. 10. Chapter xxix. 3,
change first page reference to 67 from 68.
TOC, page xi. (unnumbered in original), chapter xxix. 19, change “Soul-
seekers and Soul-haters” to capitalise “Seekers” and “Haters.” Chapter
xxix. 13, change reference to chapter xxii. 22–23 from xxii. 22. Chapter
xxix. 16, change “Victory not with the Majority” to capitalise “Not.”
Chapter xxix. 23, change second reference to chapter xvi. 18–19 from
xvi. 18.
Page 2, Divisons, part III, change “ch. xxii. 17; xxiv. 22” reference to “ch.
xxii. 17—xxiv. 22.” Critical Notes, chapter i., set verse numbers 17, 20, 28,
and 32 in bold for consistency. Title “The Author, his Method, and his
Object” to capitalise “His” (twice).
Page 4, verse 2, note one, apply Reverential Capitalisation (RC) to
“Divine” (twice). Verse 4, note one, use four period ellipsis.
Page 5, verse 5, note two, change “Melancthon” to “Melanchthon.”
Page 6, title, change “The Root of True Knowledge and the Means of its
Attainment” to capitalise “Its.” Point I, change subpoint “(1)” to “1.” for
consistency.
Page 7, note zero, paragraph one, point 2, apply RC to “Spirit”; add
“1 Cor. ii. 14” reference; change “the smothering the” to “the smothering
of the.” Verse 8, note two, capitalise “Oriental”; change “patriarchial” to
“patriarchal.” Title, change “Enticement to Sin and Exhortation against
yielding to it” to capitalise “Against,” “Yielding,” and “It.”
Page 9, lesson, point III, change “youth reflect up” to “youth reflect
upon.” Verses 11–13, note one, change subpoint “2” of point 2 to “(2)” for
consistency.
Page 10, verse 11, note zero, change the word “and” to Roman type from
Italic in Traditions of Robin Hood and Henry V to separate the two
titles.
Page 11, title, change the scripture reference from “Verses 20–23” to “20–
33.” Point I 1, remove right double quotes after “handiwork.”
Page 12, point V, apply RC to “His Spirit.” Point VI, apply RC to “Him.”
Page 13, verse 20, note two, capitalise “Orientals.” Note six, change the
double quotes around the scripture to single quotes and add a closing
double quote.
Page 14, verse 21, note zero, apply RC to “Spirit.” Verse 22, note one, add
closing double quote after “first.”
Page 16, verse 28, note zero, change “wicket.gate” to “wicket-gate.”
Verse 31, note three, add right parenthesis after “Isa. iii. 9–11” reference.
Page 17, verse 31, same note, use three period ellipsis after “desire.”
Spell-out “Ver. 32.” Verse 32, note one, move the closing double quotes
from after “lees” to after “evil.” Note five, change period after “plague in
it” to a question mark.
Page 18, Critical Notes, chapter ii., change “9. ver.” and “10. ver.” to bold
numbers, for consistency; format “13” as bold.
Page 19, lesson, point II 4, add closing quote after “him.” Verses 1 and 2,
note two, apply RC to “Word.”
Page 20, verse 5, note two, use four period ellipsis.
Page 21, lesson, point II 2, apply RC to “Himself.”
Page 22, lesson, point II 2, add left double quote before “preserveth.”
The break between pages 22 and 23 is in the word “cannot”: can|not. In
this and all subsequent cases, the whole word was moved to the earlier
page.
Page 24, title, change “The Character of those from whom Wisdom
Preserves” to capitalise “Those” and “Whom.” Lesson, point I 2, change
“forwardness” to “frowardness.”
Page 26, verse 16, note five, apply RC to “Divinely.”
Page 27, verse 21, note two, use a four period ellipsis.
Page 28, spell out “Ver. 22.” Verse 22, note three, change “That” to
lower-case. Critical notes, chapter iii., change “3” to “4.” Verse 6, add
right double quote after “smooth.” Format verse numbers 12 and 34 in
bold, for consistency.
Page 30, verse 2, note one, change “It itself” to “In itself.” Note three,
change exclamation point after “wisdom” to a question mark. Note five,
add right parenthesis after Psalm references.
Page 31, verse 4, note two, use three period ellipsis.
Page 32, lesson heading, apply Italic formatting consistently; change
"Verses" to initial cap from all caps.
Page 33, lesson, point III 2, apply RC to “His.” Verses 5 and 6, note one,
apply RC to “Word.” Note two, add left parenthesis before scripture
reference.
Page 34, title, change “The way” to capitalise “Way.” Lesson, point I 4,
change “John ix. 41” to “John ix. 39–41.”
Page 37, verse 8, note three, apply RC to “Word.”
Page 39, note one, add right double quote after “correction.”
Page 40, verse 14, note three, change “entradoes” to “entradas.”
Page 41, verse 16, note six, point I, add right double quote after “evil
men.”
Page 42, verse 17, Barrow’s comment appears as two paragraphs; the
Transcriber merged them.
Page 43, lesson, point II, complete the “Job xxxviii. 4” reference.
Page 44, lesson, point III (2), change “greater is warmer” to “greater in
warmer.” Point IV, add left double quote before “who.” Verse 19, note
two, change “i. 10” to “i. 20”; apply RC to “Diviner.”
Page 46, lesson, point II 2, remove period after “Lot.” Notes, remove the
em-dash after “Verse 22.”
Page 47, notes, remove the em-dash after “Verse 24.”
Page 48, lesson, point 2, change “friend do live” to “friend does live.”
Page 50, title, change “The Oppressor not to be Envied” to capitalise
“Not” and “Be.”
Page 52, critical notes, chapter iv., change “4” to “5.” Verse 7, add period
after “get wisdom.” Verse 15, add left double quote before “reject it.”
Page 53, lesson, point I 4, apply RC to “His” and “He.” Second lesson,
spell out “Ver. 2.”
Page 54, verse 2, note two, add right double quote after “us.”
Page 55, verse 6, note one, change the double quotes around the “Love
her” quotation to single quotes and insert a closing double quote.
Page 56, verse 7, note zero, point I, apply RC to “Divine.” Verse 7, note 4,
point 3, a typesetting issue (extra ink) next to “is vain.”
Page 57, verse 11, note one, add right double quote after “faith.”
Page 58, verse 13, note zero, capitalise new sentence “The word was
given.”
Page 60, lesson, point III 3, add right double quote after
“righteousness” and remove right double quote after “just.”
Page 61, verse 18, note two, use three period ellipsis.
Page 62, verse 18, note two, set the word “joy” in Italic to match
“knowledge” and “holiness”; use four period ellipsis after “practical
godliness.” Title, change “chap. II. 1—8” to “chap. ii. 1–5.”
Page 64, verse 23, note one, add point “2“ at “Victual this fort.”
Page 67, Critical Notes, chapter v., add “4” before “Wormwood.” Verses
6, 14, and 16, capitalise “Authorised Version.”
Page 69, lesson, point II 3, change “breaketh one edge” to “breaketh one
hedge.” Point III 3, apply RC to “His.”
Page 71, verse 12, note zero, add right double quote after “converted”;
change “has not repented” to “hast not repented” for consistency with
“hast long known Christ.” Verses 11, 12, note one, point III has an odd
structure in the original: there are two points “(1)” each followed by a
point “2.” The Transcriber changed each “2” to a “(2).”
The break between pages 71 and 72 is in the word “interpreters”:
inter|preters.
Page 73, lesson, copy missing title from TOC.
Page 75, Critical Notes, chapter vi., verse 11, add right double quote after
“shield.” Format “16” in bold; add right double quote after
“illustrations.” Change the “22” that appears after verse 30 to “32” and
format it bold.
Page 76, lesson, point II 2, add right double quote after “eyelids.”
Page 78, verse 3, note two, add right double quote after “sin.”
Page 79, lesson, point I 2, change “to Him” to lower-case, referring to a
person.
Page 80, notes, change “Verse 5” to “Verse 6” and “Verse 6 to 8” to
“Verses 6 to 8.”
Page 82, lesson, point I shows subpoints 2, 3, and 4. The Transcriber
added point “1” and set the next sentence in Italic; set the sentence for
subpoint 2 in Italic.
Page 83, lesson, point II 1, change “lay in wait” to “lie in wait.” Point II 3,
change a comma after “ruin” to a period; change “Ps. xxxi. 5” to “Ps.
xxxi. 5, 6”; change periods after “proud look” and “lying tongue” to
question marks.
Page 84, notes, spell out “Ver. 12” and “Ver. 13.” Verse 14, note one, add
final period before credit. Note three, change “there” to “their.”
Page 86, title, change homiletic cross references to “i. 7–9” from “i. 8”
and “iv. 1–4” from “iv. 1.”
Page 88, notes, remove em-dash after “Verse 23.” Note two, capitalise
“Vulgate.”
Page 89, title, change “A Special Sin and its Penalties from the He who
kept God’s Law will be kept” to capitalise “Its,” “Which,” “Who,”
“Keeps,” “Will,” “Be,” and “Kept.” Lesson, point I, change “lays in wait”
to “lies in wait”; change reference from “verse 25” to “verse 26.”
Parenthetical at end of point III, move period inside right parentheses.
Page 90, point IV, change “Father” to “father,” referring to Paul.
Page 91, verses 27 and 28, note one, change point (4) to bring the word
“the” before the point; add a final period to this note before the credit.
Page 92, Critical Notes, chapter vii., add the words “Critical Notes.”
Notes on the “Strange Woman”: first paragraph, in the Wordsworth
quote, change double quotes around “Strange Woman” to single quotes,
and use a three period ellipsis. In the Hengstenberg quote, use a three
period ellipsis after “Wisdom”; change double quotes to single quotes
around “the mouth” quote and “the woman Jezebel.” Add right double
quotes after “symbolical person.” Second paragraph (continues to
following page), change double quotes to single quotes throughout and
insert a closing double quote at the end of the paragraph.
Page 93, lesson, point IV, apply RC to “Word.”
Page 95, title and first note, change “6–37” to “5–27.”
Page 96, verse 5, note two, move period inside parenthesised reference.
Page 97, verse 14, note two, move period for parenthetical to inside the
parentheses. Verse 14, note three, point 2, move period for
parenthetical to inside the parentheses; point 3, change period after
“ceremonies of religion” to a question mark.
Page 98, verse 19, note two, change “at home rather” to “at home either.”
Page 99, note zero, use a four period ellipsis. Critical Notes, chapter
viii., verse 21, capitalise “Authorised Version.” Verse 23, capitalise
“Authorised.”
Page 100, notes on personification, remove point “1” as a singleton.
Correct the “Deut. xxxii. 6” reference by changing the comma after the
chapter number to a period. In the Fausset quotation, change the
double quotes around “brought forth” to single.
Page 101, remove the period after point “(5)” for consistency. Punctuate
the Harris quotation as if it is part of the Aiken quotation.
Page 102, lesson, point I, add right double quote after “was lost.” Point
III, change “let Him come” to lower-case. Verse 1, note two, apply RC to
“Word.”
Page 103, title, change “God’s Speech meeting Man’s Need” to capitalise
“Meeting.”
Page 104, lesson, point I, apply RC to “His”; add right double quotes
after “pit” and after “abundantly.”
Page 105, verse 4, note one, point I, change “eyery” to “every.”
Page 106, verse 9, note one, add right double quote after “red”; add right
parenthesis after reference.
Page 107, title, change “Wisdom better than Wealth” to capitalise
“Better” and “Than.” Point II, add period after “chap.”
Page 109, verse 11, note one, set the sentence after point 5 in Italic, for
consistency.
Page 110, verse 12, note one, change “verse 22–30” to “verses.”
Page 111, verse 13, note six, apply RC to “Spirit.”
Page 113, verses 15, 16, note one, change “who use to keep” to “who used
to keep.” Note two, apply RC to “Divine.” Note five, change “(1)” to “1.”
and capitalise the next word, for consistency.
Page 114, lesson, point II, change “unforseen” to “unforeseen.” Point III,
change “(1.)” to “1.” for consistency. Change reference to “vers. 11, 12” to
“vers. 10, 11” and move the period inside the parentheses.
Page 115, verse 17, note one, move a comma outside the parentheses.
Note two, point (3), apply RC to “Spirit.” Note three, change “(1)” to “1.”
and capitalise the next word, for consistency. Verse 20, note one, point
1, apply RC to “Word”; point 2, apply RC to “Spirit” (thrice).
Page 124, verses 30–36, note one, add a comma to “beginning the.”
Critical Notes, chapter ix., verse 2, capitalise “Orientals.”
Page 125, lesson, point I, change “Exod. xx, ii” to “Exod. xx. 2.”
Page 127, lesson, point X, add left double quotes before “if thou.”
Page 130, verse 2, note four, change “sweatmeats” to “sweetmeats.”
Page 131, verse 5, note zero, capitalise “Negro”; apply RC to “Him.”
Page 132, verse 9, note one, change “1.” to “(1)” for consistency. Verse 12,
note two, apply RC to “His.”
Page 133, lesson, point I 2, add right double quote after “hell.”
Page 136, verse 18, note two, change “damned” to “dammed.”
Page 137, Critical Notes, chapter x., verse 4, add right double quote after
“worketh.” Verses 6 and 22, capitalise “Authorised Version.” Verse 29,
add right double quote after “iniquity.”
Page 138, lesson, point I, change “(2)” to “2.” and capitalise the next
word, for consistency.
Page 141, lesson, point III 2, apply RC to “Spirit” (thrice). Fourth note,
point II, change “slily” to “slyly”; add a right double quote after “belly.”
The break between pages 141 and 142 is in the word “unrighteous”:
un|righteous.
Page 142, note zero, point III 2, capitalise “New Jerusalem.”
Page 143, lesson, point II, add period after “rule.”
Page 145, verse 4, note five, point 1, change “industrous” to
“industrious.”
Page 148, note one, change “occasioned offered” to “occasion offered.”
Note four, points I 1 and II 1, apply RC to “Gospel.”
Page 149, lesson, point III 1, add double quotes before “for” and after
“sake.”
Page 152, lesson, point II, add right double quote after “eater”; remove
right double quote after “fruit.”
Page 153, note zero, apply RC to “His.”
Page 155, verse 9, note four, in-line note about inspiration.
Page 156, lesson, introduction, apply RC to “Divine.”
Page 158, lesson, point I, remove point “1.” as a singleton.
Page 159, lesson, point IV, change the cross reference from “i. 12” to
“i. 10–19.”
Page 161, lesson, point II, add right double quote after “Him.”
Page 162, lesson, point III (2), remove right double quote after “made”;
change the double quotes around “ruined” and the final line to single
quotes, add double quotes at the end of the paragraph. Verse 15, note
four, add double quotes around the word “destruction.”
Page 163, verse 15, note zero, use four period ellipsis.
Page 164, title, change “Verse 18” to “Verse 17.”
Page 166, lesson, point III, change “agains” to “against.”
Page 167, note one, change “clamourous” to “clamorous.” Note two,
point 3, use four period ellipsis.
Page 169, lesson, point III, add right double quote after “judgment.”
Verse 19, note two, capitalise “Christian.” Note three, add right double
quote after “silent.”
Page 171, note two, point III, point 1 after “Observe,” change “to do
harm” to “to do no harm.”
Page 172, verse 21, note one, change “Cant. iii. 2” to “Cant. iv. 11.” Lesson,
point I, add right double quote after “bands.”
Page 173, lesson, point II, use three period ellipses after “because” and
“judgment.”
Page 174, lesson, point I, change “tell” to “tells.”
Page 176, lesson, point IV 3, apply RC to “Spirit.”
Page 179, note two, change “do not correct” to “does not correct” and
“refresh the desert” to “refreshes the desert.”
Page 181, lesson, point II, apply RC to “Spirit.”
Page 183, note zero, point II, change “insuportable” to “insupportable.”
Page 185, lesson, point II, add right double quote after “Godhead.”
Page 186, lesson, point II, change question mark after “away” to a
period; apply RC to “Him”; and change the double quotes around the
“loved darkness” and “I will not have” quotations to single quotes.
Page 188, lesson, point II, change cross reference to lower-case. Remove
parentheses from the cross reference for verse 31; split the list of four
verse numbers into two links, word “and” inserted.
Page 190, Critical Notes, chapter xi., verse 14, change “steermanship” to
“steersmanship.” Verse 17, capitalise “Authorised Version.” Verse 25, add
a period after “seeketh” and a right double quote after “pleasing.”
Page 192, note two, change “Melancthon” to “Melanchthon.” Note three,
remove right double quote after “Jehovah.”
Page 193, lesson, point I, use three period ellipsis after “thoughts.”
Page 195, note one, add a period after “prince” and capitalise next word.
Note three, add closing quote after “prudent.”
Page 196, lesson, point II, add right double quote after “man.”
Page 197, illustration, capitalise “Nereids.” Note one, change period
after “paths” to a question mark.
Page 198, note two, change “towards Him” to “toward Him.”
Page 200, verse 4, note one, add a left double quote before “from.” Spell
out “Ver. 5.” Note three, change point “III” to point “II.” Spell out “Ver.
6.” Note one, apply RC to “Divine.”
Page 202, note one, use three period ellipsis after “expects.”
Page 206, title, change “The Fate of the Unrighteous one” to capitalise
“One.”
Page 207, lesson, point II, change “develope” to “develop”; a right
double quote after “God is.” Point III, change “Isa. lx. 18” to “Isa. lx. 17–
18.”
Page 209, Foulon illustration, in the first sentence, there is a four word
appellation in French: the Italic formatting ends after three words. All
four were tagged as French. The first instance of “Hôtel-de-Ville” was
accented like the second one. Change “Sansculottism” to “Sans-
culottism.” Note two, use four period ellipsis.
Page 211, title, change “Contempt and Tale-bearing” to capitalise
“Bearing.” Lesson, point II, add a period after “made known.”
Page 212, lesson, point III, remove quotation marks. Notes, spell out
“Ver. 12” and “Ver. 13.”
Page 214, lesson, point III, change “Plassy” to “Plassey.”
Page 216, change cross reference for verse 15 from “vi. 1–4” to “vi. 1–5.”
Page 217, lesson, point I 1, change “develope” to “develop.” Point II,
capitalise “Critical Notes.”
Page 219, lesson, point I, change “subtilly” to “subtilely.”
Page 220, lesson, point IV, add right double quote after “mercy”;
capitalise “Richard iii.” and apply Italic formatting as the title of a play.
Page 221, note one, apply RC to “Divine.”
Page 222, note one, in-line comment on “niggardly.” It also refers to
Ecclesiasticus, which is not part of the 66-book canon of scripture. It is
in a Roman Catholic Bible and it can be found on-line. Note two, in the
word “kindness,” the first “n” sort is inverted. Note three, capitalise first
quoted word “He.” Note four, capitalise “Sabbath.” Note five, capitalise
“Good Samaritan.”
Page 223, lesson, point I, change comma after “bane” to a colon.
Page 224, lesson, point I 3, change “a honest man” to “an honest man.”
Point II 1, change cross reference “chap. vii. 1, 4” to “chap vii. 1–4.” Point
II 2, change “1 Isa. ii. 1” to “1 John ii. 1.” Notes, spell out “Ver. 18.”
Page 225, note five, add a period after the initial to “A Clarke.”
The break between pages 225 and 226 is in the word “encumbrances”:
encum|brances.
Page 226, verse 18, note zero, change “Thess. iv. 1” to “1 Thess. iv. 1.” Spell
out “Ver. 19” and “Ver. 20.”
Page 228, lesson, point II, change “naught” to “nought.” Point III,
change “His work” to lower case, referring to men; add right double
quote after “anointed”; change “refuges of lies” to “refuge”; change
“Isaiah xxviii. 18” to “Isaiah xxviii. 17–18”; change “Isaiah liv. 15, 17” to
“Isaiah liv. 15–17.”
Page 229, title, change “Precious things possessed by unworthy owners”
to capitalise “Things,” “Possessed,” “Unworthy,” and “Owners.”
The break between pages 229 and 230 is in the word “himself”:
him|self.
Page 231, copy missing outline title from TOC.
Page 232, verse 23 and chap. x. 24, note one, point II, change points “(1)”
and “(2)” to “1.” and “2.,” respectively, for consistency.
Page 233, note zero, point III, apply RC to “He.” In-line note about
“niggardly.” Lesson, point I, change “that is meet” to “than.” Point I 2,
apply RC to “He”; add “Deut. xv. 11” reference; apply RC to “He.”
Page 234, lesson, point I 4, add double quotes around the James v. 1–3
quotation. Notes, spell out “Vers. 24, 25.” Note one, change final period
to a question mark.
Page 237, lesson, point II, change “chap. viii. 16” to “chap. viii. 17.”
Page 239, lesson, point II 3, replace period after “living God” with right
double quote. Note five, change “pruning himself” to “preening
himself.”
Page 240, lesson, in-line note on “niggardly.” Add “I.”; remove the bold
quotation marks.
Page 242, lesson, point III, apply RC to “Him” (twice).
Page 246, Critical Notes, chapter xii., the name “Zöckler” is spelled
without the accent in these notes and it was transcribed consistently
with other chapters. Verse 9, capitalise “Authorised Version.”
Page 247, lesson, point II, change the period after “born” to a question
mark.
Page 248, verse 1, note five, in-line note on “Hottentot.” Apply RC to
“Gospel.”
Page 249, verse 1, note zero, apply RC to “Spirit.” Change first cross
reference for verse 2 from “chap. iii. 4” to “chap. iii. 1–4.” Notes, spell out
“Ver. 2.” Note one, change “will he done” to “will be done.” Note three,
move right double quote to before the credit from after the credit.
Page 250, verse 2, note one, apply RC to “Gospel.” Title, change “A Right
Desire and the Means of its Attainment” to capitalise “Its.”
Page 254, title, change “Thoughs and Words and their Result” to
capitalise “Their.” Lesson, point I 1, apply RC to “Word”; change “out thy
mouth” to “out of thy mouth” and “thereon” to “therein.”
Page 255, lesson, point IV I 3, add left double quote before “turned.”
Add “II.” before “But for the wicked.”
Page 255, lesson, renumber point “4” as point “2.” Verse 5, note one,
change “whom” to “which.”
Page 257, notes, spell out “Ver. 7.”
Page 258, notes, spell out “Ver. 8.”
Page 259, add missing lesson title from TOC.
Page 260, note two, capitalise “Oriental.”
Page 261, note one, change “Ecclus. x. 30” to “Ecclus. x. 27.” NB,
Ecclesiasticus is not part of the 66-book Canon. It is available in a
Roman Catholic Bible or on-line.
Page 263, note one, capitalise “Authorised Version.”
Page 264, note one, change “worlding” to “worldling.” Note four, add
double quotes around “regard.”
Page 266, lesson, point I 1, apply RC to “Word.” Change the sub-points
of point II from “(1)” to “1.” for consistency with point I.
Page 267, note four, change “transcendantly” to “transcendently.” Add
the missing outline title from the TOC.
Page 268, lesson, renumber the subpoints of point II 2 as “(1)” and “(2).”
In point II 2 (1), change “Jas. v. ii.” to “Jas. v. 11.”
Page 270, verse 13, note three, add a period after “chap.”
Page 273, verse 16, note three, change “Chap.” to “chap.”; change “1 Sam.
xii. 35” to “1 Sam. xx. 34.”
Page 274, lesson, point II, change "Chap. x. 18" to "chap. x. 18."
Page 275, lesson, point III 2, remove right double quotes after “God”;
add right double quotes after “weary”; change “Acts x. 14” to “Acts iv. 12.”
Point IV, change page reference to 190 from 191.
Page 277, verse 18, note two, apply RC to “Spirit.” Verse 19, note four, the
“r” sort of “ever” is not in line. Verse 22, note four, change “2 Cor. 1–17”
to “2 Cor. i. 17.”
Page 278, note after poem, change “2 John i.” to “2 John 1” and “2 John
iii.” to “2 John 3.” Second note after poem, apply RC to “He maketh.”
Lesson, point I, add right double quote after “righteousness.”
Page 280, verse 20, note zero, point 2, apply RC to “God, Who.” Lesson,
add a right double quote just before the credit for the poem.
Page 281, lesson, point II (2), change “2 Tim. iv. 13” to “2 Tim. iii. 13.”
Note three, add right double quotes after “touch him” and “his sin.”
Page 282, same note, move the right double quotes to after “wine” from
within the reference. Change “Heb. v. 8, 11” to “Zech. v. 8, 11.”
The break between pages 282 and 283 is in the word “appearance”:
appear|ance.
Page 284, note one includes a reference to Ecclesiasticus, which is not
in the 66-book Canon. It is available in a Roman Catholic Bible or on-
line, if desired.
Page 286, title, change “Heaviness of Heart and its Cure” to capitalise
“Its.”
Page 287, lesson, point I 2, add right double quote after “thereof.” Point
I 3, change “Psa. xxii. 3” to “Psa. xxxii. 3.”
Page 288, lesson, point III, tag ignis fatuus as Latin and set it in Italic.
Page 289, note one, add right double quote after “them.” Add missing
lesson title from TOC.
Page 291, verse 27, note zero, add left double quote before “the slothful.”
Add missing lesson title from TOC.
Page 292, homily on whole chapter, point (1), add “vers. 1–11” for
consistency. Add point “(3)” and capitalise next word, for consistency.
Page 293, Critical Notes, chapter xiii., verse 15, Miller’s comment, add
right double quotes after “perpetual.” Verse 19, add left double quotes
before “appeased” and right double quotes after “satisfied.” Lesson,
point III, change “chap. iv. 1, 4” to “chap. iv. 1–4.”
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
Let us accompany you on the journey of exploring knowledge and
personal growth!
ebookultra.com