ebook img

C++20 for Programmers: An Objects-Natural Approach PDF

1005 Pages·2022·13.416 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview C++20 for Programmers: An Objects-Natural Approach

Copyright © 2022 Pearson Education, Inc. All rights reserved. This publication is protected by copyright, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying, recording, or likewise. For information regarding permissions, request forms, and the appropriate contacts within the Pearson Education Global Rights & Permissions Department, please visit https://www.pearson.com/permissions/. Deitel and the double-thumbs-up bug are registered trademarks of Deitel & Associates, Inc. Cover design by Paul Deitel, Harvey Deitel, and Chuti Prasertsith ISBN-13: 978-0-13-690569-1 ISBN-10: 0-13-690569-2 1 Contents Preface ........................................................................................................................................................................................... 13 P.1 Modern C++ ....................................................................................................................................................................... 13 P.2 Target Audiences ............................................................................................................................................................. 14 P.3 Live-Code Approach and Getting the Code ............................................................................................................... 14 P.4 Three Industrial-Strength Compilers .......................................................................................................................... 14 P.6 “Objects-Natural” Learning Approach ....................................................................................................................... 15 P.8 How to Get the Online Chapters and Appendices ................................................................................................... 16 P.9 C++ Core Guidelines ........................................................................................................................................................ 17 P.11 Teaching Approach ....................................................................................................................................................... 18 P.13 Docker ............................................................................................................................................................................... 18 P.14 Some Key C++ Documentation and Resources ....................................................................................................... 19 Before You Begin ........................................................................................................................................................................ 21 Compilers We Use in C++20 for Programmers ............................................................................................................... 21 Some Examples Do Not Compile and Run on All Three Compilers ........................................................................... 21 Installing Visual Studio Community Edition on Windows .......................................................................................... 21 Installing Xcode on macOS .................................................................................................................................................. 22 Installing the Most Recent GNU C++ Version .................................................................................................................. 22 Installing the GNU Compiler Collection in Ubuntu Linux Running on the Windows Subsystem for Linux .. 22 Docker and Docker Containers ........................................................................................................................................... 23 A Note Regarding the {fmt} Text-Formatting Library .................................................................................................. 24 (Industrial-Strength) Static Code Analysis Tools ............................................................................................................ 25 1. Intro and Test-Driving Popular, Free C++ Compilers .................................................................................................... 26 1.1 Introduction ...................................................................................................................................................................... 26 1.2 Test-Driving a C++20 Application ................................................................................................................................ 28 1.3 Moore’s Law, Multi-Core Processors and Concurrent Programming ................................................................ 41 1.4 A Brief Refresher on Object Orientation .................................................................................................................... 43 1.5 Wrap-Up ............................................................................................................................................................................. 45 2. Intro to C++20 Programming ............................................................................................................................................... 46 2.1 Introduction ...................................................................................................................................................................... 46 2.2 First Program in C++: Displaying a Line of Text ...................................................................................................... 47 2.3 Modifying Our First C++ Program ............................................................................................................................... 50 2.4 Another C++ Program: Adding Integers ..................................................................................................................... 51 2.5 Arithmetic .......................................................................................................................................................................... 56 2.6 Decision Making: Equality and Relational Operators ............................................................................................ 57 2.7 Objects Natural: Creating and Using Objects of Standard-Library Class string ............................................ 61 2.8 Wrap-Up ............................................................................................................................................................................. 64 2 3. Control Statements: Part 1 ................................................................................................................................................... 66 3.1 Introduction ...................................................................................................................................................................... 67 3.2 Control Structures ............................................................................................................................................................ 67 3.3 if Single-Selection Statement ....................................................................................................................................... 70 3.4 if …else Double-Selection Statement ........................................................................................................................ 71 3.5 while Iteration Statement .............................................................................................................................................. 74 3.6 Counter-Controlled Iteration ........................................................................................................................................ 75 3.7 Sentinel-Controlled Iteration ........................................................................................................................................ 77 3.8 Nested Control Statements ............................................................................................................................................ 81 3.9 Compound Assignment Operators .............................................................................................................................. 84 3.10 Increment and Decrement Operators ...................................................................................................................... 85 3.11 Fundamental Types Are Not Portable ...................................................................................................................... 88 3.12 Objects Natural Case Study: Arbitrary-Sized Integers ......................................................................................... 89 3.13 C++20: Text Formatting with Function format ...................................................................................................... 93 3.14 Wrap-Up ........................................................................................................................................................................... 95 4. Control Statements, Part 2 ................................................................................................................................................... 96 4.1 Introduction ...................................................................................................................................................................... 96 4.2 Essentials of Counter-Controlled Iteration ................................................................................................................ 97 4.3 for Iteration Statement .................................................................................................................................................. 98 4.4 Examples Using the for Statement ........................................................................................................................... 100 4.5 Application: Summing Even Integers ....................................................................................................................... 101 4.6 Application: Compound-Interest Calculations ....................................................................................................... 101 4.7 do… while Iteration Statement ................................................................................................................................... 105 4.8 switch Multiple-Selection Statement ........................................................................................................................ 106 17 4.9 C++17 Selection Statements with Initializers .................................................................................................... 111 4.10 break and continue Statements .............................................................................................................................. 113 4.11 Logical Operators ......................................................................................................................................................... 114 Err 4.12 Confusing the Equality (==) and Assignment (=) Operators ............................................................. 119 4.13 Objects-Natural Case Study: Using the miniz-cpp Library to Write and Read ZIP files7 .......................... 120 20 4.14 C++20 Text Formatting with Field Widths and Precisions .......................................................................... 125 4.15 Wrap-Up ......................................................................................................................................................................... 127 5. Functions and an Intro to Function Templates ............................................................................................................ 128 5.1 Introduction .................................................................................................................................................................... 129 5.2 C++ Program Components ........................................................................................................................................... 129 5.3 Math Library Functions ............................................................................................................................................... 130 5.4 Function Definitions and Function Prototypes ...................................................................................................... 134 3 5.5 Order of Evaluation of a Function’s Arguments .................................................................................................... 136 5.6 Function-Prototype and Argument-Coercion Notes ............................................................................................. 136 5.7 C++ Standard Library Headers ................................................................................................................................... 139 5.8 Case Study: Random-Number Generation............................................................................................................... 143 5.9 Case Study: Game of Chance; Introducing Scoped enums .................................................................................... 148 5.10 Scope Rules .................................................................................................................................................................... 153 5.11 Inline Functions ........................................................................................................................................................... 157 5.12 References and Reference Parameters .................................................................................................................. 158 5.13 Default Arguments ...................................................................................................................................................... 161 5.14 Unary Scope Resolution Operator ........................................................................................................................... 163 5.15 Function Overloading ................................................................................................................................................. 163 5.16 Function Templates ..................................................................................................................................................... 166 5.17 Recursion ....................................................................................................................................................................... 169 5.18 Example Using Recursion: Fibonacci Series ......................................................................................................... 172 5.19 Recursion vs. Iteration ............................................................................................................................................... 175 5.20 Lnfylun Lhqtomh Wjtz Qarcv: Qjwazkrplm xzz Xndmwwqhlz ...................................................................... 177 5.21 Wrap-Up ......................................................................................................................................................................... 180 6. arrays, vectors, Ranges and Functional-Style Programming .................................................................................. 182 6.1 Introduction .................................................................................................................................................................... 182 6.2 arrays ................................................................................................................................................................................ 183 6.3 Declaring arrays ............................................................................................................................................................ 184 6.4 Initializing array Elements in a Loop ...................................................................................................................... 184 6.5 Initializing an array with an Initializer List ........................................................................................................... 186 6.6 C++11 Range-Based for and C++20 Range-Based for with Initializer ............................................................... 188 6.7 Calculating array Element Values and an Intro to constexpr ........................................................................... 190 6.8 Totaling array Elements .............................................................................................................................................. 191 6.9 Using a Primitive Bar Chart to Display array Data Graphically ........................................................................ 192 6.10 Using array Elements as Counters .......................................................................................................................... 193 6.11 Using arrays to Summarize Survey Results .......................................................................................................... 194 6.12 Sorting and Searching arrays .................................................................................................................................. 195 6.13 Multidimensional arrays ........................................................................................................................................... 197 6.14 Intro to Functional-Style Programming ................................................................................................................. 201 6.15 Objects-Natural Case Study: C++ Standard Library Class Template vector ................................................ 207 6.16 Wrap-Up ......................................................................................................................................................................... 213 7. (Downplaying) Pointers in Modern C++ ......................................................................................................................... 214 7.1 Introduction .................................................................................................................................................................... 215 7.2 Pointer Variable Declarations and Initialization .................................................................................................. 216 4 7.3 Pointer Operators .......................................................................................................................................................... 217 7.4 Pass-by-Reference with Pointers ................................................................................................................................ 220 7.5 Built-In Arrays ................................................................................................................................................................ 224 20 7.6 Using C++20 to_array to Convert a Built-in Array to a std::array ........................................................... 226 7.7 Using const with Pointers and the Data Pointed To ............................................................................................. 227 7.8 sizeof Operator ............................................................................................................................................................... 230 7.9 Pointer Expressions and Pointer Arithmetic .......................................................................................................... 232 20 7.10 Objects-Natural Case Study: C++20 spans—Views of Contiguous Container Elements ........................ 235 7.11 A Brief Intro to Pointer-Based Strings .................................................................................................................... 240 7.12 Looking Ahead to Other Pointer Topics ................................................................................................................. 244 7.13 Wrap-Up ......................................................................................................................................................................... 244 8. strings, string_views, Text Files, CSV Files and Regex ............................................................................................ 246 8.1 Introduction .................................................................................................................................................................... 247 8.2 string Assignment and Concatenation ................................................................................................................... 247 8.3 Comparing strings ....................................................................................................................................................... 249 8.4 Substrings ........................................................................................................................................................................ 251 8.5 Swapping strings .......................................................................................................................................................... 251 8.6 string Characteristics .................................................................................................................................................. 252 8.7 Finding Substrings and Characters in a string ..................................................................................................... 254 8.8 Replacing and Erasing Characters in a string ...................................................................................................... 256 8.9 Inserting Characters into a string ............................................................................................................................ 258 8.10 C++11 Numeric Conversions ..................................................................................................................................... 259 17 8.11 C++17 string_view ................................................................................................................................................ 260 8.12 Files and Streams ......................................................................................................................................................... 263 8.13 Creating a Sequential File .......................................................................................................................................... 264 8.14 Reading Data from a Sequential File ...................................................................................................................... 267 14 8.15 C++14 Reading and Writing Quoted Text ......................................................................................................... 269 8.16 Updating Sequential Files .......................................................................................................................................... 270 8.17 String Stream Processing ........................................................................................................................................... 271 8.18 Raw String Literals ...................................................................................................................................................... 273 8.19 Objects-Natural Case Study: Reading and Analyzing a CSV File Containing Titanic Disaster Data ..... 274 8.20 Objects-Natural Case Study: Intro to Regular Expressions ............................................................................... 284 8.21 Wrap-Up ......................................................................................................................................................................... 291 9. Custom Classes ...................................................................................................................................................................... 292 9.1 Introduction1 ................................................................................................................................................................... 293 9.2 Test-Driving an Account Object .................................................................................................................................. 293 9.3 Account Class with a Data Member and Set and Get Member Functions ....................................................... 295 5 9.4 Account Class: Custom Constructors ......................................................................................................................... 298 9.5 Software Engineering with Set and Get Member Functions ............................................................................. 302 9.6 Account Class with a Balance ...................................................................................................................................... 303 9.7 Time Class Case Study: Separating Interface from Implementation................................................................. 306 9.8 Compilation and Linking Process .............................................................................................................................. 313 9.9 Class Scope and Accessing Class Members .............................................................................................................. 314 9.10 Access Functions and Utility Functions ................................................................................................................. 315 9.11 Time Class Case Study: Constructors with Default Arguments ....................................................................... 315 9.12 Destructors .................................................................................................................................................................... 321 9.13 When Constructors and Destructors Are Called .................................................................................................. 321 9.14 Time Class Case Study: A Subtle Trap —Returning a Reference or a Pointer to a private Data Member ................................................................................................................................................................................................... 324 9.15 Default Assignment Operator ................................................................................................................................... 326 9.16 const Objects and const Member Functions ....................................................................................................... 328 9.17 Composition: Objects as Members of Classes ....................................................................................................... 330 9.18 friend Functions and friend Classes .................................................................................................................... 334 9.19 The this Pointer .......................................................................................................................................................... 336 9.20 static Class Members: Classwide Data and Member Functions .................................................................... 341 20 9.21 Aggregates in C++20 ............................................................................................................................................... 345 9.22 Objects-Natural Case Study: Serialization with JSON ......................................................................................... 347 9.23 Wrap-Up ......................................................................................................................................................................... 353 10. OOP: Inheritance and Runtime Polymorphism ......................................................................................................... 355 10.1 Introduction .................................................................................................................................................................. 356 10.2 Base Classes and Derived Classes ............................................................................................................................ 358 10.3 Relationship Between Base and Derived Classes ................................................................................................ 361 10.4 Constructors and Destructors in Derived Classes ............................................................................................... 369 10.5 Intro to Runtime Polymorphism: Polymorphic Video Game ........................................................................... 370 10.6 Relationships Among Objects in an Inheritance Hierarchy ............................................................................. 371 10.7 Virtual Functions and Virtual Destructors ............................................................................................................ 376 10.8 Abstract Classes and Pure virtual Functions ..................................................................................................... 381 10.9 Case Study: Payroll System Using Runtime Polymorphism .............................................................................. 383 10.10 Runtime Polymorphism, Virtual Functions and Dynamic Binding “Under the Hood” ........................... 392 10.11 Non-Virtual Interface (NVI) Idiom ........................................................................................................................ 395 10.12 Program to an Interface, Not an Implementation24 ......................................................................................... 401 10.13 Runtime Polymorphism with std::variant and std::visit....................................................................... 408 10.14 Multiple Inheritance ................................................................................................................................................. 414 10.15 protected Class Members: A Deeper Look ......................................................................................................... 422 6 10.16 public, protected and private Inheritance ..................................................................................................... 423 10.17 More Runtime Polymorphism Techniques; Compile-Time Polymorphism ............................................... 424 10.18 Wrap-Up ....................................................................................................................................................................... 428 11. Operator Overloading, Copy/Move Semantics and Smart Pointers ...................................................................... 430 11.1 Introduction .................................................................................................................................................................. 431 11.2 Using the Overloaded Operators of Standard Library Class string .............................................................. 432 11.3 Operator Overloading Fundamentals .................................................................................................................... 437 11.4 (Downplaying) Dynamic Memory Management with new and delete ......................................................... 439 11.5 Modern C++ Dynamic Memory Management: RAII and Smart Pointers ...................................................... 441 11.6 MyArray Case Study: Crafting a Valuable Class with Operator Overloading ................................................ 444 20 11.7 C++20 Three-Way Comparison Operator (<=>) ............................................................................................... 474 11.8 Converting Between Types ........................................................................................................................................ 477 11.9 explicit Constructors and Conversion Operators ............................................................................................ 477 11.10 Overloading the Function Call Operator () ......................................................................................................... 480 11.11 Wrap-Up ....................................................................................................................................................................... 480 12. Exceptions and a Look Forward to Contracts ............................................................................................................ 482 12.1 Introduction .................................................................................................................................................................. 483 12.2 Exception-Handling Flow of Control ...................................................................................................................... 486 12.3 Exception Safety Guarantees and noexcept ......................................................................................................... 491 12.4 Rethrowing an Exception .......................................................................................................................................... 492 12.5 Stack Unwinding and Uncaught Exceptions ......................................................................................................... 494 12.6 When to Use Exception Handling ............................................................................................................................ 496 12.7 Constructors, Destructors and Exception Handling ........................................................................................... 499 12.8 Processing new Failures ............................................................................................................................................ 502 12.9 Standard Library Exception Hierarchy ................................................................................................................. 505 12.10 C++’s Alternative to the finally Block: Resource Acquisition Is Initialization (RAII) ............................... 507 12.11 Some Libraries Support Both Exceptions and Error Codes............................................................................ 507 12.12 Logging ......................................................................................................................................................................... 508 12.13 Looking Ahead to Contracts49 ................................................................................................................................. 509 12.14 Wrap-Up ....................................................................................................................................................................... 517 13. Standard Library Containers and Iterators ................................................................................................................ 519 13.1 Introduction .................................................................................................................................................................. 520 13.2 Introduction to Containers3 ...................................................................................................................................... 522 13.3 Working with Iterators .............................................................................................................................................. 528 13.4 A Brief Introduction to Algorithms ......................................................................................................................... 534 13.5 Sequence Containers ................................................................................................................................................... 534 13.6 vector Sequence Container ...................................................................................................................................... 535 7 13.7 list Sequence Container .......................................................................................................................................... 542 13.8 deque Sequence Container ........................................................................................................................................ 547 13.9 Associative Containers ............................................................................................................................................... 548 13.10 Container Adaptors ................................................................................................................................................... 557 13.11 bitset Near Container ............................................................................................................................................. 561 13.12 Optional: A Brief Intro to Big O .............................................................................................................................. 563 13.13 Optional: A Brief Intro to Hash Tables ................................................................................................................. 566 13.14 Wrap-Up ....................................................................................................................................................................... 568 14. Standard Library Algorithms and C++20 Ranges & Views ...................................................................................... 569 14.1 Introduction .................................................................................................................................................................. 570 14.2 Algorithm Requirements: C++20 Concepts ............................................................................................................ 571 14.3 Lambdas and Algorithms .......................................................................................................................................... 574 14.4 Algorithms ..................................................................................................................................................................... 577 14.5 Function Objects (Functors) ...................................................................................................................................... 615 14.6 Projections ..................................................................................................................................................................... 620 20 14.7 C++20 Views and Functional-Style Programming ......................................................................................... 622 14.8 Intro to Parallel Algorithms ...................................................................................................................................... 629 14.9 Standard Library Algorithm Summary ................................................................................................................. 630 14.10 A Look Ahead to C++23 Ranges .............................................................................................................................. 633 14.11 Wrap-Up ....................................................................................................................................................................... 634 15. Templates, C++20 Concepts and Metaprogramming ................................................................................................ 636 15.1 Introduction .................................................................................................................................................................. 637 15.2 Custom Class Templates and Compile-Time Polymorphism ............................................................................ 640 20 15.3 C++20 Function Template Enhancements ....................................................................................................... 645 20 15.4 C++20 Concepts: A First Look .............................................................................................................................. 647 15.5 Type Traits ..................................................................................................................................................................... 656 20 15.6 C++20 Concepts: A Deeper Look ......................................................................................................................... 661 15.7 Testing C++20 Concepts with static_assert ............................................................................................................ 672 15.8 Creating a Custom Algorithm ................................................................................................................................... 674 15.9 Creating a Custom Container and Iterators .......................................................................................................... 676 15.10 Default Arguments for Template Type Parameters ......................................................................................... 690 15.11 Variable Templates ................................................................................................................................................... 691 15.12 Variadic Templates and Fold Expressions .......................................................................................................... 691 15.13 Template Metaprogramming ................................................................................................................................. 706 15.14 Wrap-Up ....................................................................................................................................................................... 717 16. C++20 Modules: Large-Scale Development ................................................................................................................. 718 16.1 Introduction .................................................................................................................................................................. 719 8 16.2 Compilation and Linking Before C++20 ................................................................................................................. 721 16.3 Advantages and Goals of Modules .......................................................................................................................... 722 16.4 Example: Transitioning to Modules—Header Units ........................................................................................... 723 16.5 Modules Can Reduce Translation Unit Sizes and Compilation Times ........................................................... 726 16.6 Example: Creating and Using a Module ................................................................................................................. 727 16.7 Global Module Fragment ........................................................................................................................................... 735 16.8 Separating Interface from Implementation ......................................................................................................... 736 16.9 Partitions ........................................................................................................................................................................ 743 16.10 Additional Modules Examples ............................................................................................................................... 751 16.11 Migrating Code to Modules ..................................................................................................................................... 757 16.12 Future of Modules and Modules Tooling ............................................................................................................ 757 16.13 Wrap-Up ....................................................................................................................................................................... 759 17. Parallel Algorithms and Concurrency: A High-Level View ..................................................................................... 765 17.1 Introduction .................................................................................................................................................................. 766 17 17.2 Standard Library Parallel Algorithms (C++17) ............................................................................................... 768 17.3 Multithreaded Programming ................................................................................................................................... 776 17.4 Launching Tasks with std::jthread ..................................................................................................................... 781 17.5 Producer–Consumer Relationship: A First Attempt ........................................................................................... 785 17.6 Producer–Consumer: Synchronizing Access to Shared Mutable Data .......................................................... 792 17.7 Producer–Consumer: Minimizing Waits with a Circular Buffer ..................................................................... 804 17.8 Readers and Writers ................................................................................................................................................... 812 17.9 Cooperatively Canceling jthreads .......................................................................................................................... 813 17.10 Launching Tasks with std::async ....................................................................................................................... 816 17.11 Thread-Safe, One-Time Initialization ................................................................................................................... 823 17.12 A Brief Introduction to Atomics ............................................................................................................................. 824 20 17.13 Coordinating Threads with C++20 Latches and Barriers .......................................................................... 827 20 17.14 C++20 Semaphores ............................................................................................................................................... 834 17.15 C++23: A Look to the Future of C++ Concurrency ............................................................................................. 837 17.16 Wrap-Up ....................................................................................................................................................................... 838 18. C++20 Coroutines ............................................................................................................................................................... 840 18.1 Introduction .................................................................................................................................................................. 840 18.2 Coroutine Support Libraries ..................................................................................................................................... 841 18.3 Installing the concurrencpp and generator Libraries ...................................................................................... 843 18.4 Creating a Generator Coroutine with co_yield and the generator Library ............................................... 843 18.5 Launching Tasks with concurrencpp ..................................................................................................................... 847 18.6 Creating a Coroutine with co_await and co_return .......................................................................................... 851 18.7 Low-Level Coroutines Concepts ............................................................................................................................... 858 9 18.8 C++23 Coroutines Enhancements ............................................................................................................................ 861 18.9 Wrap-Up ......................................................................................................................................................................... 861 19. Stream I/O & C++20 Text Formatting ............................................................................................................................ 862 19.1 Introduction .................................................................................................................................................................. 863 19.2 Streams ........................................................................................................................................................................... 863 19.3 Stream Output .............................................................................................................................................................. 865 19.4 Stream Input ................................................................................................................................................................. 866 19.5 Unformatted I/O Using read, write and gcount .................................................................................................. 870 19.6 Stream Manipulators .................................................................................................................................................. 871 19.7 Stream Error States ..................................................................................................................................................... 884 19.8 Tying an Output Stream to an Input Stream ........................................................................................................ 887 20 19.9 C++20 Text Formatting .......................................................................................................................................... 887 19.10 Wrap-Up ....................................................................................................................................................................... 892 20. Other Topics and a Look Toward the Future of C++ ................................................................................................. 894 20.1 Introduction .................................................................................................................................................................. 895 20.2 const_cast Operator .................................................................................................................................................. 895 20.3 Storage Classes and Storage Duration .................................................................................................................... 897 20.4 namespaces ..................................................................................................................................................................... 900 20.5 Operator Keywords ..................................................................................................................................................... 904 20.6 Pointers to Class Members (.* and ->*) ................................................................................................................ 906 20.7 Case Study: Payroll System Using Polymorphism and Runtime Type Information — Downcasting, dynamic_cast, typeid and type_info .................................................................................................. 907 11 20.8 Inheriting Base-Class Constructors .................................................................................................................... 910 17 20.9 C++17 and C++20: [[nodiscard]] Attribute .................................................................................................... 911 20.10 shared_ptr and weak_ptr Smart Pointers .......................................................................................................... 912 11 20.11 Trailing Return Types for Functions ............................................................................................................... 923 20.12 decltype....................................................................................................................................................................... 923 20.13 initializer_list Class Template ........................................................................................................................ 924 20 20.14 C++20: [[likely]] and [[unlikely]] Attributes ....................................................................................... 925 23 20.15 A Look Toward C++23 ......................................................................................................................................... 926 20.16 Wrap-Up ....................................................................................................................................................................... 928 20.17 Closing Notes ............................................................................................................................................................... 929 A. Operator Precedence and Grouping ............................................................................................................................... 930 B. Character Set ......................................................................................................................................................................... 934 C. Number Systems .................................................................................................................................................................. 935 C.1 Introduction .................................................................................................................................................................... 935 C.2 Abbreviating Binary Numbers as Octal and Hexadecimal Numbers .............................................................. 939 10

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.