<p><strong>Preface xvii</strong><br>Reasons to Learn C++ xvii</p> <p>Reasons to Read This Book xviii</p> <p>The Beauty and the Beast xviii</p> <p>Languages in Science and Engineering xix</p> <p>Typographical Conventions xx</p> <p>Acknowledgments xxiii</p> <p>About the Author xxv</p> <p><strong>Chapter 1: C++ Basics 1</strong></p> <p>1.1 Our First Program 1</p> <p>1.2 Variables 3</p> <p>1.3 Operators 10</p> <p>1.4 Expressions and Statements 21</p> <p>1.5 Functions 28</p> <p>1.6 Error Handling 34</p> <p>1.7 I/O 40</p> <p>1.8 Arrays, Pointers, and References 47</p> <p>1.9 Structuring Software Projects 58</p> <p>1.10 Exercises 63</p> <p><strong>Chapter 2: Classes 65</strong></p> <p>2.1 Program for Universal Meaning Not for Technical Details 65</p> <p>2.2 Members 67</p> <p>2.3 Setting Values: Constructors and Assignments 72</p> <p>2.4 Destructors 89</p> <p>2.5 Method Generation Résumé 95</p> <p>2.6 Accessing Member Variables 96</p> <p>2.7 Operator Overloading Design 100</p> <p>2.8 Exercises 104</p> <p><strong>Chapter 3: Generic Programming 107</strong></p> <p>3.1 Function Templates 107</p> <p>3.2 Namespaces and Function Lookup 115</p> <p>3.3 Class Templates 123</p> <p>3.4 Type Deduction and Definition 131</p> <p>3.5 A Bit of Theory on Templates: Concepts 136</p> <p>3.6 Template Specialization 136</p> <p>3.7 Non-Type Parameters for Templates 144</p> <p>3.8 Functors 146</p> <p>3.9 Lambda 154</p> <p>3.10 Variadic Templates 159</p> <p>3.11 Exercises 161</p> <p><strong>Chapter 4: Libraries 165</strong></p> <p>4.1 Standard Template Library 165</p> <p>4.2 Numerics 186</p> <p>4.3 Meta-programming 198</p> <p>4.4 Utilities 202</p> <p>4.5 The Time Is Now 209</p> <p>4.6 Concurrency 211</p> <p>4.7 Scientific Libraries Beyond the Standard 213</p> <p>4.8 Exercises 215</p> <p><strong>Chapter 5: Meta-Programming 219</strong></p> <p>5.1 Let the Compiler Compute 219</p> <p>5.2 Providing and Using Type Information 226</p> <p>5.3 Expression Templates 245</p> <p>5.4 Meta-Tuning: Write Your Own Compiler Optimization 253</p> <p>5.5 Exercises 283</p> <p><strong>Chapter 6: Object-Oriented Programming 287</strong></p> <p>6.1 Basic Principles 287</p> <p>6.2 Removing Redundancy 298</p> <p>6.3 Multiple Inheritance 299</p> <p>6.4 Dynamic Selection by Sub-typing 306</p> <p>6.5 Conversion 308</p> <p>6.6 CRTP 316</p> <p>6.7 Exercises 320</p> <p><strong>Chapter 7: Scientific Projects 321</strong></p> <p>7.1 Implementation of ODE Solvers 321</p> <p>7.2 Creating Projects 332</p> <p>7.3 Some Final Words 345</p> <p><strong>Appendix A: Clumsy Stuff 347</strong></p> <p>A.1 More Good and Bad Scientific Software 347</p> <p>A.2 Basics in Detail 353</p> <p>A.3 Real-World Example: Matrix Inversion 362</p> <p>A.4 Class Details 371</p> <p>A.5 Method Generation 375</p> <p>A.6 Template Details 386</p> <p>A.7 Using std::vector in C++03 391</p> <p>A.8 Dynamic Selection in Old Style 392</p> <p>A.9 Meta-Programming Details 392</p> <p><strong>Appendix B: Programming Tools 403</strong></p> <p>B.1 gcc 403</p> <p>B.2 Debugging 404</p> <p>B.3 Memory Analysis 408</p> <p>B.4 gnuplot 409</p> <p>B.5 Unix, Linux, and Mac OS 411</p> <p><strong>Appendix C: Language Definitions 413</strong></p> <p>C.1 Value Categories 413</p> <p>C.2 Operator Overview 413</p> <p>C.3 Conversion Rules 416</p> <p>Bibliography 419</p> <p>Index 423</p>