Imperfect C++ : Practical Solutions for Real-Life Programming
暫譯: 不完美的 C++:實用的現實編程解決方案
Matthew Wilson
- 出版商: Addison Wesley
- 出版日期: 2004-10-21
- 售價: $1,920
- 貴賓價: 9.5 折 $1,824
- 語言: 英文
- 頁數: 624
- 裝訂: Paperback
- ISBN: 0321228774
- ISBN-13: 9780321228772
-
相關分類:
C++ 程式語言
立即出貨(限量) (庫存=10)
買這商品的人也買了...
-
$920$727 -
$590$466 -
$750$638 -
$560$476 -
$2,370$2,252 -
$850$723 -
$750$593 -
$780$616 -
$890$703 -
$620$490 -
$990$782 -
$780$616 -
$480$408 -
$650$514 -
$1,600$1,520 -
$675LPIC 1 Exam Cram 2: Linux Professional Institute Certification Exams 101 and 102 (Paperback)
-
$650$553 -
$380$300 -
$890$703 -
$650$507 -
$580$452 -
$399$339 -
$620$527 -
$650$507 -
$1,200$1,176
相關主題
商品描述
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.
Table of Contents:
I. FUNDAMENTALS.
1. Enforcing Design: Constraints, Contracts, and Assertions.
Eggs and Ham.
Compile-Time Contracts: Constraints.
Runtime Contracts: Preconditions, Postconditions, and Invariants.
Assertions.
2. Object Lifetime.
The Object Life Cycle.
Controlling Your Clients.
MILs and Boon.
3. Resource Encapsulation.
A Taxonomy of Resource Encapsulation.
POD Types.
Wrapper Proxies.
RRID Types.
RAII Types.
RAII Coda.
4. Data Encapsulation and Value Types.
A Taxonomy of Data Encapsulation.
Value Types and Entity Types.
A Taxonomy of Value Types.
Open Types.
Encapsulated Types.
Value Types.
Arithmetic Value Types.
Value Types Coda.
Encapsulation Coda.
5. Object Access Models.
Vouched Lifetimes.
Copied for Caller.
Given to Caller.
Shared Objects.
6. Scoping Classes.
Value.
State.
APIs and Services.
Language Features.
II. SURVIVING THE REAL WORLD.
7. ABI.
Sharing Code.
C ABI Requirements.
C++ ABI Requirements.
I Can C Clearly Now.
8. Objects Across Borders.
Mostly Portable vtables?
Portable vtables.
ABI/OAB Coda.
9. Dynamic Libraries.
Calling Functions Explicitly.
Indentity: Link Units and Link Space.
Lifetime.
Versioning.
Resource Ownership.
Dynamic Libraries: Coda.
10. Threading.
Synchronizing Integer Access.
Synchronizing Block Access: Critical Regions.
Atomic Integer Performance.
Multithreading Extensions.
Thread Specific Storage.
11. Statics.
Nonlocal Static Objects: Globals.
Singletons.
Function-Local Static Objects.
Static Members.
Statics Coda.
12. Optimization.
Inline Functions.
Return Value Optimization.
Empty Base Optimization.
Empty Derived Optimization.
Preventing Optimization.
III. LANGUAGE CONCERNS.
13. Fundamental Types.
May I Have a byte?
Fixed-Sized Integer Types.
Large Integer Types.
Dangerous Types.
14. Arrays and Pointers.
Don't Repeat Yourself.
Arrays Decay into Pointers.
dimensionof().
Cannot Pass Arrays to Functions.
Arrays Are Always Passed by Address.
Arrays of Inherited Types.
Cannot Have Multidimensional Arrays.
15. Values.
NULL-The Keyword That Wasn't.
Down to Zero.
Bending the Truth.
Literals.
Constants.
16. Keywords.
interface.
temporary.
owner.
explicit(_cast).
unique.
final.
Unsupported Keywords.
17. Syntax.
Class Layout.
Conditional Expressions.
for.
Variable Notation.
18. Typedefs.
Pointer typedefs.
What's in a Definition?
Aliases.
True Typedefs.
The Good, the Bad, and the Ugly.
IV. COGNIZANT CONVERSIONS.
19. Casts.
Implicit Conversion.
Casting in C++.
The Case for C Casts.
Casts on Steroids.
explicit_cast.
literal_cast.
union_cast.
comstl::interface_cast.
boost::polymorphic_cast.
Casts: Coda.
20. Shims.
Embracing Change and Enhancing Flexibility.
Attribute Shims.
Logical Shims.
Control Shims.
Conversion Shims.
Composite Shim Concepts.
Namespaces and Koenig Lookup.
Why Not Traits?
Structural Conformance.
Breaking Up the Monolith.
Shims: Coda.
21. Veneers.
Lightweight RAII.
Binding Data and Operations.
Rubbing Up to Concepts.
Veneers: Coda.
22. Bolt-ins.
Adding Functionality.
Skin Selection.
Nonvirtual Overriding.
Leveraging Scope.
Simulated Compile-Time Polymorphism: Reverse Bolt-ins.
Parameterized Polymorphic Packaging.
Bolt-ins: Coda.
23. Template Constructors.
Hidden Costs.
Dangling References.
Template Constructor Specialization.
Argument Proxies.
Argument Targeting.
Template Constructors: Coda.
V. OPERATORS.
24. operator bool().
operator int() const.
operator void () const.
operator bool() const.
operator !()-not!.
operator boolean const () const.
operator int boolean::() const.
Operating in the Real World.
operator!.
25. Fast, Non-intrusive String Concatenation.
fast_string_concatenator<>.
Performance.
Working with Other String Classes.
Concatenation Seeding.
Pathological Bracing.
Standardization.
26. What's Your Address?
Can't Get the Real Address.
What Actions Are Carried Out during Conversion?
What Do We Return?
What's Your Address: Coda.
27. Subscript Operators.
Pointer Conversion versus Subscript Operators.
Handling Errors.
Return Value.
28. Increment Operators.
Missing Postfix Operators.
Efficiency.
29. Arithmetic Types.
Class Definition.
Default Construction.
Initialization (Value Construction).
Copy Construction.
Assignment.
Arithmetic Operators.
Comparison Operators.
Accessing the Value.
sinteger64.
Truncations, Promotions, and Tests.
Arithmetic Types: Coda.
30. Short-circuit!
VI. EXTENDING C++.
31. Return Value Lifetime.
A Taxonomy of Return Value Lifetime Gotchas.
Why Return-by-Reference?
Solution 1-integer_to_string<>.
Solution 2-TSS.
Solution 3-Extending RVL.
Solution 4-Static Array Size Determination.
Solution 5-Conversion Shims.
Performance.
RVL: The Big Win for Garbage Collection.
Potential Applications.
Return Value Lifetime: Coda.
32. Memory.
A Taxonomy of Memory.
The Best of Both Worlds.
Allocators.
Memory: Coda.
33. Multidimensional Arrays.
Facilitating Subscript Syntax.
Sized at Run Time.
Sized at Compile Time.
Block Access.
Performance.
Multidimensional Arrays: Coda.
34. Functors and Ranges.
Syntactic Clutter.
for_all() ?
Local Functors.
Ranges.
Functors and Ranges: Coda.
35. Properties.
Compiler Extensions.
Implementation Options.
Field Properties.
Method Properties.
Static Properties.
Virtual Properties.
Property Uses.
Properties: Coda.
Appendix A. Compilers and Libraries.
Compilers.
Libraries.
Other Resources.
Appendix B. "Watch That Hubris!"
Operator Overload.
DRY Rued Yesterday.
Paranoid Programming.
To Insanity, and Beyond!
Appendix C. Arturius.
Appendix D. The CD.
Epilogue.
Bibliography.
Index.
商品描述(中文翻譯)
描述:
《不完美的 C++》
C++ 雖然是一種奇妙的語言,但並不完美。Matthew Wilson 已經使用 C++ 超過十年,在這段時間裡,他發現了許多固有的限制,這些限制需要巧妙的變通方法。在這本書中,他不僅告訴你 C++ 的問題所在,還提供了實用的技術和工具,以編寫更健壯、靈活、高效和可維護的代碼。他向你展示如何駕馭 C++ 的複雜性,穿越其龐大的範式,重新掌控你的代碼,並獲得更好的結果。
如果你是一位長期的 C++ 開發者,這本書將幫助你以新的方式看待你的編程挑戰,並揭示你可能從未嘗試過的強大技術。如果你是 C++ 的新手,你將學到一些原則,這些原則將使你在所有項目中更有效率。在這個過程中,你將學會如何:
克服 C++ 類型系統的不足
通過約束、合約和斷言來強制執行軟體設計
處理標準忽略的行為——包括與動態庫、靜態對象和線程相關的問題
實現動態加載組件之間的二進制兼容性
理解隱式轉換的成本和缺點——以及替代方案
提高與各種編譯器、庫和操作環境的兼容性
幫助你的編譯器檢測更多錯誤並更有效地工作
理解影響可靠性的風格方面
將資源獲取即初始化(Resource Acquisition Is Initialization)機制應用於各種問題領域
管理數組和指針之間有時晦澀的關係
使用模板編程來提高靈活性和健壯性
擴展 C++:包括快速字符串連接、真正的 NULL 指針、靈活的內存緩衝區、屬性、多維數組和範圍
隨書附贈的 CD-ROM 包含各種有價值的 C++ 編譯器、庫、測試程序、工具和實用程序,以及作者相關的期刊文章。新的和更新的缺陷,以及軟體庫和示例代碼可在線獲得,網址為 http://imperfectcplusplus.com。
目錄:
I. 基礎知識。
1. 強制設計:約束、合約和斷言。
- 蛋和火腿。
- 編譯時合約:約束。
- 運行時合約:前置條件、後置條件和不變式。
- 斷言。
2. 對象生命週期。
- 對象生命週期。
- 控制你的客戶。
- MILs 和 Boon。
3. 資源封裝。
- 資源封裝的分類法。
- POD 類型。
- 包裝代理。
- RRID 類型。
- RAII 類型。
- RAII 結尾。
4. 數據封裝和值類型。
- 數據封裝的分類法。
- 值類型和實體類型。
- 值類型的分類法。
- 開放類型。
- 封裝類型。
- 值類型。
- 算術值類型。
- 值類型結尾。
- 封裝結尾。
5. 對象訪問模型。
- 擔保生命週期。
- 為調用者複製。
- 給調用者。
- 共享對象。
6. 範圍類。
- 值。
- 狀態。
- API 和服務。
- 語言特性。
II. 在現實世界中生存。
7. ABI。
- 共享代碼。
- C ABI 要求。
- C++ ABI 要求。
- 我現在可以清楚地看見 C。
8. 跨邊界的對象。
- 大多數可攜帶的 vtables?
- 可攜帶的 vtables。
- ABI/OAB 結尾。
9. 動態庫。
- 明確調用函數。
- 身份:鏈接單元和鏈接空間。
- 生命週期。
- 版本控制。
- 資源擁有權。
- 動態庫:結尾。
10. 線程。
- 同步整數訪問。
- 同步區塊訪問:臨界區域。
- 原子整數性能。
- 多線程擴展。