Book description
Imperfect C++
C++, although a marvelous language, isn't perfect. Matthew Wilson has been working with it for over a decade, and during that time he has found inherent limitations that require skillful workarounds. In this book, he doesn't just tell you what's wrong with C++, but offers practical techniques and tools for writing code that's more robust, flexible, efficient, and maintainable. He shows you how to tame C++'s complexity, cut through its vast array of paradigms, take back control over your code—and get far better results.
If you're a long-time C++ developer, this book will help you see your programming challenges in new ways—and illuminate powerful techniques you may never have tried. If you're newer to C++, you'll learn principles that will make you more effective in all of your projects. Along the way, you'll learn how to:
Overcome deficiencies in C++'s type system
Enforce software design through constraints, contracts, and assertions
Handle behavior ignored by the standard— including issues related to dynamic libraries, static objects, and threading
Achieve binary compatibility between dynamically loading components
Understand the costs and disadvantages of implicit conversions—and the alternatives
Increase compatibility with diverse compilers, libraries, and operating environments
Help your compiler detect more errors and work more effectively
Understand the aspects of style that impact reliability
Apply the Resource Acquisition Is Initialization mechanism to a wide variety of problem domains
Manage the sometimes arcane relationship between arrays and pointers
Use template programming to improve flexibility and robustness
Extend C++: including fast string concatenation, a true NULL-pointer, flexible memory buffers, Properties, multidimensional arrays, and Ranges
The CD-ROM contains a valuable variety of C++ compilers, libraries, test programs, tools, and utilities, as well as the author's related journal articles. New and updated imperfections, along with software libraries and example code are available online at http://imperfectcplusplus.com.
© Copyright Pearson Education. All rights reserved.
Table of contents
- Copyright
- Preface
- Prologue: Philosophy of the Imperfect Practitioner
- Imperfections, Constraints, Definitions, and Recommendations
-
One. Fundamentals
- 1. Enforcing Design: Constraints, Contracts, and Assertions
- 2. Object Lifetime
- 3. Resource Encapsulation
- 4. Data Encapsulation and Value Types
- 5. Object Access Models
- 6. Scoping Classes
-
Two. Surviving the Real World
- 7. ABI
- 8. Objects Across Borders
- 9. Dynamic Libraries
- 10. Threading
- 11. Statics
- 12. Optimization
-
Three. Language Concerns
- 13. Fundamental Types
- 14. Arrays and Pointers
- 15. Values
- 16. Keywords
- 17. Syntax
- 18. Typedefs
-
Four. Cognizant Conversions
- 19. Casts
-
20. Shims
- 20.1. Embracing Change and Enhancing Flexibility
- 20.2. Attribute Shims
- 20.3. Logical Shims
- 20.4. Control Shims
- 20.5. Conversion Shims
- 20.6. Composite Shim Concepts
- 20.7. Namespaces and Koenig Lookup
- 20.8. Why Not Traits?
- 20.9. Structural Conformance
- 20.10. Breaking Up the Monolith
- 20.11. Shims: Coda
- 21. Veneers
- 22. Bolt-ins
- 23. Template Constructors
-
Five. Operators
- 24. operator bool()
- 25. Fast, Non-intrusive String Concatenation
- 26. What's Your Address?
- 27. Subscript Operators
- 28. Increment Operators
-
29. Arithmetic Types
- 29.1. Class Definition
- 29.2. Default Construction
- 29.3. Initialization (Value Construction)
- 29.4. Copy Construction
- 29.5. Assignment
- 29.6. Arithmetic Operators
- 29.7. Comparison Operators
- 29.8. Accessing the Value
- 29.9. sinteger64
- 29.10. Truncations, Promotions, and Tests
- 29.11. Arithmetic Types: Coda
- 30. Short-circuit!
-
Six. Extending C++
-
31. Return Value Lifetime
- 31.1. A Taxonomy of Return Value Lifetime Gotchas
- 31.2. Why Return-by-Reference?
- 31.3. Solution 1—integer_to_string<>
- 31.4. Solution 2—TSS
- 31.5. Solution 3—Extending RVL
- 31.6. Solution 4—Static Array Size Determination
- 31.7. Solution 5—Conversion Shims
- 31.8. Performance
- 31.9. RVL: The Big Win for Garbage Collection
- 31.10. Potential Applications
- 31.11. Return Value Lifetime: Coda
- 32. Memory
- 33. Multidimensional Arrays
- 34. Functors and Ranges
- 35. Properties
-
31. Return Value Lifetime
- A. Compilers and Libraries
- B. “Watch That Hubris!”
- C. Arturius
- D. The CD
- Epilogue
- Bibliography
Product information
- Title: Imperfect C++ Practical Solutions for Real-Life Programming
- Author(s):
- Release date: October 2004
- Publisher(s): Addison-Wesley Professional
- ISBN: 9780321228772
You might also like
book
C++ Gotchas: Avoiding Common Problems in Coding and Design
"This may well be the best C++ book I have ever read. I was surprised by …
book
Practical C++ Metaprogramming
To say that C++ programmers embrace metaprogramming is a real stretch. Outright rejection is probably more …
book
More Exceptional C++
Organized in a practical problem-and-solution format, picks up where the widely acclaimed More Exceptional C++ leaves …
book
C++ All-In-One For Dummies®, 2nd Edition
Here’s the easy way to learn how to use C++ C++, developed by Bjarne Stroustrup at …