professional_c_plus_plus_index

Professional C++ Index

Symbols

A

is-permutation(), 600 next-permutation(), 600 prev-permutation(), 600 range-based, 617–619 resources, 1196–1197 scan algorithms, 760 search adjacent_find(), 592 find(), 592 find_end(), 592 find_first_of(), 592 find_if(), 592 find_if_not(), 592 search(), 592 search_n(), 592 sequence algorithms modifying, 737–747 non-modifying, 731–737 set about, 752–755 includes(), 597 inplace:merge(), 597 merge(), 597 set_difference(), 598 set_intersection(), 598 set_symmetric_difference(), 598 set_union(), 598 sorting about, 750–751 is_sorted(), 596 is_sorted_until(), 596 nth-element(), 596 partial_sort(), 597 partial_sort_copy(), 597 sort(), 597 stable_sort(), 597 Standard Library, 574, 591–600 std:list(), 618 std:sort(), 617 swap iter_swap(), 527 swap_ranges(), 527 writing, 836–837

architecture, crossplatform development and address sizes, 1140 binary compatibility, 1139–1140 byte order, 1140–1141 integer size, 1138–1139

assign() method, 635 assignment operators about, 289–295 copy, 280 declaring, 278 defaulted, explicit, 280 defining, 278–279 deleted, explicit, 280 move about, 295, 297–299 objects, as return values, 280–281 swap() function, 300–301 associative arrays, 587 associativity, 545–546 at() function, 424 atan2() function, 577 <atomic> header atomic operations, 931–932 atomic types, 929–931, 933–935 references, 932–933 smart pointers, 932 variables, 935–936 attributes deprecated, 32–33 fallthrough, 25 maybe_unused, 31–32, 911 nodiscard, 31, 129 noreturn, 32, 927 auto keyword, 72–74 auto operator, 560 automatic variables, 212 auto_ptr, 245–246

B

bad() method, 470–471 barriers, 951 base classes about, 177, 338, 361–362 ambiguous, 369–370 virtual, 370, 389–390 base() method, 614 begin() function, 607 behaviors, 172 Bessel functions, 577 beta functions, 577 bidirectional streams, 488–489 big-endian ordering of bytes, 1141 binary logical operators, overloading, 548–549 binary operators, 16 binary_search() algorithm, 597, 751–752 bind() negator adaptor, 710–712 binding dynamic, 347 early, 346 late, 347 method hiding and, 346 static, 346 bitset container, 588, 590, 693–697 bitwise copying, 289 bitwise function objects, 709 bitwise operators, overloading, 548–549 black-box testing, 1021–1022 Boehm, Barry W., 975 boolalpha input manipulator, 480 boolalpha output manipulator, 471 boyer_moore_horspool_searcher algorithm, 733 boyer_moore_searcher algorithm, 733 bridge pattern, 330–331 buffered streams, 466, 469–470 bugs. See also debugging avoiding bugs, 1046–1047 Bugzilla, 1024 life cycle, 1022–1023 root causes, 1046 tracking, 1023–1025 byte order, 1140–1141 C C++ resources, 1191–1192 C++11, resources, 1196 C++14, resources, 1196 C++17, resources, 1196 C++20, resources, 1196 cache lines, 920 callbacks, 728, 730–731 calling member functions, 712–713 casting about, 358–359 casting variables, 15–16 pointers and, 224 casts const_cast(), 394 dynamic_cast(), 393–394 reinterpret_cast(), 391–392 static_cast(), 390–391, 394 std:bit_cast(), 392–393 catch exceptions, object handling and, 998 catching exceptions about, 499–501, 1088 in class hierarchy, 510–511 const reference, 502–503 multiple, 503–505 cbegin() function, 607 ceil() function, 577, 797 cend() function, 607 cerr stream, 467 chain of responsibility pattern, 1129–1131 chaining constructors, 354 character classification, localization and, 769 character sets about, 764 non-Western, 765–767 character types, 766 Chrono library clocks, 801–802 date, 804–807 durations, 796–800 time points, 802–804 time zone, 807 cin stream, 466 clamp() algorithm, 598 class constants, 316–317 class methods, type constraints and, 461–462 class templates about, 582 alias templates, 447 compiler and instantiation, 431–432 types and, 432 definitions in header files, 432–433 in source files, 433 deriving from, 445–446 inheritance, 445–446 instantiation, 426, 430–431 parameters about, 433 deduction for constructors, 436–438 default values, 436 non-type parameters, 434–436 type constraints and, 461 writing coding without templates, 423–426 Grid class, 426–431 Grid template, 430–431 classes about, 170–171 abstract, 362 access specifiers, 251–252 base about, 338, 361–362 ambiguous, 369–370 virtual, 370 constructors, 251 data members, 250, 251 declarations, ordering, 252–253 defining constructor initializer, 42 constructors, 42–44 data members, 41–42 destructors, 42–44 methods, 41–42 definitions, 250–253 derived about, 338–341, 363–364 functionality, 351–353 parent constructors, 353–354 parent destructors, 355–356 deriving from existing, 1086 destructors, 251 exceptions, writing, 512–516 friends, 284–285 Grid, 426–431 hierarchies, catching exceptions, 510–511 high_resolution_clock, 802 Impl, 332 implement class, 330–334 instances, 171, 251 interface class, 330–334 interviews, 1174–1177 istream_iterator, 611–612 Logger, 105–10521 member functions, 251 member variables, 251 members, 251, 254 methods, 251 mixin, 184–185 nested, 318–319 opaque, 190 ostream_iterator, 610–611 over-classification, 173–174 pair, 669–670 parent, 338 reference:wrapper, 629 rule of zero, 305–306 std::ostringstream, 482 string, 575–576 string_view, 575–576 superclasses, 338 system_clock, 801 template classes, 1090 time_point, 801, 802–804 types, enumerated, 319–320 using, 44 writing, 1084–1086 cleanup() function, 301 clocks high_resolution_clock class, 802 system_clock class, 801 time_point class, 801, 802–804 clog stream, 467 clone() method, 423 code compiled, 5 decomposition, 122–124 reuse advantages, 147–148 APIs, 147 big-O notation, 150–152 capabilities, 149–150 design, 191–193 design-by-contract, 195 disadvantages, 148–149 error checking, 195 extensibility and, 196–198 frameworks, 146 libraries, 146 licensing and, 153–154 open-source libraries, 155–157 performance and, 150–153 platforms and, 153 versus polymorphism, 178 postconditions, 195 preconditions, 195 prototypes, 154–155 resources, 154 safe code, 195–196 SRP (Single Responsibility Principle), 191–192 stand-alone classes, 146 stand-alone functions, 146 Standard Library, 157 support and, 154 templates, 193–195 types of code, 146–147 writing reusable, 144–145 code points, character sets, 765 coding style. See also design about, 127 challenges, 132 constants, 128 documentation, comments, 112–122 exceptions, custom, 129 formatting curly braces { }, 130–131 parentheses, 131 spaces, 131–132 tabs, 131–132 interviews, 1168–1169 planning, 112 references, 128–129 collections, 172 collisions, 684 comments about, 5 ad hoc, 120–121 complicated code and, 115–116 every line, 117–118 fixed-format, 119–120 meta-information and, 116–117 prefixes, 118–119 self-documenting code, 122 usage explanation, 111–112 comparison algorithms, 592–593, 733–735 comparison function objects, 707–709 comparison operators, overloading, 325–329 compiled code, 5 compiler-generated constructors, 275–276 component interface, 200 components, 171 compound requirements, 456–457 computer architecture, resources, 1200 concatenation, tuples, 828 concepts about, 454 constraints expression, 455–457 predefined standard, 457–458 syntax, 455 type constraints and class methods, 461–462 type constraints and class templates, 461 type constraints and function templates, 458–461 type constraints and template specialization, 462 type-constrained auto, 458 condition variables, 947–950 conditional statements if/else, 23 operator, 25–26 switch, 24–25 <condition_variable> header, 947 console, streams and, 466 const keyword, 55 const methods, 307–308 const reference data members, 317–318 const static data members, 316–317 constant iterators, 605 constants class constants, 316–317 null pointer, 52–53 const_cast(), 68–69, 394, 424 consteval keyword, 57–58 constexpr keyword, 56–57 constrain template parameters, 1090–1091 constrained algorithms, 758 constraints expression, 455–457 constructors about, 259 chaining, 354 compiler-generated, 275–276, 280–281 converting constructors, 365–367 copy, 269–271 default compiler-generated, 263–264 explicitly defaulted, 264–265 explicitly deleted, 264–265 need, 262 writing, 262–263 delegating, 260–261, 273, 291 derived classes, 353–354 error handling, 526–528 on the free store, 260 function-try-blocks, 528–531 inherited, 374–378 initializer-list constructors, 271–272 initializers, 61 move, 297–301 multiple, 260–261 overloading, 260–261 parent, 353–354 on the stack, 260 typed constructors, 365–367 writing, 259 container adapters about, 628 priority_queue, 666–668 queue, 663–666 stack, 668–669 containers Allocator type, 834–835 allocators, 866–871 associative, 628 bitset, 588, 693–697 error checking, 630 hash functions, 684–686 hash map interface deleting elements, 843–845 inserting elements, 842–843 removing elements, 843–845 searching elements, 841–842 swapping elements, 845 hash maps buckets, 684 methods, 850–852 type aliases, 849 hash tables, 628, 684–691 header files, 1205–1206 interfaces about, 582–590 access methods, 858–859 const_directed_graph_iterator class, 852–856 iterators, 606–608, 852 type aliases, 858–859 using, 859–862 ordered associative, 669–684 reversible, 863–864 sequential about, 628 array, 660–661 deque, 653 forwards_list, 657–659 list, 653–657 span, 661–663 standard C-style arrays, 691–692 Standard Library about, 574, 582–590 array, 584, 589 bitset, 590 deque, 584, 589 forward_list, 584, 589 list, 584, 588 map, 587, 590 multimap, 587, 590 multiset, 586–587, 590 priority_queue, 585, 589 queue, 585, 589 set, 586–587, 590 span, 585 stack, 586, 589 unordered_map, 590 unordered_multimap, 590 unordered_multiset, 590 unordered_set, 590 vector, 583, 588, 590 strings, 692–693 unordered associative containers, 587–588, 628, 684–691 writing, 837–875 conversions implicit, 322 localization, 769–771 converting constructors, 365–367 cooked mode literal operators, 570–571 copy() algorithm, 593 copy assignment operator, compiler generated, 280–281 copy constructors, 269–271, 289–295 copy list initialization, 74 copy-and-swap idiom, 1087–1088 copy_backward() algorithm, 593 copy_if() algorithm, 594 copy_n() algorithm, 594 core dumps, 1058 count() algorithm, 593, 736–737 count_if() algorithm, 593, 736–737 counting algorithms, 593, 736–737 cout stream, 466, 468 crash dumps, 1058 crbegin() function, 607 createDocArray() function, 217 cref() function, 629 crend() function, 607 cross-language development C and C++, 1145 C code, 1149–1151 C++ code calling assembly code from, 1159–1160 calling from C#, 1151–1154 calling from Java with JNI, 1154–1156 calling from scripts, 1156–1159 calling scripts from, 1156 facade, 1145 object-oriented wrapper, 1145–1148 cross-platform development architecture and address sizes, 11400 binary compatibility, 1139–1140 byte order, 1140–1141 integer size, 1138–1139 cross-compiling, 114000 implementation compilers and, 1142 library implementations, 1142–1143 platform-specific features, 1143–1144 <cstdint> header, 581 C-style arrays, 691–692 curiously recurring template pattern (CRTP), 1100 cylindrical Neumann functions, 577 D dangling pointers, 234, 289 data members about, 250 moving, 300 mutable, 308 pointers to, 702–705 references, 61 static, 314–316 accessing, 315–316 inline variables, 314–315 data races, 918–919 data structures, resources, 1196–1197 date, 804–807, 1183 day class, 804 deadlocks, multithreaded programming and, 919–920 deallocate() method, 834–835 deallocating memory, 213–215 debugging article citations example, 1067–1079 assertions, 1057–1058 avoiding bugs, 1046–1047 catastrophic bugs, 1046 cosmetic bugs, 1046 crash dumps, 1058 debug traces debug mode, 1049–1053 ring buffers, 1053–1056 debugging reproducible, 1060 error logging and, 1047–1049 interviews, 1187–1188 memory problems about, 1062, 1065–1066 memory-access errors, 1063–1064 memory-freeing errors, 1062–1063 multithreaded programs, 1066–1067 noncatastrophic bugs, 1046 regressions, 1061 reproducing bugs about, 1059–1060 debugging nonreproducible, 1060–1061 resources, 1201 root causes of bugs, 1046 tests, 1038 dec input manipulator, 480 dec output manipulator, 471 declaring functions, 6, 28–30 decltype keyword, 75 decomposing code, 28–29 decomposition modular, 124 refactoring abstraction, 123 breaking code apart, 123 locations, 123 names, 123 decorator pattern, 1126–1128 default arguments, 313–314 default keyword, 265 default_searcher algorithm, 733

  1. define directive, 7

delegating constructors, 260–261, 273, 291 delete[ ], 217 delete keyword, deallocating memory, 213–214 delete() operator, 52, 564–569 Dependency Inversion Principle (DIP), 206 deprecated attribute, 32–33 deque container, 584, 589, 653 dereferencing operators, overloading operator *, 558 operator →, 558–559 operator→

  • , 559

dereferencing pointers, 50–51, 223–224 derived classes about, 338–341, 363–364 constructors, parent, 353–354 destructors, parent, 355–356 functionality, 351–353 Derived constructor, 353–354 design. See also reusable code abstraction and benefits, 142–143 incorporating, 143 C++ about, 141–142 algorithms, 162–165 chess program, 157–158 class hierarchies, 161–162 classes, 162–165 data structures, 162–165 error handling, 165 patterns, 162–165 subsystems, 158–160 threading models, 160–161 frameworks and, interviews, 1188 functional requirements and, 138 importance of, 139–141 multithreaded programming, 965–966 non-functional requirements and, 138 object-oriented design, interviews, 1171–1172 patterns about, 141, 145, 1105–1106 adaptor pattern, 1118–1120 chain of responsibility, 1129–1131 decorator pattern, 1126–1128 dependency injection, 1106 factory patterns, 1109–1118 interviews, 1188 iterator pattern, 1123 observer pattern, 1124–1126 proxy pattern, 1120–1122 resources, 1201–1202 singleton, 1132–1135 program design, interviews, 1169–1171 software design, 138 stakeholders and, 138 Standard Library and, 157 techniques, 145, 1084 designated initializers, 48–49 design-level efficiency caching, 1002–1003 object pools, 1003–1008 destruction, variables, non-local, 415 destructors about, 276–277, 288 derived classes, 355–356 error handling and, 531 parent, 355–356 virtual keyword, 348–349 direct list initialization, 74 directed graphs, 837–848 directed_graph interface, 840–841, 848–866 directives

  1. endif, 409
  2. ifndef, 409
  3. include, 409
  4. pragma once, 409

preprocessor, 5–7 directories, iteration, 492–493 documentation comments ad hoc, 120–121 complicated code and, 115–116 every line, 117–118 fixed-format, 119–120 meta-information, 116–117 prefixes, 118–119 self-documenting code, 122 usage explanation, 111–112 man pages, 119 doSomething() function, 518 double dispatch, 1093–1098 double square brackets, 30 double-ended queue, 584 doubleInts(), 225 doubly linked lists, 584 do/while loop, 39 downcasting, 358–359 doWorkInThread() function, 928 DumpRange() function, 753 durations, 796–800 dynamic arrays, 217 dynamic binding, 347 dynamic casts, pointers and, 224 Dynamic Link Library (DLLs), 701–702 dynamic memory about, 212–224 allocation, 285–306 SpreadsheetCell class, 285–288 dynamic strings about, 88–103 C-style copyString() function, 88 sizeof() operator, 89 strlen() function, 88–89 nonstandard strings, 102–103 std::string class, 92–96 std::string_view class, 100–102 string literals assigning, 90 literal pooling, 90 raw string literals, 90–91 dynamically allocating arrays, 51–52 dynamic_cast(), 393–394, 518 E early binding, 346 edges deleting, 844–845 inserting, 843 efficiency design-level, 994, 1001–1008 caching, 1002–1003 object pools, 1003–1008 interviews, 1186–1187 language, 995–1001 language-level about, 994, 995–1001 inline functions, 1001 inline methods, 1001 memory allocation, 1000–1001 object handling, 996–1000 profiling and about, 1008–1019 example, Visual C++ 2019, 1016–1019 gprof and, 1009–1016 resources, 1200 elements, value semantics, 628–630 elliptic integrals, 577 emplace() method, 674 emplace operations, containers, 643–644 employee records program about, 76 Database class Database.cpp file, 81 Database.cppm file, 80 DatabaseTest.cpp file, 82 Employee class Employee.cpp file, 78–79 Employee.cppm file, 76–77 EmployeeTest.cpp file, 79 user interface, 82–85 enable_shared_from_this, 244–245 encodings, UCS, 765 end() function, 607

  1. endif directive, 7
  2. endif directive, 409

enumerated types about, 19–21, 319–320 strongly typed enumerations, 19 structs, 22 eof() method, 470–471 equal() algorithm, 592, 733–735 equal_range() algorithm, 597, 751–752 erf() function, 577 error checking, containers, 630 error handling about, 496 constructors, 526–528 destructors, 531 exceptions, 496–498 input streams, 475–476 interviews, 1180–1181 memory allocation errors, 523–526 output streams, 470–471 error logging, debugging and, 1047–1049 exception handling, futures, 956 exceptions about, 69–70, 496–498 catching about, 499–501, 1088 in class hierarchy, 510–511 const reference, 502–503 multiple, 503–505 classes, writing, 512–516 cleanup and, 522 copying, 926–929 custom, 129 exception specification, 508–509 header files, 1209 nested, 517–518 noexcept keyword, 507–508 rethrowing, 519–520, 522, 926–929 standard, 509–510 Standard Library, 576 throw list, 508–509 throwing about, 499–501 multiple, 503–505 throwing exceptions, 1088 types, 501–502 uncaught, 505–507 exclusive_scan() algorithm, 599, 760 execution policy, parallel algorithms, 757 exp() function, 577 explicit keyword, 438 expressions, folding expressions, 896–898 extern keyword, 413–414 extraction operators, overloading, 549–550 F factories, 617 factory patterns implementing, 1110–1111, 1114–1115 other uses, 1117–1118 fail() method, 470–471 fallthrough attribute, 25 false-sharing, multithreaded programming and, 920–921 feature test macros, 410–411 fgets() function, 467 file streams about, 484–488 binary mode, 485 fgets() function and, 467 fprintf() function and, 467 fputs() function and, 467 fread() function and, 467 fscanf() function and, 467 fwrite() function and, 467 ios_base::app constant, 484 ios_base::ate constant, 484 ios_base::binary constant, 484 ios_base::in constant, 484 ios_base::out constant, 484 ios_base::trunc constant, 484 text mode, 485 files header files, 5 module implementation, 401–402 module interface, 399–401 reading from, 1089 source files, 6 writing to, 1089 filesystem support library about, 490, 580 directory entry, 491–492 directory iteration, 492–493 helper functions, 492 path, 490–491 fill() algorithm, 594 [fill]align, 105 fill_n() algorithm, 594 find() algorithm, 592, 726–729 find_end() algorithm, 592 find_first_of() algorithm, 592 find_if() algorithm, 592, 726–729 find_if_not() algorithm, 592 findMatches() function, 700 floating-point numbers, 16 floor() function, 577, 797 flush() method, 466, 469–470 flush-on-access, streams, 487–488 fma() function, 577 folding expressions, 896–898 for loop, 39 for_each() algorithm, 595, 747–748 for_each_n() algorithm, 595, 749 format specifiers, 104–107 forward declarations, 409–410 forward_list container, 584, 589, 657–659 fprintf() function, 467 fputs() function, 467 frameworks, object-oriented MFC (Microsoft Framework Classes), 1101 MVC (Model-View-Controller), 1102–1103 fread() function, 467 free store about, 49–50 constructors on, 260 objects, 257–258 freeing memory, 288 friends, 284–285 fscanf() function, 467 full class template specialization, 884–887 function call operator, overloading, 555–556 function objects about, 580 arithmetic, 706–707 bitwise, 709 comparison, 707–709 invokers, 722 logical, 709 threads and, 922–923 transparent, 707 writing, 705 function pointers about, 700–702 threads and, 921–922 function templates class templates and, 449–451 overloading, 449 specialization and, 449 return types, 451–453 specialization, 447–449 type constraints and, 458–461 functional composition, adaptor function objects and, 709–710 functional relationships, 181–182 functionality, 177 functions about, 28–30 abs(), 577 at(), 424 atan2(), 577 begin(), 607 cbegin(), 607 ceil(), 577 cend(), 607 cleanup(), 301 crbegin(), 607 createDocArray(), 217 crend(), 607 current function name, 30 declarations, 6, 28–30 definitions, 6 deprecated attribute, 32–33 doSomething(), 518 doWorkInThread(), 928 DumpRange(), 753 end(), 607 erf(), 577 exp(), 577 fgets(), 467 findMatches(), 700 floor(), 577 fma(), 577 fprintf(), 467 fputs(), 467 fread(), 467 friends, 284 fscanf(), 467 fwrite(), 467 getValue(), 251 handleMessage(), 296–297 handleValue(), 894 hash functions, 684–686 increment(), 855 intEqual(), 701 log(), 577, 1053 main(), 8 make_pair(), 436–437 malloc(), 214–215 maybe_unused attribute, 31–32, 911 member functions, calling, 712–713 mem_fn(), 712–713 new handler callback, 524–526 nodiscard attribute, 31, 129 noreturn attribute, 32, 927 overloading, 30 polymorphic function wrapper, 703 pow(), 577 predicate function callbacks, 728 processValues(), 893–895 pthread_create(), 921 rand(), 579, 810–811 rbegin(), 607, 614 realloc(), 217 refcall(), 65 remainder(), 577 rend(), 607, 614 rethrow_nested(), 518 return type, deduction, 30 set_terminate(), 507 setValue(), 251–252 sin(), 577 sinh(), 577 sprintf(), 468 sprintf_s(), 468 sqrt(), 577 srand(), 579, 810–811 sscanf(), 468 swap(), 300–301 terminate(), 506–507 tgamma(), 577 threadFunc(), 928–929 function-try-blocks, 528–531 functors, 555. See also function objects <future> folder, 580–581 futures about, 952–953 exception handling, 956 promises, 952–953 std::async, 955–956 std::future, 953–954 std::packaged_task, 954–955 std::promise, 953–954 std::shared_future, 956–957 fuzz testing, 1039 fwrite() function, 467 G generate() algorithm, 594 generate_n() algorithm, 594 generic programming about, 426 templates and, 574–575 get_money input manipulator, 480 getStatus(), 127 getters, 127 get_time input manipulator, 480 getValue() function, 251 global scope, 44–45 good() method, 470–471 GPUs (graphics cards), 916 granularity of tests, 1027–1028 graph_node, 838–840 Grid class, 426–431 H handleMessage() function, 296–297 handles, 190 handleValue() function, 894 has-a relationships, 175–176, 178–181 hash functions, 684–686 hash tables, 587–588, 684–691 header files about, 5, 408–409, 1203–1205 <algorithm>, 726 algorithms, 1206–1207 allocators, 1206–1207 <any>, 823–824 <array>, 584 <atomic>, 929 <chrono>, 579 <condition_variable>, 947 containers, 1205–1206 <cstdint>, 581 <deque>, 584 duplicate definitions, 409 exceptions, 1209 forward declarations, 409–410 <forward_list>, 584 <future>, 580–581 general utilities, 1207–1209 initializer lists, 40 <initializer_list>, 579 I/O streams, 1210 <iostream>, 5–6, 468 iterators, 1206–1207 <map>, 587 mathematical utilities, 1209 <multimap>, 587 <multiset>, 586–587 <ostream>, 468 <priority_queue>, 585 <queue>, 585 ranges, 1206–1207 <ratio>, 794–796 <set>, 586–587 <stack>, 586 <string>, 575–576 template definitions, 433 <thread>, 580–581 threading support library, 1210–1211 <tuple>, 579–580 <type_traits>, 581 <utility>, 579–580 <variant>, 821–823 <vector>, 583 header units, 408 Hello World, 4–5 helper functions, filesystem support library, 492 hex input manipulator, 480 hex output manipulator, 471 hierarchies about, 182–183 catching exceptions, 510–511 standard exceptions, 509–510 high_resolution_clock class, 802 Hungarian Notation, 126 I _i literal, 570

  1. ifdef directive, 7

if/else statements, 23

  1. ifndef directive, 7, 409

Impl class, 332 implementation directed_graph interface, 841 partitions, 407–408 splitting from interface, 402–403 implementation class, 330–334 implicit conversions, 322

  1. include directive, 6, 409

includes() algorithm, 597 inclusive_scan() algorithm, 599, 760 increment() function, 855 inheritance base classes about, 177 virtual, 389–390 casts, 390–394 constructors, 374–378 derived classes assignment operator, 385–386 copy constructors, 385–386 extending classes, 338–341 functionality, 177 multiple about, 183–184, 367–371 base classes, ambiguous, 369–370 naming collisions, 368–371 uses, 371 non-public, 388 overridden methods base class method, 382–385 base class method overloaded, 379–380 base class method private, 380–381 base class method static, 378–379 method return type, 371–373 parent classes, 177 polymorphism and, 360–367 preventing, 341 properties, 177 reuse and, 350–353 RTTI (run-time type information), 386–388 specialization comparison, 446 superclasses, 177 templates, 445–446 inheritance techniques, interviews, 1177–1178 initialization constructors, 61 RAII (Resource Acquisition is Initialization), 1091–1093 uniform about, 45–47 copy list, 74 direct list, 74 variables, non-local, 415 initializer lists, 40 initializer-list constructors, 271–272 <initializer_list> header, 579 inline keyword, 312 inline methods about, 311–313 efficiency and, 1001 inline variables, static data member access, 314–315 in-memory stream, 482 inner_product() algorithm, 600 inplace:merge() algorithm, 597 input streams

operator, 473–474

error handling, 475–476 manipulators, 480 methods bad(), 475 fail(), 475 get(), 476–477 getline(), 479–480 good(), 475 peek(), 478–479 putback(), 478 unget(), 477–478 objects and, 423–425 as views, 625 insert() method, 612–613, 672–673 insertion operators, overloading, 549–550 insert_or_assign() method, 673 instances, 171 int* type declaration, 70–71 integration about, 1039–1041 JSON-based file serializer, 1040 shared resources, readers/writers, 1040 wrapper, third-party library, 1040 intEqual() function, 701 interface class, 330–334 Interface Segregation Principle (ISP), 206 interfaces APIs (application programming interface), 199 audience and, 198–199 component interface, 200 containers, 582–590 libraries, 199 purpose, 199–200 reusable customizability, 204–205 documentation, 203–204 ease of use and generality, 205 familiarity, 200–202 general-purpose, 204–205 ISP (Interface Segregation Principle), 206 multiple, 206 required functionality, 202–203 uncluttered, 203 splitting from implementation, 402–403 subsystems, 200 utility classes, 199 interviews applications, 1189 classes, 1174–1177 coding style, 1168–1169 date and time utilities, 1183 debugging, 1187–1188 design frameworks and, 1188 object-oriented design, 1171–1172 patterns, 1188 program design, 1169–1171 reuse and, 1172 efficiency, 1186–1187 error handling, 1180–1181 inheritance techniques, 1177–1178 I/O, 1179–1180 library utilities, 1184 memory management, 1172–1173 multithreaded programming, 1184–1185 objects, 1174–1177 obscure questions, 1178 operator overload, 1181 random number facilities, 1183–1184 regular expressions, 1167–1168 software engineering methods, 1185–1186 Standard Library, 1165–1166, 1182–1183 strings localization, 1167–1168 views, 1167–1168 templates, 1178–1179 testing abilities, 1187 IntPtr, 70–71 invoke() adaptor, 722 I/O bidirectional, 488–489 interviews, 1179–1180 I/O streams about, 8–9 header files, 1210 resources, 1194 Standard Library, 576 ios_base::app constant, 484 ios_base::ate constant, file streams, 484 ios_base::binary constant, file streams, 484 ios_base::in constant, file streams, 484 ios_base::out constant, file streams, 484 ios_base::trunc constant, file streams, 484 <iostream> header file, 5–6, 468 iota() algorithm, 599 is-a relationships, 176–178 is_heap() algorithm, 598 is_heap_until() algorithm, 598 is_partitioned() algorithm, 596 is_permutation() algorithm, 600 is_sorted() algorithm, 596 is_sorted_until() algorithm, 596 istream_iterator class, 611–612 iteration, directories, 492–493 iterative processes, 975 iterator adaptors insert iterators, 612–613 move iterators, 615–616 reverse iterators, 614 iterator design pattern, 1123 iterators about, 604–606 BidirectionalIterator, 605 constant iterators, 605 containers, 606–608 ContiguousIterator, 605 examples, 609–610 ForwardIterator, 605 header files, 1206–1207 InputIterator, 605 mutable, 605 OutputIterator, 605 RandomAccessIterator, 605 streams istream_iterator class, 611–612 ostream_iterator class, 610–611 traits, 608–609 iter_swap() algorithm, 595 K keywords auto, 72–74 const, 53–56 constexpr, 56–57 decltype, 75 default, 265 explicit, 438 extern, 413–414 inline, 312 new, 213–214 noexcept, 507–508 override, 342–343 static data members, 411 linkage, 411–413 methods, 411 throw, 519–520 try, 528–531 virtual, 347–349 virtual, 342–343 L lambda expressions assigning, 722 capture expressions, 719–720 copying, 722 default construction, 722 generic expressions, 719 as parameters, 718–719 as return types, 721 Standard Library algorithms count_if(), 593, 736–737 generate(), 730–731 syntax, 713–718 threads and, 924 in unevaluated contexts, 722 writing, 1086–1087 language, efficiency and, 995–1001 language-level efficiency about, 994, 995–1001 inline functions, 1001 inline methods, 1001 memory allocation, 1000–1001 object handling catch exceptions, 998 move semantics, 998 pass-by-reference, 996–997 return-by-reference, 998 return-value optimization, 999–1000 temporary objects, 998–999 latches, 950 late binding, 347 lazy evaluation, 619 Legendre polynomials, 577 lexicographical_compare() algorithm, 593, 733–735 lexicographical_compare_three_way() algorithm, 593, 733–735 libraries filesystem support directory entry, 491–492 directory iteration, 492–493 helper functions, 492 path, 490–491 interfaces, 199 open-source BSD (Berkeley Software Distribution), 155 CC (Creative Commons) license, 155 GPL (GNU Public License), 155 locating, 156 use guidelines, 156–157 Ratio library, 794–796 library utilities, interviews, 1184 likely attribute, 33 linked lists, 584 linking streams, 487–488 Liskov Substitution Principle (LSP), 181, 206 list container, 584, 588, 653–657 lists doubly linked, 584 singly linked, 584 literal operators, 570–572 literals about, 11–12 _i literal, 570 _s literal, 571 string literals, localization and, 764–765 user-defined, 570–572 little-endian ordering of bytes, 1141 local storage, threads, 924–925 <locale> header, 767 locales about, 767–769 string literals, 764–765 wide characters, 764 localization about, 575, 763–764 ASCII characters and, 763–764 character classification, 769 character conversion and, 769–771 character sets about, 764 matches, 775–777 non-Western, 765–767 conversions, 769–771 facet categories, 770–771 facets, 767 log() function, 577, 1053 Logger class, 1051–1052 logical evaluation operators !, 26 !=, 26 &&, 26 ==, 26 <, 26

⇐, 26

, 26
=, 26

⇔, 26 logical expressions, short-circuit logic, 26 logical function objects, 709 loops for, 39 do/while, 39 while, 38–39 lower_bound() algorithm, 597, 751–752 lvalues, 295–297 M macros feature test, 410–411 preprocessor and, 417–418 main() function, 8 make-heap() algorithm, 598 make_pair() function, 436–437 malloc() function, 214–215 man pages, 119 map container about, 587, 590 element look up, 675 element removal, 675–676 example, 676–679 inserting elements, 671–674 iterators, 674 nodes, 676 mapping, in ranges, 623 mathematical utilities, Standard Library about, 577–579 Bessel functions, 577 beta functions, 577 complex numbers, 577 cylindrical Neumann functions, 577 elliptic integrals, 577 Legendre polynomials, 577 ratio class, 577 ratio class template, 577 valarray class, 577 max() algorithm, 598, 755–756 max_element() algorithm, 599 maybe_unused attribute, 31–32, 911 member functions calling, 712–713 threads and, 924 mem_fn() function, 712–713 memory allocating failure, 215 new keyword, 213–214 buffers, underallocating, 229–231 deallocating, delete keyword, 213–214 destructors, 288 double deleting, 234 dynamic, 212–224 freeing, 288 garbage collection, 228–229 handling, 94 leaks, 231–234, 290 low-level operations, 227–229 malloc() function, 214–215 object pools, 229 orphaned, 290 out-of-bounds, accessing, 229–231 pointer arithmetic, 227–228 pointers about, 49–51 dangling, 234 polymorphic memory wrappers, 834–835 stack, 49–50 memory allocation errors, custom failure behavior, 524–526 operators, overloading delete expression, 564 delete operator, 564–569 new expression, 564 new operator, 564–569 pre-allocating, 1000–1001 memory dumps, 1058 memory management about, 211–212 custom, 228 interviews, 1172–1173 memory pool, 563 merge() algorithm, 597, 656 meta-information, coding style and, 116–117 metaprogramming templates, 898 loop unrolling, 899–900 tuples, printing about, 900–903 compile-time integer sequence, 903 constexpr if statement, 902–903 type traits about, 903–905 constexpr if statement, 910–912 enable_if, 908–910 logical operators, 912 static assertions, 912–913 type categories, 905–907 type relationships, 907 methods : : (scope resolution operator), 254 about, 469–470 access, 254 allocate(), 834–835 assign(), 635 bad(), 470–471, 475 base(), 614 calling others, 254–255 class methods, type constraints and, 461–462 clone(), 423 const, 307–308 constructors about, 259 compiler-generated, 275–276 copy, 269–271 default, 261–265 delegating, 260–261, 273 on the free store, 260 initializer-list constructors, 271–272 initializers, 265–268 multiple, 260–261 overloading, 260–261 on the stack, 260 writing, 259 deallocate(), 834–835 destructors, 276–277 emplace(), 674 eof(), 470–471 fail(), 470–471, 475 flush(), 466, 469–470 good(), 470–471, 475 hiding, 346 inline, 311–313 insert(), 612–613, 672–673 insert_or_assign(), 673 method templates, 438–442 moveFrom(), 300 mutable data members, 308 myCopy(), 612–613 operator[ ], 673–674 overloading const and, 309–310 deleting explicitly, 310 overriding override keyword, 344–345 preventing, 350 syntax, 342–343 pointers to, 702–705 pure virtual methods, 362 put(), 469 ref-qualifier, 310–311 resize(), 878 seek(), 485–487 static, 306–307 std::as_const(), 69, 310 str(), 482 swap(), 635 tell(), 485–487 this pointer, 255–256 tie(), 487–488 write(), 469 min() algorithm, 598, 755–756 min_element() algorithm, 599 minimum-maximum algorithms, 755–756 minmax() algorithm, 599 minmax_element() algorithm, 599 mismatch() algorithm, 593, 733–735 mixin classes about, 184–185, 1098–1101, 1100 designing, 1098–1100 implementing, 1100 modifying sequence algorithms about, 593–595, 737–747 copy(), 739–740 erase(), 742–743 generate(), 737–738 move(), 740–742 remove(), 743–744 replace(), 742 reverse(), 746 sample(), 745–746 shift_left(), 746–747 shift_right(), 746–747 shuffle(), 595 transform(), 738–739 unique(), 744–745 module declaration, 399 module implementation files, 401–402 module interface files, 399–401 module partitions, 405–408 modules about, 397–399 submodules, 404–405 month class, 804 move() algorithm, 594 move assignment operators, 295, 297–301, 544–545 move constructor, 297–301 move semantics about, 244, 295–305, 615, 730 implementing, 297–299 object handling and, 998 move_backward() algorithm, 594 moveFrom() method, 300 multicore processors, 917 multi-dimensional arrays free store, 221–222 stack, 220–221 multimap container, 587, 590 multiple inheritance, 183–184, 367–371 multiset container, 586–587, 590 multithreaded programming about, 916–917 barriers, 951 condition variables, 947–950 coroutines, 963–964 data races, 918–919 deadlocks, 919–920 debugging, 1066–1067 false-sharing, 920–921 <future> header, 580–581 futures about, 952–953 exception handling, 956 promises, 952–953 std::async, 955–956 std::future, 953–954 std::packaged_task, 954–955 std::promise, 953–954 std::shared_future, 956–957 interviews, 1184–1185 latches, 950 logger class example, 958–962 race conditions, 918–919 resources, 1202 semaphores, 951–952 tearing, 919 thread pools, 962–963 <thread> header, 580–581 threading design, 965–966 mutable data members, 308 mutable iterators, 605 mutex classes about, 936–939 double-checked locking, 946–947 locks lock_guard, 939–940 multiple, 941 scoped_lock, 942 shared_lock, 941 unique_lock, 940 non-timed exclusive ownership, 938 lock() method, 937 read locks, 938 readers-writers lock, 938 shared lock ownership, 938 shared ownership, 938 shared_mutex class, 938 try_lock() method, 938 unlock() method, 938 std::call_once, 942–943 thread writing, safe streams, 943–945 timed, 939 timed locks, 945–946 mutual exclusion, mutex classes about, 936 non-timed, 937–938 timed, 939 myCopy() method, 612–613 N named comparison functions, 28 namespaces about, 9–11 aliases, 11 anonymous, 45 naming conventions capitalization, 127 counters, 125 getStatus(), 127 getters, 127 Hungarian Notation, 126 namespaced constants, 127 prefixes, 126 selecting, 124–125 setStatus(), 127 setters, 127 negative tests, 1034–1035 nested, 11 nested classes, 318–319 nested exceptions, 517–518 nested namespaces, 11 nested requirements, 457 new[ ], 217 new handler callback function, 524–526 new keyword, 213–214 new operator, 564–569 next_permutation() algorithm, 600 noboolalpha input manipulator, 480 noboolalpha output manipulator, 471 node handles, 676 node-based data structures, 676 nodes deleting, 843–844 inserting, 842–843 searching, 841–842 nodiscard attribute, 31, 129 noexcept keyword, 507–508 none_of() algorithm, 593, 736–737 non-local variables destruction, 415 initialization order, 415 non-modifying algorithms, 591–593 non-modifying sequence algorithms comparison algorithms, 733–735 counting algorithms, 736–737 search algorithms, 731–733 specialized searchers, 733 non-timed mutex classes exclusive ownership, 938 lock() method, 937 read locks, 938 readers-writers lock, 938 shared lock ownership, 938 shared ownership, 938 shared_mutex class, 938 try_lock() method, 938 unlock() method, 938 non-type parameters, templates about, 434–436 method templates, 440–442 noreturn attribute, 32, 927 noshowpoint output manipulator, 472 noskipws input manipulator, 480 not1() negator adaptor, 712 not2() negator adaptor, 712 not_fn() negator adaptor, 712 NRVO (named return value optimization), 303–304 nth_element() algorithm, 596 null pointers, 50–51 <numeric> header, 1005 O object handling catch exceptions, 998 move semantics, 998 return-by-reference, 998 return-value optimization, 999–1000 temporary objects, 998–999 object-oriented programming (OOP) about, 41, 170 aggregation, 175 behaviors, 172 classes about, 170–171 base classes, 177 instances, 171 collections, 172 components, 171 deriving, 176 extending, 176 frameworks, 1101–1102 general, 174–175 hierarchies, 182–183 inheritance about, 176–178 base classes, 177 functionality, 177 multiple, 183–184 parent classes, 177 properties, 177 superclasses, 177 instances, 171 MVC (Model-View-Controller), 1102–1103 objects, general, 174–175 polymorphism, 178 properties, 171 relationships functional, 181–182 has-a, 175–176, 178–181 is-a, 178–181 is-a relationship, 176–178 mixin classes, 184–185 shares-with, 185 SOLID principles, 206 subclassing, 176 objects assignment operators declaring, 278 defining, 278–279 explicitly defaulted, 280 explicitly deleted, 280 block ends, 276 casting, 358–359 constructors about, 259 compiler-generated, 275–276 copy, 269–271 default, 261–265 delegating, 260–261, 273 on the free store, 260 initializer-list constructors, 271–272 initializers, 265–268 multiple, 260–261 overloading, 260–261 on the stack, 260 writing, 259 creating, 258–276 data members, moving, 300 destructors, 276–277 on the free store, 257–258 function, 580 functors, 555 input, 481–482 interviews, 1174–1177 out of scope, 276 output, 481–482 passing by reference, 270–271 as return values, 280–281 on the stack, 257 obscure questions in interviews, 1178 observer pattern, 1124–1126 oct input manipulator, 480 oct output manipulator, 471 one-dimensional arrays, 34–35 opaque classes, 190 Open/Closed Principle (OCP), 206 open-source libraries BSD (Berkeley Software Distribution), 155 CC (Creative Commons) license, 155 GPL (GNU Public License), 155 locating, 156 use guidelines, 156–157 operating systems, resources, 1202 operational algorithms, 747–749 operations, on strings, 94–95 operator[ ] method, 673–674 operator overload add() method, 320–321 argument types, 538 arithmetic operators about, 324–325 decrement, 547–548 increment, 547–548 unary minus, 547 unary plus, 547 associativity, 545–546 behavior, 539 binary logical operators, 548–549 bitwise operators, 548–549 comparison, 325–329 conversions, implicit, 322 dereferencing operators about, 557–559 operator *, 558 operator →, 558–559 operator→

  • , 559

extraction operators, 549–550 function call operator, 555–556 global functions, 537–538 insertion operators, 549–550 interviews, 1181 limitations, 526–527 memory allocation operators about, 564–569 delete expression, 564 delete operator, 564–569 new expression, 564 new operator, 564–569 methods, 537–538 move assignment operators, 544–545 operator+, 321–323 operators not to overload, 539 overloadable operators, 540–544 precedence, 545–546 read-only access, 553–555 reasons, 536 relational operators, 546 return types, 538–539 rvalue references, 544–545 Standard Library, 575 subscripting operator about, 550–555 non-integral array indices, 555 operator [ ], 553 type building and, 330 operators arity, 537 assignment operators about, 291–294 copy, 280 declaring, 278 defaulted, explicit, 280 defining, 278–279 deleted, explicit, 280 move, 295 associativity, 537 binary, 16 conditional statements, 25–26 conversion about, 559–563 auto, 560 Boolean expressions, 561–563 explicit, 561 delete, 52, 564–569 literal, 570–572 logical evaluation !, 26 !=, 26 &&, 26 <, 26 ==, 26 ⇐, 26

>, 26

=, 26

⇔, 26 move assignment operators, 544–545 new, 51–52, 564–569 precedence, 537 relational, 546 spaceship, 27–28 ternary, 16 three-way comparison, 27–28 unary, 16 <optional> header, 37 ordered associative containers map constructing, 670–671 element look up, 675 element removal, 675–676 example, 676–679 inserting elements, 671–674 iterators, 674 nodes, 676 multimap, 679–682 multiset, 684 set, 682–684 orphaned memory, 290 orthogonality, 591 <ostream> header file, 468 ostream_iterator class, 610–611 output streams about, 468–473 cout, 468 error handling, 470–471 manipulators, 471–473 methods about, 469–470 bad(), 470–471 eof(), 470–471 fail(), 470–471 flush(), 469–470 good(), 470–471 put(), 469 write(), 469 objects and, 481–482 raw output, 469 over-classification, 173–174 overload resolution, 309 overloading about, 260–261 methods about, 308–311 const and, 309–310 deleting explicitly, 310 override keyword, 344–345 overriding methods about, 342–350 override keyword, 344–345 preventing, 350 syntax, 342–343 P pair class, 669–670 parallel algorithms, 756–758 parameter packs, 894 parameterization, 451 parameters about, 313 const keyword and, 55 constrain template, 1090–1091 cooked-mode literal operators, 570–571 references about, 61–63 pass-by-reference, 63 pass-by-value, 63–64 template template parameters, 880–882 templates about, 433 deduction for constructors, 436–438 default values, 436 non-type parameters, 434–436, 882–884 template parameters, 880–882 parent classes, 177, 338 parent names, 356–358 partial class template specialization, 884–889 partial ordering, 28 partial specialization, templates, 445 partial_sort() algorithm, 597 partial_sort_copy() algorithm, 597 partial_sum() algorithm, 599 partition() algorithm, 596 partition algorithms, 749–750 partition_copy() algorithm, 596, 749–750 partition_point() algorithm, 596 partitions, module, 405–408 passing, by reference, 270–271 pimpl idiom, 330–331 pipeline, 619 placeholders, 103–104 platform about, 1137 binary compatibility, 1139–1140 pointer arithmetic, 227–228 pointers about, 49–51 arrays as, 224–226 casting with, 224 dangling, 234, 289 to data members, 702–705 dereferencing, 50–51, 223–224 free store, 49–50 to methods, 702–705 models, 223–224 null about, 50–51 constant, 52–53 to references, 60 versus references, 64–68 shared ownership, 235 smart about, 65 auto_ptr, 245–246 enable_shared_from_this, 244–245 move semantics, 244 referencing counting and, 241–242 shared_ptr, 239–242 unique_ptr, 235–239 weak_ptr, 243–244 smart pointers, 234–246 on the stack, 260 to structures, 51 this, 255–256 polymorphic function wrapper, 703 polymorphic memory wrappers, 834–835 polymorphism about, 178 inheritance and, 360–367 pop_heap() algorithm, 598 pow() function, 577

  1. pragma directive, 7
  2. pragma once directive, 409

precedence, 18–19, 545–546 precision, 107 predefined standard concepts, 457–458 predicate function callbacks, 728 preprocessor directives, 5–7 macros, 417–418 prev_permutation() algorithm, 600 priority_queue container about, 585, 589 function objects and, 707–709 private implementation idiom, 330–331 private nested classes, 319 procedural approach, 170 process, software engineering and, 972–973 processors, multicore, 917 processValues() function, 893–895 profiling about, 1008–1019 gprof and, 1009–1016 programming. See also design; object-oriented programming (OOP) generic, 426 multithreaded, 916–917 style, resources, 1199–1200 projection defined, 617 in range-based algorithms, 618–619 properties, 171, 177 protected nested classes, 319 proxy patterns, 1120–1122 pseudo-random number engines linear congruential, 812 Mersenne twister, 812 subtract with carry engine, 812 pthread_create() function, 921 pure virtual methods, 362 push_back() call, 615–616 push_heap() algorithm, 598 put() method, 469 put_money output manipulator, 472 put_time output manipulator, 472 Q QA (quality assurance), 1021 queue container, 585, 589 quoted input manipulator, 480 quoted output manipulator, 472 R race conditions, 918–919 rand() function, 579, 810–811 random numbers distributions Bernoulli, 816 normal, 816–817 Poisson, 816 uniform, 816 engines about, 811–813, 816–819 adapter pattern, 813–814 adaptors, 813 linear_congruential_engine, 811 mersenne_twister_engine, 811 predefined, 813–814 random_device, 811 subtract_with_carry_engine, 811 generate() algorithm, 815 generating, 810–811, 814–815 interviews, 1183–1184 pseudo-random number engines linear congruential, 812 Mersenne twister, 812 subtract with carry engine, 812 resources, 1197 Standard Library, 579 random_shuffle() algorithm, 595 range adapters, 620–621 range factories, 623–625 range-based algorithms, 617–619 range-based for loop, 39–40 ranges defined, 617 header files, 1206–1207 range factories, 623–625 ranges library about, 601, 616–617 range factories, 623–625 range-based algorithms, 617–619 Ratio library, 794–796 <ratio> header, 794–796 raw pointers, 606 raw string literals, 90–91 raw-mode literal operators, 570 rbegin() function, 607, 614 reachability, visibility vs., 403–404 reading from files, 1089 read-only access, 553–555 realloc() function, 217 recursive_directory_iterator, 492 reduce() algorithm, 600 ref() function, 629 refcall() function, 65 reference data members about, 61 const, 317–318 reference variables, 58–61 references about, 58–68 <atomic> header, 932–933 const keyword, 502–503 lvalues, 295–297 modifying, 58–59 parameters about, 61–63 pass-by-reference, 63 pass-by-value, 63–64 passing by, 270–271 to pointers, 60 versus pointers, 64–68 rvalues, 295–297 structured bindings and, 61 reference:wrapper class, 629 ref-qualifier methods, 310–311 regression testing, 1041–1042 regular expressions alternation, 773 anchors, 773 back references, 774, 778 capture groups, 774 character sets about, 775–777 character classes, 775–776 range specification, 775 decision making and, 772 ECMAScript, 772, 773–779 grammars, 772–773 grouping, 774 interviews, 1167–1168 iteration and, 772 lookahead, 778 matches, 772 parsing and, 772 patterns, 772 precedence, 775 raw string labels, 778–779 regex library, 779–780 regex_iterator() algorithm, 784–785 regex_match() algorithm, 781–783 regex_replace() algorithm, 788–790 regex_search() algorithm, 783–784 regex_token_iterator, 785–788 repetition, 774 replace, 772 replace operations, 774 searches, 772 Standard Library, 576 subexpressions, 774 tokenization and, 772 transformation and, 772 validation and, 772 wildcards, 773 word boundaries, 777 reinterpret_cast(), 391–392 relational operators, 546 relationships functional, 181–182 has-a, 175–176, 178–181 is-a, 176–178 mixin classes, 184–185 shares-with, 185 remainder() function, 577 remove() algorithm, 594 remove_copy() algorithm, 594 remove_copy_if() algorithm, 594 remove-erase-idiom, 744 remove_if() algorithm, 594 rend() function, 607, 614 replace() algorithm, 594 replace:copy() algorithm, 594 replace:copy_if() algorithm, 594 replace:if() algorithm, 594 resize() method, 878 Resource Acquisition Is Initialization (RAII), 1091–1093 resources algorithms, 1196–1197 beginning C++, 1191–1192 C++11, 11967 C++14, 11967 C++17, 11967 C++20, 1196 computer architecture, 1200 data structures, 1196–1197 debugging, 1201 design patterns, 1201–1202 efficiency, 1200 general C++, 1192–1194 I/O streams and strings, 1194 multithreaded programming, 1202 operating systems, 1202 programming style, 1199–1200 random numbers, 1197 software engineering methodology, 1198–1199 open-source, 1197–1198 Standard Library, 1194–1195 templates, 1195 testing, 1200 UML (Unified Modeling Language), 1196 rethrowing exceptions, 519–520, 522 rethrow_nested() function, 518 return type functions about, 30 function templates, 451–453 return values, optimization, object handling and, 999–1000 return-by-reference, object handling and, 998 reusable code abstraction and, 189–190 advantages, 147–148 APIs, 147 big-O notation, 150–152 capabilities, 149–150 dependency injection, 145 design aggregation, 192–193 class hierarchies, 191–192 high cohesion, 191–193 interface dependencies, 193 low coupling, 191 subsystems, 191 design reuse, 145 design-by-contract, 195 disadvantages, 148–149 error checking, 195 extensibility and, 196–198 frameworks, 146 inheritance and, WeatherPrediction class, 350–351 interfaces customizability, 204–205 documentation, 203–204 ease of use and generality, 205 familiarity, 200–202 general-purpose, 204–205 ISP (Interface Segregation Principle), 206 multiple, 206 required functionality, 202–203 uncluttered, 203 interviews, 1172 libraries, 146 licensing and, 153–154 mottos, 188 open-source libraries BSD (Berkeley Software Distribution), 155 CC (Creative Commons) license, 155 GPL (GNU Public License), 155 locating, 156 open-source software, 155 use guidelines, 156–157 optimal reuse design, 191–198 performance and, 150–153 platforms and, 153 versus polymorphism, 178 postconditions, 195 preconditions, 195 prototypes, 154–155 resources, 154 safe code, 195–196 SRP (Single Responsibility Principle), 191–192 stand-alone classes, 146 stand-alone functions, 146 Standard Library, 157 support and, 154 templates benefits, 194 versus inheritance, 195 problems, 194–195 std::vector class, 193 types of code, 146–147 writing reusable code, 144–145 reverse() algorithm, 594 reverse_copy() algorithm, 594 ring buffers, debugging and, 1053–1056 rotate() algorithm, 594 rotate_copy() algorithm, 594 round() function, 797 rule of zero, 305–306 runtime_error, 503–505 rvalues about, 295–297, 615 operator overload and, 544–545 RVO (Return Value Optimization), 303–304, 1000 S _s literal, 571 sample() algorithm, 594 Sashimi Model life cycle model, 975 scan algorithms, 760 scope, resolution, 44–45 search() algorithm, 592 search algorithms about, 592, 731–733 binary search, 751–752 search_n() algorithm, 592 seek() method, 485–487 semaphores, 951–952 sequence algorithms modifying, 737–747 non-modifying comparison algorithms, 733–735 counting algorithms, 736–737 search algorithms, 731–733 specialized searchers, 733 sequential containers array, 660–661 deque, 653 forwards_list, 657–659 list, 653–657 span, 661–663 vector algorithmic complexity, 644 assigning, 635 comparing, 635–636 constructors, 633–634 copying, 635 destructors, 633–634 dynamic-length, 644 elements, 640–644 fixed-length, 631–633 iterators, 636–639, 644 memory allocation scheme, 644–646 move semantics, 646–647 reference storage, 639–640 round-robin schedule example, 647–651 vector<bool > specialization, 652 set algorithms, 752–755 set container, 586–587, 590 set symmetric difference() algorithm, 598 set_difference() algorithm, 598, 752–755 setfill output manipulator, 471 set_intersection() algorithm, 598, 752–755 set_new_handler(), 525–526 setprecision output manipulator, 471 setStatus(), 127 set_symmetric_difference() algorithm, 752–755 set_terminate() function, 507 setters, 127 set_union() algorithm, 598, 752–755 setValue() function, 251–252 setw output manipulator, 471 shallow copying, 289 shared_ptr pointer, 239–242 shares-with relationships, 185 shift_left() algorithm, 594 shift_right() algorithm, 594 short circuit logic, 26 showpoint output manipulator, 472 shuffle() algorithm, 595 sign, 105 simple requirement, 455 sin() function, 577 Single Responsibility Principle (SRP), 191–192, 206 singleton design pattern, 1132–1135 singly linked lists, 584 sinh() function, 577 skipws input manipulator, 480 smart pointers about, 65, 234–246 <atomic> header, 932 auto_ptr, 245–246 enable_shared_from_this, 244–245 move semantics, 244 reference counting and, 241–242 shared_ptr pointer, 239–242 stack unwinding, 521–522 Standard Library, 576 unique_ptr pointer, 235–239 weak_ptr, 243–244 smoke testing, 1042 software design, 138 open-source, resources, 1197–1198 software engineering methods custom, 989 Extreme Programming (XP) about, 984–988 integration, 985–986 iteration planning, 985 metaphor, 987 pair programming, 984 refactoring, 986 release planning, 985 small releases, 986 testing, 985 interviews, 1185–1186 process and, 972–973 Rational Unified Process (RUP), 980–981 resources, 1198–1199 Scrum about, 981 benefits, 983 Daily Scrum, 982 drawbacks, 983–984 effort estimation, 982 PO (Product Owner), 981 product backlog, 982 SM (Scrum Master), 981–982 sprint cycle, 981 Sprint Planning, 983 triage, 988 Unified Process (UP) construction phase, 979 disciplines, 979 elaboration phase, 979 inception phase, 979 iterations, 979 transition phase, 979 software life cycle Agile Model, 978 Sashimi Model, 975 Spiral Model, 975–978 spiral-like models, 975–978 Waterfall Model, 973–975 SOLID principles Dependency Inversion Principle (DIP), 206 Interface Segregation Principle (ISP), 206 Liskov Substitution Principle (LSP), 206 Open/Closed Principle (OCP), 206 Single Responsibility Principle (SRP), 206 sort() algorithm, 597 sort_heap() algorithm, 598 sorting algorithms, 750–751 source code control servers, 1058 Source Code Control software, 990–992 source files about, 6 template definitions, 433 <source location>, 582 spaceship operator, 27–28 span container, 585, 661–663 specialization versus inheritance, 446 specialized searchers, 733 spinlock, 936–937 Spiral Model life cycle model, 975–978 spiral-like models, life cycle, 975–978 spreadsheet application, 250 SpreadsheetCell class, 285–288 sqrt() function, 577 srand() function, 579, 810–811 stable_partition() algorithm, 596 stable_sort() algorithm, 597 stack about, 49–50 constructors on, 260 objects, 257 stack container, 586, 589 stack unwinding, 520–523 stakeholders, design and, 138 Standard Library about, 75, 157 algorithms about, 574, 591–600 accumulate, 729 binary search, 597 comparison, 592–593 counting, 593 find(), 726–729 find_all(), 836–837 find_if(), 726–729 heap, 598 iterators, 604–606 minimum-maximum, 598–599 modifying sequence, 593–595 move semantics, 730 non-modifying, 591–593 numerical processing, 599–600 operational, 595 partition, 595–596 permutation, 600 search, 592 set, 597–598 sorting, 596–597 swap, 595 writing, 836–837 C, 6 containers about, 574, 582–590 adapters, 663–669 allocators, 866–871 array, 584, 589 associative, 628 bitset, 588, 590, 693–697 container adapters, 628 deque, 584, 589 element requirements, 628–630 error checking, 630 forward_list, 584, 589 hash tables, 628, 684–691 iterators, 606–608 list, 584, 588 map, 587, 590 multimap, 587, 590 multiset, 586–587, 590 ordered associative containers, 669–684 priority_queue, 585, 589 queue, 585, 589 reversible, 863–864 sequential, 628, 631–663 set, 586–587, 590 span, 585 stack, 586, 589 standard C-style arrays, 691–692 strings, 692–693 unordered associative containers, 628, 684–691 unordered_map, 590 unordered_multimap, 590 unordered_multiset, 590 unordered_set, 590 vector, 583, 588, 590 writing, 837–875 exceptions, 576 extending, 835–875 filesystem support library, 580 function objects, 580 hash tables, 587–588 header files about, 1203–1205 algorithms, 1206–1207 allocators, 1206–1207 containers, 1205–1206 exceptions, 1209 general utilities, 1207–1209 I/O streams, 1210 iterators, 1206–1207 mathematical utilities, 1209 ranges, 1206–1207 threading support library, 1210–1211 heterogeneous elements, 579–580 homogeneous elements, 579–580 initializer lists, 579 integer types, standard, 581 interviews, 1165–1166, 1182–1183 I/O streams, 576 mathematical utilities about, 577–579 abs() function, 577 atan2() function, 577 Bessel functions, 577 beta functions, 577 ceil() function, 577 complex numbers, 577 cylindrical Neumann functions, 577 elliptic integrals, 577 erf() function, 577 exp() function, 577 floor() function, 577 fma() function, 577 Legendre polynomials, 577 log() function, 577 pow() function, 577 ratio class, 577 remainder() function, 577 sin() function, 577 sinh() function, 577 sqrt() function, 577 tgamma() function, 577 valarray class, 577 modifying sequence algorithms, 593–595 multithreading, 580–581 operator overloading, 575 orthogonality, 591 pair template, 579–580 random number library rand() function, 579 srand() function, 579 regular expressions, 576 resources, 1194–1195 smart pointers, 576 <source location>, 582 stream iterators istream_iterator class, 611–612 ostream_iterator class, 610–611 streams, 576 strings, 575–576 templated lambda expressions, 720–721 templates, 574–575 time utilities, <chrono> header file, 579 <tuple> header file, 579–580 type aliases, 71 type traits, 581 unordered associative containers, 587–588 <utility> header, 579–580 <version>, 582 standard user-defined literals, 571–572 statements, conditional if/else, 23 operator, 25–26 switch, 24–25 static assertions, 912–913 static binding, 346 static casts, pointers and, 224 static data members about, 314–316 access, 315–316 const, 316–317 inline variables, 314–315 static keyword data members, 411 linkage external, 411–412 internal, 411–412 static, 411–412 methods, 411 static methods, 306–307 static variables, 414 static_cast(), 390–391, 394 std::array container, 35 std::as_const() method, 69, 310 std::atomic type, 929 std::back_inserter, 613 std::bad_cast exception, 359, 393 std:bit_cast(), 392–393 std::condition_variable, 947 std::condition_variable_any, 947 std::exchange, 299–300 std::function, 703–705 std:list() algorithm, 618 std::make_from_tuple(), 829 std::make_move_iterator(), 616 std::make_pair(), 437, 670 std::move(), 303–304 std:optional container, 37 std::ostringstream class, 482 std::pair class, 824–826 std::pair container, 36 std::reverse_iterator, 614 std::shared_future, 956–957 std:sort() algorithm, 617 std::string class literals, 95–96 numeric conversions high level, 96–97 low level, 97–99 std::string_view class, 100–102 std::throw_with_nested(), 518 std::tie, 827 std::unique_ptr pointer, 235, 295 std::vector array container, 36, 286 STL (Standard Template Library), 573 str() method, 482 streams about, 466, 693 bidirectional, 488–489 buffered, 466, 469–470 cerr, 467 cin, 466 clog, 467 cout, 466 current position, 483 destinations, 467–468 file streams about, 484–488 fgets() function and, 467 fprintf() function and, 467 fputs() function and, 467 fread() function and, 467 fscanf() function and, 467 fwrite() function and, 467 ios_base::app constant, 484 ios_base::ate constant, 484 ios_base::binary constant, 484 ios_base::in constant, 484 ios_base::out constant, 484 ios_base::trunc constant, 484 flushes, 469–470 flush-on-access, 487–488 input

operator, 473–474

error handling, 475–476 manipulators, 480 iterators istream_iterator class, 611–612 ostream_iterator class, 610–611 linking, 487–488 output « operator, 468 about, 468–473 cout, 468 error handling, 470–471 manipulators, 471–473 seek() method, 485–487 sources, 467–468 Standard Library, 576 string in-memory stream, 482 sprintf() function, 468 sprintf_s() function, 468 sscanf() function, 468 synchronized, 944 tell() method, 485–487 tie() method, 487–488 unbuffered, 466 string class, 575–576 string literals, localizing, 764–765 string streams in-memory stream, 482 sprintf() function, 468 sprintf_s() function, 468 sscanf() function, 468 <string> header, 575–576 strings about, 40–41, 692–693 dynamic C-style, 88–89 nonstandard strings, 102–103 std::string class, 92–96 std::string_view class, 100–102 string literals, 90–91 formatting, 103–109 interviews, 1167–1168 operations on, 94–95 time point conversion, 802–804 string_view class, 575–576 strong ordering, 27 structured bindings, 38, 61 structures, pointers to, 51 submodules, 404–405 subscripting operator, overloading about, 550–555 non-integral array indices, 555 operator [ ], 553 subsumption, of constraints, 460–461 subsystems, interface and, 200 superclasses, 177, 338 swap() method, 300–301, 635 swap_ranges() algorithm, 595 switch statements, 24–25 symbol servers, 1058 synchronized streams, 944 system tests, 1041 system_clock class, 801 T tearing, multithreaded programming and, 919 tell() method, 485–487 template classes, writing, 1090 templates about, 144, 582 class templates alias templates, 447 compiler and, 431–432 definitions, 432–433 deriving from, 445–446 inheritance, 445–446 instantiation, 426, 430–431 parameters, 433–438 type constraints and, 461 writing, 423–431 constrain template parameters, 1090–1091 function templates about, 447–453 class templates and, 449–451 overloading, 449 return types, 451–453 specialization, 447–449 type constraints and, 458–461 generic programming and, 574–575 interviews, 1178–1179 metaprogramming about, 898 factorial at compile time, 898–899 loops, unrolling, 899–900 tuples, printing, 00–903 type traits, 903–905 parameterization, 451 parameters, non-type, 882–884 recursion, 889–892 resources, 1195 reusable code benefits, 194 versus inheritance, 195 problems, 194–195 std::vector class, 193 specialization about, 442–445 full class, 884–887 partial class, 884–889 type constraints and, 462 Standard Library, 574–575 template parameters, 880–882 type parameters, 878–880 variable templates, 454 variadic folding expressions, 896–898 mixin classes, 895–896 type-safe variable-length argument lists, 893–895 temporary objects, object handling and, 998–999 terminate() function, 506–507 ternary operators, 16 testing black-box, 1021–1022 bugs, 1022–1025 fuzz, 1039 granularity, 1027–1028 integration about, 1039–1041 JSON-based file serializer, 1040 shared resources, readers/writers, 1040 wrapper, third-party library, 1040 interviews, 1187 regression testing, 1041–1042 resources, 1200 smoke testing, 1042 system tests, 1041 unit testing about, 1025–1039 approaches, 1026 building, 1034 debugging, 1038 granularity, 1027–1028 negative tests, 1034–1035 planning, 1028–1029 results, 1038–1039 running, 1030, 1034 sample data, 1029 Visual C++ testing framework, 1031–1033 writing, 1029–1030, 1033 white-box, 1021–1022 tgamma() function, 577 this pointer, 255–256, 279 thread objects, 921 <thread> folder, 580–581, 921 threadFunc() function, 928–929 threading design, 965–966 threading support library, header files, 1210–1211 threads automatically joining, 925–926 cancelling, 925 exceptions copying, 926–929 rethrowing, 926–929 function object and, 922–923 function pointer and, 921–922 lambda expressions and, 924 local storage and, 924–925 member function and, 924 results, retrieving, 926 three-way comparison operator, 27–28 throw keyword, 519–520 throwing exceptions about, 499–501, 1088 multiple, 503–505 tie() method, 487–488 time points, 802–804 time utilities, Standard Library, 579, 1183 time zone, 807 timed mutex classes, 939 time_point class, 801, 802–804 transform() algorithm, 595 transform_exclusive_scan() algorithm, 599, 760 transform_inclusive_scan() algorithm, 599, 760 transform_reduce() algorithm, 600 transparent operator functors, 707 try keyword, 528–531 tuples comparisons, 828–829 concatenation, 828 decompose std::tie, 827 structured bindings, 827 std::apply, 829 std::make_from_tuple(), 829 std::pair class, 824–826 std::tuple_cat(), 828 <utility> header, 824–826 type, 106 type aliases, 70–71 type building, operator overload and, 330 type constraints class methods and, 461–462 class templates and, 461 function templates and, 458–461 template specialization and, 462 type inference auto keyword, 72–74 decltype keyword, 75 type parameters, templates, 878–880 type requirements, 456 type-constrained auto, 458 typed constructors, 365–367 typedefs, 71–72 types enumerated, 19–21, 319–320 strongly typed enumerations, 19 structs, 22 templates and, 432 <type_traits> header, 581 U unary operators, 16 unbuffered streams, 466 uncaught exceptions, 505–507 Unicode, 575 Unified Modeling Language (UML), 138, 1196 uniform initialization, 45–47 unique() algorithm, 595 unique_copy() algorithm, 595 unique_ptr pointer, 235–239 unit testing about, 1025–1039 approaches, 1026 building, 1034 debugging, 1038 granularity, 1027–1028 negative tests, 1034–1035 planning, 1028–1029 results, 1038–1039 running, 1030, 1034 sample data, 1029 Visual C++ testing framework, 1031–1033 writing, 1029–1030, 1033 Universal Character Set (UCS), 765–767 unlikely attribute, 33 unordered_map container, 590, 686–690 unordered_multimap container, 590, 690–691 unordered_multiset container, 590, 691 unordered_set container, 590, 691 upcasting, 358–359 upper_bound() algorithm, 597, 751–752 user-defined literals, 570–572 using declaration, 10 utilities general, header files, 1207–1209 interface, 199 mathematical, header files, 1209 variable-length argument lists argument access, 416–417 disadvantages, 417 <utility> header about, 647 tuples, 824–826 V value semantics, elements, 628–630 variable templates, 454 variables about, 12–16 <atomic> header, 935–936 automatic variables, 212 casting, 15–16 coerced, 16 condition variables, 947–950 inline, static data member access, 314–315 non-local destruction, 415 initialization order, 415 static, 414 uninitialized, 50 variadic templates folding expressions, 896–898 mixin classes, 895–896 parameter packs, 894 type-safe variable-length argument lists, 893–895 <variant> header, 821–823 vector container about, 583, 588, 590, 631–651 algorithmic complexity, 644 allocators, 631 assigning, 635 comparing, 635–636 constructors, 633–634 copying, 635 destructors, 633–634 dynamic-length, 644 elements, 640–644 fixed-length, 631–633 iterators, 636–639, 644 memory allocation scheme, 644–646 move semantics, 646–647 reference storage, 639–640 round-robin schedule example, 647–651 vector<bool> specialization, 652 <version>, 582 views defined, 617 ranges and, 619–623 virtual base classes, 370, 389–390 virtual keyword about, 342–343 destructors, 348–349 implementing, 346–347 virtual methods, 362 visibility, reachability vs., 403–404 Visual C++ testing framework, 1031–1033 vtables, 347

W

Waterfall Model life cycle model, 973–975 weak ordering, 28 weak_ptr, 243–244 WeatherPrediction class, 350–351 weekday class, 805 while loop, 38–39 white-box testing, 1021–1022 wide characters, localization, 764 width, 104–105 wifstream, 764 Windows, DLL (Dynamic Link Library), 701–702 wofstream, 764 write() method, 469 ws input manipulator, 480

X

Y

Z

Fair Use Sources

C++: C++ Fundamentals, C++ Inventor - C++ Language Designer: Bjarne Stroustrup in 1985; C++ Keywords, C++ Built-In Data Types, C++ Data Structures (CPP Containers) - C++ Algorithms, C++ Syntax, C++ OOP - C++ Design Patterns, Clean C++ - C++ Style Guide, C++ Best Practices ( C++ Core Guidelines (CG)) - C++ BDD, C++ Standards ( C++ 23, C++ 20, C++ 17, C++ 14, C++ 11, C++ 03, C++ 98), Bjarne Stroustrup's C++ Glossary, CppReference.com, CPlusPlus.com, ISOcpp.org, C++ Compilers (Compiler Explorer, MinGW), C++ IDEs, C++ Development Tools, C++ Linter, C++ Debugging, C++ Modules ( C++20), C++ Packages, C++ Package Manager ( Conan - the C/C++ Package Manager), C++ Standard Library, C++ Libraries, C++ Frameworks, C++ DevOps - C++ SRE, C++ CI/CD ( C++ Build Pipeline), C++ Data Science - C++ DataOps, C++ Machine Learning, C++ Deep Learning, Functional C++, C++ Concurrency, C++ History, C++ Topics, C++ Bibliography, Manning C++ Series, C++ Courses, CppCon, C++ Research, C++ GitHub, Written in C++, C++ Popularity, C++ Awesome , C++ Versions. (navbar_cplusplus – see also navbar_cpp_containers, navbar_cppcon, navbar_cpp_core_guidelines, navbar_cpp23, navbar_cpp20, navbar_cpp17, navbar_cpp14, navbar_cpp11)


© 1994 - 2024 Cloud Monk Losang Jinpa or Fair Use. Disclaimers

SYI LU SENG E MU CHYWE YE. NAN. WEI LA YE. WEI LA YE. SA WA HE.


professional_c_plus_plus_index.txt · Last modified: 2024/05/01 04:23 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki