توضیحاتی در مورد کتاب C++ Initialization Story: A Guide Through All Initialization Options and Related C++ Areas
نام کتاب : C++ Initialization Story: A Guide Through All Initialization Options and Related C++ Areas
ویرایش : 1
عنوان ترجمه شده به فارسی : داستان راهاندازی C: راهنمای همه گزینههای راهاندازی و مناطق C مرتبط
سری :
نویسندگان : Bartłomiej Filipek
ناشر : Leanpub
سال نشر : 2022
تعداد صفحات : 275
زبان کتاب : English
فرمت کتاب : pdf
حجم کتاب : 2 مگابایت
بعد از تکمیل فرایند پرداخت لینک دانلود کتاب ارائه خواهد شد. درصورت ثبت نام و ورود به حساب کاربری خود قادر خواهید بود لیست کتاب های خریداری شده را مشاهده فرمایید.
فهرست مطالب :
Table of Contents
About the Book
Why should you read this book?
Learning objectives
The structure of the book
Who is this book for?
Prerequisites
Reader feedback & errata
Example code
Code license
Formatting
Special sections
About the Author
Acknowledgements
Revision History
Local Variables and Simple Types
Starting with simple types
Setting values to zero
Initialization with aggregates
Default data member initialization
Summary
Initialization With Constructors
A simple class type
Basics of constructors
Body of a constructor
Adding constructors to DataPacket
Compiler-generated default constructors
Explicit constructors and conversions
Difference between direct and copy initialization
Implicit conversion and converting constructors
Constructor summary
Copy and Move Operations
Copy constructor
Move constructor
Distinguishing from assignment
Adding debug logging to constructors
Trivial classes and user-provided default constructors
Delegating and Inheriting Constructors
Delegating constructors
Limitations
Inheritance
Inheriting constructors
Destructors
Basics
Objects allocated on the heap
Destructors and data members
Virtual destructors and polymorphism
Partially created objects
A compiler-generated destructor
Summary and use cases
Type Deduction and Initialization
Deduction with auto
Rules for auto type deduction
Deduction with decltype
Printing type info
Structured bindings in C++17
Lifetime extension, references, and loops
Almost Always Auto
Summary
Quiz from Chapters 1…6
Non-Static Data Member Initialization
How it works
Investigation
Experiments
Other forms of NSDMI
Copy constructor and NSDMI
Move constructor and NSDMI
C++14 changes
C++20 changes
Limitations of NSDMI
NSDMI: Advantages and Disadvantages
NSDMI summary
Containers as Data Members
The basics
Using std::initializer list
Example implementation
The cost of copying elements
Some inconvenience - non-copyable types
More options (advanced)
Summary
Non-regular Data Members
Constant non-static data members
Pointers as data members
Smart pointers as data members
References as data members
Summary
Non-local objects
Storage duration and linkage
Initialization of non-local static objects
constinit in C++20
Static variables in a function scope
About static data members
Motivation for inline variables
Global inline variables
constexpr and inline variables
Summary
Aggregates and Designated Initializers in C++20
Aggregates in C++20
The basics of Designated Initializers
Rules
Advantages of designated initialization
Examples
Summary
Techniques and Use Cases
Using explicit for strong types
Best way to initialize string data members
Reducing extra copies through emplace and in_place
The copy and swap idiom
CRTP class counter
Several initialization types in one class
Meyer\'s Singleton and C++11
Factory with self-registering types and static initialization
Summary
The Final Quiz And Exercises
Exercises
Appendix A - Rules for Special Member Function Generation
The diagram
Rules
Appendix B - Quiz and Exercises Answers
The quiz from chapters 1…6
The final quiz
Solution to the first coding problem, NSDMI
Solution to the second coding problem, NSDMI
Solution to the third coding problem, inline
Solution to the fourth coding problem, fix code
References