E-Book, Englisch, 308 Seiten
Weert / Gregoire C++17 Standard Library Quick Reference
2. ed
ISBN: 978-1-4842-4923-9
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
A Pocket Guide to Data Structures, Algorithms, and Functions
E-Book, Englisch, 308 Seiten
ISBN: 978-1-4842-4923-9
Verlag: Apress
Format: PDF
Kopierschutz: 1 - PDF Watermark
This quick reference is a condensed guide to the essential data structures, algorithms, and functions provided by the C++17 Standard Library. It does not explain the C++ language or syntax, but is accessible to anyone with basic C++ knowledge or programming experience. Even the most experienced C++ programmer will learn a thing or two from it and find it a useful memory-aid.
It is hard to remember all the possibilities, details, and intricacies of the vast and growing Standard Library. This handy reference guide is therefore indispensable to any C++ programmer. It offers a condensed, well-structured summary of all essential aspects of the C++ Standard Library. No page-long, repetitive examples or obscure, rarely used features. Instead, everything you need to know and watch out for in practice is outlined in a compact, to-the-point style, interspersed with practical tips and well-chosen, clarifying examples.
This new edition is updated to include all Standard Library changes in C++17, including the new vocabulary types std::string_view, any, optional, and variant; parallel algorithms; the file system library; specialized mathematical functions; and more.
What You Will LearnGain the essentials that the C++ Standard Library has to offerUse containers to efficiently store and retrieve your dataInspect and manipulate your data with algorithms See how lambda expressions allow for elegant use of algorithmsDiscover what the standard string class provides and how to use itWrite localized applicationsWork with file and stream-based I/OPrevent memory leaks with smart pointersWrite safe and efficient multi-threaded code using the threading libraries
Who This Book Is For
All C++ programmers, irrespective of their proficiency with the language or the Standard Library. A secondary audience is developers who are new to C++, but not new to programming, and who want to learn more about the C++ Standard Library in a quick, condensed manner.
Marc Gregoire is a software engineer from Belgium. He graduated from the University of Leuven, Belgium, with a degree in 'Burgerlijk ingenieur in de computer wetenschappen' (equivalent to Master of Science in engineering in computer science). The year after, he received the cum laude degree of master in artificial intelligence at the same university. After his studies, Marc started working for a software consultancy company called Ordina Belgium. As a consultant, he worked for Siemens and Nokia Siemens Networks on critical 2G and 3G software running on Solaris for telecom operators. This required working in international teams stretching from South America and USA to EMEA and Asia. Now, Marc is working for Nikon Metrology on industrial 3D laser scanning software. His main expertise is C/C++, and specifically Microsoft VC++ and the MFC framework. He has experience in developing C++ programs running 24x7 on Windows and Linux platforms; for example, KNX/EIB home automation software. Next to C/C++, Marc also likes C# and uses PHP for creating web pages. Since April 2007, he received the yearly Microsoft MVP (Most Valuable Professional) award for his Visual C++ expertise. Marc is the founder of the Belgian C++ Users Group, author of Professional C++ and a member on the CodeGuru forum (as Marc G). Peter Van Weert is a Belgian software engineer, whose main interests and expertise are programming languages, algorithms, and data structures. He received his master of science in computer science summa cum laude with congratulations of the Board of Examiners from the University of Leuven. In 2010, he completed his PhD thesis on the design and efficient compilation of rule based programming languages at the declarative programming languages and artificial intelligence department of the same university. During his doctoral studies, he was a teaching assistant for object-oriented programming (Java), software analysis and design, and declarative programming. After graduating, Peter joined Nikon Metrology to work on large-scale, industrial application software in the area of 3D laser scanning and point cloud inspection. At Nikon, he has mastered C++, refactoring and debugging very large code bases, and has gained further proficiency in all aspects of the software development process, including the analysis of functional and technical requirements, and agile and scrum-based project and team management. In his spare time, he has co-authored two award-winning Windows 8 apps, and is a regular speaker at and board member of the Belgian C++ Users Group.
Autoren/Hrsg.
Weitere Infos & Material
1;Contents;5
2;About the Authors;15
3;About the Technical Reviewer;17
4;Introduction;18
5;Chapter 1: Numerics and Math;23
5.1;Common Mathematical Functions;23
5.1.1;Basic Functions;23
5.1.2;Exponential and Logarithmic Functions;24
5.1.3;Power Functions;24
5.1.4;Trigonometric and Hyperbolic Functions;25
5.1.5;Integral Rounding of Floating-Point Numbers;25
5.1.6;Floating-Point Manipulation Functions;25
5.1.7;Classification and Comparison Functions;26
5.1.8;gcd/lcm;26
5.1.9;Error Handling;27
5.2;Special Mathematical Functions;27
5.2.1;Bessel Functions;28
5.2.2;Polynomials;29
5.2.3;Elliptic Integrals;29
5.2.4;Exponential Integrals;30
5.2.5;Error Functions;30
5.2.6;Gamma Functions;30
5.2.7;Beta Functions;31
5.2.8;Zeta Functions;31
5.3;Minimum, Maximum, and Clamping;31
5.4;Fixed-Width Integer Types;32
5.5;Arithmetic Type Properties;33
5.6;Complex Numbers;35
5.7;Compile-Time Rational Numbers;36
5.8;Random Numbers;37
5.8.1;Random Number Generators;37
5.8.1.1;Pseudorandom Number Engines;38
5.8.1.1.1;Engine Adaptors;38
5.8.1.1.2;Predefined Engines;39
5.8.1.2;Nondeterministic Random Number Generator;40
5.8.1.3;Seeding;40
5.8.2;Random Number Distributions;40
5.8.2.1;Uniform Distributions;41
5.8.2.2;Bernoulli Distributions;41
5.8.2.3;Normal Distributions;41
5.8.2.4;Poisson Distributions;42
5.8.2.5;Sampling Distributions;42
5.8.2.5.1;Discrete Distribution;42
5.8.2.5.2;Piecewise Constant Distribution;43
5.8.2.5.3;Piecewise Linear Distribution;44
5.8.2.5.4;Example;44
5.9;Numeric Arrays;45
5.9.1;std::slice;46
5.9.2;std::gslice;47
5.9.3;std::mask_array;48
5.9.4;std::indirect_array;49
6;Chapter 2: General Utilities;50
6.1;Moving, Forwarding, Swapping;50
6.1.1;Moving;50
6.1.2;Forwarding;52
6.1.3;Swapping and Exchanging;53
6.2;Pairs and Tuples;54
6.2.1;Pairs;54
6.2.2;Tuples;55
6.3;std::byte;56
6.4;Relational Operators;57
6.5;Smart Pointers;57
6.5.1;Exclusive Ownership Pointers;57
6.5.1.1;std::unique_ptr;57
6.5.1.2;std::auto_ptr;60
6.5.2;Shared Ownership Pointers;60
6.5.2.1;std::shared_ptr;60
6.5.2.2;std::weak_ptr;62
6.5.2.3;std::enable_shared_from_this;62
6.6;Function Objects;63
6.6.1;Reference Wrappers;64
6.6.2;Predefined Functors;64
6.6.3;Binding Function Arguments;65
6.6.4;Negating a Callable;66
6.6.5;Generic Function Wrappers;66
6.6.6;Functors for Class Members;67
6.7;Initializer Lists;68
6.8;Vocabulary Types;69
6.8.1;std::optional;69
6.8.1.1;std::nullopt_t;69
6.8.1.2;Constructors;70
6.8.1.3;Methods and Non-member Functions;71
6.8.2;std::variant;71
6.8.2.1;Construction;72
6.8.2.1.1;Default Construction;72
6.8.2.1.2;Constructors;72
6.8.2.2;Methods and Non-member Functions;73
6.8.2.3;Example Usage;74
6.8.2.4;Visitation;74
6.8.2.5;Helper Classes;75
6.8.3;std::any;76
6.8.3.1;Constructors;76
6.8.3.2;Methods and Non-member Functions;76
6.8.3.3;Example Usage;77
6.9;Date and Time Utilities;77
6.9.1;Durations;78
6.9.2;Time Points;79
6.9.3;Clocks;80
6.9.4;C-Style Date and Time Utilities;81
6.10;Type Utilities;83
6.10.1;Runtime Type Identification, ;83
6.10.2;Type Traits;84
6.10.2.1;Helper Classes;84
6.10.2.2;Type Classification;85
6.10.2.3;Type Properties;86
6.10.2.4;Type Relationships;87
6.10.2.5;Type Property Queries;87
6.10.2.6;Type Transformations;88
6.10.2.7;SFINAE Templates;89
6.10.2.7.1;std::enable_if;89
6.10.2.7.2;std::void_t;90
6.10.2.8;Function Invocation Traits;90
6.10.2.9;Trait Operations;91
6.10.3;Type Operations;91
6.10.3.1;std::declval;91
6.10.3.2;std::as_const;92
6.11;Generic Utilities;92
6.11.1;std::invoke;92
6.11.2;std::addressof;93
7;Chapter 3: Containers;94
7.1;Iterators;94
7.1.1;Iterator Tags;95
7.1.2;Non-member Functions to Get Iterators;96
7.1.3;Non-member Operations on Iterators;97
7.2;Sequential Containers;97
7.2.1;std::vector;97
7.2.1.1;Construction;98
7.2.1.2;Accessing Elements;98
7.2.1.3;Iterators;99
7.2.1.4;Adding Elements;99
7.2.1.5;Size and Capacity;101
7.2.1.6;Removing Elements;101
7.2.1.7;Remove-Erase Idiom;102
7.2.1.8;std::vector;103
7.2.1.9;Complexity;103
7.2.2;std::deque;104
7.2.2.1;Complexity;104
7.2.3;std::array;105
7.2.3.1;Complexity;105
7.2.4;std::list and std::forward_list, ;105
7.2.4.1;Complexity;106
7.2.4.2;List-Specific Algorithms;106
7.2.5;Sequential Containers Reference;107
7.2.5.1;Iterators;107
7.2.5.2;Size and Capacity;108
7.2.5.3;Access;108
7.2.5.4;Modifiers;109
7.2.5.5;Non-member Functions;110
7.3;std::bitset;110
7.3.1;Complexity;111
7.3.2;Reference;111
7.3.2.1;Access;111
7.3.2.2;Operations;111
7.4;Container Adaptors;112
7.4.1;std::queue;112
7.4.2;std::priority_queue;112
7.4.3;std::stack;113
7.4.4;Example;113
7.4.5;Reference;114
7.5;Ordered Associative Containers;114
7.5.1;std::map;115
7.5.2;Inserting in a Map;116
7.5.2.1;The Square Brackets Operator;116
7.5.2.2;insert() and insert_or_assign();116
7.5.2.3;emplace() and try_emplace();117
7.5.2.4;Hints;118
7.5.2.5;Return Values;118
7.5.3;std::multimap;119
7.5.4;std::set and std::multiset;119
7.5.5;Order of Elements;119
7.5.6;Searching;120
7.5.7;Moving Nodes Between Containers;121
7.5.8;Merging Containers;121
7.5.9;Complexity;122
7.5.10;Reference;122
7.5.10.1;Iterators;122
7.5.10.2;Size;122
7.5.10.3;Access and Lookup;123
7.5.10.4;Modifiers;123
7.5.10.5;Observers;124
7.5.10.6;Non-member Functions;124
7.6;Unordered Associative Containers , ;124
7.6.1;Hash Map;125
7.6.2;Template Type Parameters;125
7.6.3;Hash Functions;125
7.6.4;Complexity;127
7.6.5;Reference;127
7.6.5.1;Observers;127
7.6.5.2;Bucket Interface;128
7.6.5.3;Hash Policy;128
7.6.5.4;Non-member Functions;128
7.7;Allocators;129
7.7.1;Polymorphic Allocators;129
7.7.1.1;Type Aliases;130
7.7.1.2;Monotonic Buffers;130
7.7.1.3;Memory Pools;131
7.7.2;Allocators for Multilevel Containers;132
8;Chapter 4: Algorithms;133
8.1;Input and Output Iterators;133
8.2;General Guidelines;134
8.2.1;Algorithm Arguments;134
8.3;Terminology;135
8.4;Algorithms;135
8.4.1;Applying a Function to a Range;135
8.4.1.1;Example;136
8.4.2;Checking for the Presence of Elements;137
8.4.2.1;Example;137
8.4.3;Finding Elements;137
8.4.3.1;Example;138
8.4.4;Finding Min/Max Elements;138
8.4.5;Binary Search;139
8.4.5.1;Example;139
8.4.6;Subsequence Search;140
8.4.6.1;Example;141
8.4.7;Sequence Comparison;141
8.4.8;Generating Sequences;142
8.4.8.1;Example;143
8.4.9;Copy, Move, Swap;143
8.4.9.1;Example;144
8.4.10;Removing and Replacing;144
8.4.10.1;Example;145
8.4.11;Reversing and Rotating;145
8.4.11.1;Example;146
8.4.12;Partitioning;146
8.4.13;Sorting;147
8.4.13.1;Example;148
8.4.14;Sampling and Shuffling;148
8.4.14.1;Example;149
8.4.15;Operations on Sorted Ranges;149
8.4.16;Permutation;150
8.4.17;Heaps;151
8.5;Numeric Algorithms;152
8.5.1;Reductions;152
8.5.1.1;Example;153
8.5.2;Inner Products;153
8.5.2.1;Example;153
8.5.3;Prefix Sums;154
8.5.4;Element Differences;155
8.6;Algorithms for Uninitialized Memory;155
8.7;Parallel Algorithms;156
8.7.1;Parallel Execution;157
8.7.2;Parallel Unsequenced Execution;158
8.8;Iterator Adaptors;158
9;Chapter 5: Input/Output;160
9.1;Input/Output with Streams;160
9.1.1;Helper Types;161
9.1.2;Formatting Methods (std::ios_base);162
9.1.3;I/O Manipulators, ;164
9.1.4;Example;165
9.1.5;std::ios;166
9.1.5.1;Stream State;166
9.1.5.2;Error Handling;167
9.1.5.3;Other Methods;168
9.1.6;std::ostream;168
9.1.6.1;I/O Manipulators;169
9.1.6.2;Global Output Streams;169
9.1.6.3;Example;170
9.1.7;std::istream;170
9.1.7.1;I/O Manipulators;171
9.1.7.2;Global Input Streams;171
9.1.7.3;Example;172
9.1.8;std::iostream;172
9.2;String Streams;172
9.2.1;Example;173
9.3;File Streams;174
9.3.1;Example;175
9.4;Streaming Custom Types;175
9.4.1;Custom << and >> Operators;175
9.4.2;Custom I/O Manipulators;176
9.4.2.1;Example;178
9.5;Stream Iterators;179
9.5.1;std::ostream_iterator;179
9.5.2;std::istream_iterator;179
9.6;Stream Buffers;180
9.7;File Systems;181
9.7.1;Files, Paths, and Pathnames;181
9.7.2;Error Reporting;182
9.7.3;The path Class;183
9.7.3.1;Construction and Assignment;183
9.7.3.2;Conversion to Strings;184
9.7.3.3;Decomposition;184
9.7.3.4;Composition;186
9.7.3.5;Modification;187
9.7.4;File Links;187
9.7.5;Path Normalization;188
9.7.6;The Current Working Directory;189
9.7.7;Absolute and Relative Paths;189
9.7.8;Comparing Paths;191
9.7.9;File Status;191
9.7.9.1;File Types;192
9.7.9.2;File Permissions;193
9.7.10;Creating, Copying, Deleting, and Renaming;195
9.7.11;File Sizes and Free Space;196
9.7.12;Directory Listing;197
9.8;C-Style File Utilities;199
9.9;C-Style Output and Input;200
9.9.1;std::printf() Family;200
9.9.1.1;Example;204
9.9.2;std::scanf() Family;204
9.9.2.1;Example;206
10;Chapter 6: Characters and Strings;207
10.1;Strings;207
10.1.1;Searching in Strings;208
10.1.2;Modifying Strings;209
10.1.3;Constructing Strings;210
10.1.4;String Length;210
10.1.5;Copying (Sub)Strings;211
10.1.6;Comparing Strings;211
10.2;String Views;212
10.3;Character Classification, ;213
10.4;Character-Encoding Conversion, ;215
10.5;Localization;218
10.5.1;Locale Names;218
10.5.2;The Global Locale;219
10.5.3;Basic std::locale Members;220
10.5.4;Locale Facets;220
10.5.4.1;Numeric Formatting;221
10.5.4.1.1;Numeric Punctuation;221
10.5.4.1.2;Formatting and Parsing of Numeric Values;222
10.5.4.2;Monetary Formatting;222
10.5.4.2.1;Monetary Punctuation;222
10.5.4.2.2;Formatting and Parsing of Monetary Values;223
10.5.4.3;Time and Date Formatting;224
10.5.4.4;Character Classification, Transformation, and Conversion;225
10.5.4.4.1;Character Classification and Transformation;225
10.5.4.4.2;Character-Encoding Conversions;226
10.5.4.5;String Ordering and Hashing;226
10.5.4.6;Message Retrieval;227
10.5.5;Combining and Customizing Locales;228
10.5.5.1;Combining Facets;228
10.5.5.2;Custom Facets;229
10.5.6;C Locales;231
10.6;Regular Expressions;232
10.6.1;The ECMAScript Regular Expression Grammar;232
10.6.1.1;Character Classes;233
10.6.1.2;Greedy vs. Non-greedy Quantification;234
10.6.2;Regular Expression Objects;234
10.6.2.1;Construction and Syntax Options;234
10.6.2.2;Basic Member Functions;235
10.6.3;Matching and Searching Patterns;236
10.6.3.1;Match Results;237
10.6.3.1.1;std::sub_match;237
10.6.3.1.2;std::match_results;238
10.6.3.2;Example;239
10.6.4;Match Iterators;239
10.6.4.1;Tokenizing;240
10.6.5;Replacing Patterns;241
10.7;Numeric Conversions;244
10.7.1;Convenient Conversion Functions;245
10.7.1.1;Parsing Integers;245
10.7.1.2;Parsing Floating-Point Numbers;246
10.7.1.3;Error Reporting and Number Formatting;246
10.7.2;High-Performance Conversion Functions;247
11;Chapter 7: Concurrency;249
11.1;Threads;249
11.1.1;Launching a New Thread;249
11.1.2;A Thread’s Lifetime;250
11.1.3;Thread Identifiers;250
11.1.4;Utility Functions;251
11.1.5;Exceptions;251
11.2;Futures;252
11.2.1;Return Objects;252
11.2.2;Providers;253
11.2.2.1;Async;253
11.2.2.2;Packaged Tasks;254
11.2.2.3;Promises;255
11.2.3;Exceptions;255
11.3;Mutual Exclusion;256
11.3.1;Mutexes and Locks;256
11.3.1.1;Example;257
11.3.2;Mutex Types;257
11.3.2.1;Common Functionality;258
11.3.2.2;Recursion;258
11.3.2.3;Timeouts;258
11.3.2.4;Sharing Ownership;258
11.3.3;Lock Types;259
11.3.3.1;std::scoped_lock;259
11.3.3.2;std::unique_lock;260
11.3.3.3;std::shared_lock;261
11.3.4;Locking Multiple Mutexes;262
11.3.5;Exceptions;262
11.4;Calling a Function Once;263
11.5;Condition Variables;264
11.5.1;Waiting for a Condition;264
11.5.2;Notification;265
11.5.3;Exceptions;266
11.6;L1 Data Cache Line Size;266
11.7;Synchronization;267
11.8;Atomic Operations;268
11.8.1;Atomic Variables;268
11.8.1.1;Template Specializations and Type Aliases;269
11.8.1.2;Basic Atomic Operations;269
11.8.1.3;Atomic Exchange of Values;270
11.8.1.4;Lock-Free Atomic Operations;271
11.8.1.5;Atomic Operations for Integral and Pointer Types;272
11.8.1.6;Synchronization;272
11.8.2;Atomic Flags;273
11.8.3;Non-member Functions and Macros;273
11.8.4;Fences;273
12;Chapter 8: Diagnostics;274
12.1;Assertions;274
12.2;Exceptions, ;275
12.3;Exception Pointers;276
12.4;Nested Exceptions;277
12.5;System Errors;279
12.5.1;std::error_category;280
12.5.2;std::error_code;280
12.5.3;std::error_condition;281
12.6;C Error Numbers;281
12.7;Failure Handling;282
12.7.1;std::uncaught_exceptions();282
12.7.2;std::terminate();283
13;Appendix: Standard Library Headers;287
13.1;Numerics and Math (Chapter 1);287
13.2;General Utilities (Chapter 2);288
13.3;Containers (Chapter 3);289
13.4;Algorithms (Chapter 4);290
13.5;Input/Output (Chapter 5);290
13.6;Characters and Strings (Chapter 6);291
13.7;Concurrency (Chapter 7);292
13.8;Diagnostics (Chapter 8);293
13.9;The C Standard Library;293
14;Index;294




