See My New Guide: C++ Initialization Story

[ad_1]

I’m pleased to announce that my new ebook on C++ Initialization is printed and completed!

Take a look on the background story and the way to get it.

Updates: Go to the most recent updates from twenty third Dec right here, 30 new pages added!

Be aware: Initially, the ebook was known as “Knowledge Member Initialization in Trendy C++”, however in September 2022, I up to date it closely and adjusted the title.

In regards to the ebook

 

As for my different books, I used the Leanpub platform for the PDF/Epub technology. Right here’s the ebook’s web site:


C++ Initialization Story @Leanpub

And in addition take a look at Goodreads: C++ Initialization Story by Bartłomiej Filipek and depart youre evaluation.

Why I wrote the ebook?

 

Initialization in C++ is a sizzling subject. With every C++ Commonplace, we’ll get some updates to the syntax, guidelines, and new capabilities. With this ebook, I needed to make clear the confusion and make it easier to cause about Trendy C++ code.

Have I succeeded?

It’s C++, and also you’ll see many opinions, particular circumstances, and even contradicting examples. But, I’m proud of my content material, and it ought to actually enhance your information and develop your views.

It could look scary to some folks, although…

“what??? 275 pages on simply initialization???”

I didn’t simply need to write ten pages stuffed with guidelines; as a substitute, I attempted to current C++ from the angle of the initialization. And since initialization touches so many elements of C++… right here we’re with that web page depend. Amongst these guidelines, you’ll discover many important methods and common good practices for contemporary C++.

Studying targets

 

The objective is to equip you with the next information:

  • Clarify guidelines about object initialization, together with common variables, knowledge members, and non-local objects.
  • The way to implement particular member capabilities (constructors, destructors, copy/transfer operations) and when they’re useful.
  • The way to effectively initialize non-static knowledge members utilizing C++11 options like non-static knowledge member initialization, inheriting, and delegating constructors.
  • The way to streamline working with static variables and static knowledge members with inline variables from C++17.
  • The way to work with container-like members, non-copyable knowledge members (like const knowledge members) or move-able solely knowledge members, and even lambdas.
  • What’s an combination, and the way to create such objects with designated initializers from C++20.

The construction of the ebook

 

The ebook comprises 14 chapters within the following construction:

  • Chapters 1 to five create a basis for the remainder of the ebook. They cowl primary initialization guidelines, constructors, destructors, and the fundamentals of information members.
  • Chapter 6 is a brief quiz on constructors. You may examine your information from the primary “half” of the ebook.
  • Chapter 7 Kind deduction: auto, decltype, AAA
  • Chapter 8 describes Non-static Knowledge Member Initialization (NSDMI), a robust function from C++11 that improves how we work with knowledge members. On the finish of the chapter, you possibly can resolve just a few workouts.
  • Chapter 9 discusses the way to initialize container-like knowledge members.
  • Chapter 10 comprises details about non-regular knowledge members and the way to deal with them in a category. You’ll study const knowledge members, unique_ptr as a knowledge member, and references.
  • Chapter 11 describes static non-local variables, static objects, varied storage period choices, inline variables from C++17 and constinit from C++20.
  • Chapter 12 strikes to C++20 and describes Designated Initializers, a useful function primarily based on related factor from the C language.
  • Chapter 13 reveals varied methods like passing strings into constructors, sturdy typing, CRTP class counter, Copy and swap idiom, and extra.
  • Chapter 14 is the ultimate quiz with questions from the entire ebook.

And there are two appendices:

  • Appendix A – a useful information about guidelines for compiler-generated particular member capabilities.
  • Appendix B – solutions to quizzes and workouts.

In complete it’s 275 pages!

Background for the ebook

 

Lengthy story quick: just a few years in the past, I wrote an article about NSDMI and bought interested by how issues work for knowledge members. Final yr I created a mini-course on the Educative platform. Beginning this yr, I needed to carry the PDF model… and it appears like I found and described much more stuff 🙂

Right here’s the preliminary article from 2015: Non Static Knowledge Members Initialization – C++ Tales. And the course at Educative: Initializing Knowledge Members: From C++11 until C++20.

Initially, after changing the teachings right into a pdf, I bought one thing round 60 pages. However then I spotted it might be higher to explain issues with extra examples and use circumstances. After digging, investigating, speaking to varied folks… I ended up with 100 pages and now (Dec 2022) with 275 pages 🙂 Whereas the web page depend just isn’t the one issue for the ebook, I imagine it corresponds to the standard and sensible information I put inside.

As a brand new experiment, I put quizzes and workouts in an effort to follow and examine your information. There’s no have to arrange any coding atmosphere for these duties, as you possibly can simply use Compiler Explorer hyperlinks and run all of the code within the browser. This additionally works for 70+ examples yow will discover throughout the ebook – open the hyperlink and see how the code works.

Supply code:

You may see all examples at this GitHub repository:

https://github.com/fenbf/cppinitbook_public

Updates and plans

 

Final replace: twenty third December:

  • Added a brand new chapter on Deduction (auto, decltype, AAA)
  • dded new sections within the methods chapter: in_place development, Singletons, Factories
  • Improved quiz sections, added new questions and one train
  • plenty of structure fixes and enhancements

Additionally, take a look at my video describing thread_local:


Plans

 

The ebook is 100% “content material” prepared!

Now, I need to enhance some structure, add index and put together the print model for Amazon KDP.

At present, the value is about to the minimal value of seven.99$ obtainable at Leanpub, however when the ebook is prepared, it would go up.

CCurrently, the value is about to 9.99$ at Leanpub, however when the ebook is prepared, it would go up. In all probability to round 12$.

At present the value is about to 15.99$.

However right here’s a coupon code legitimate in December to purchase it on the “previous” value:

https://leanpub.com/cppinitbook/c/olddecprice

Acknowledgements

 

This ebook wouldn’t be doable with out beneficial enter from many C++ specialists and mates.

I particularly want to thank to the next folks:

They spent loads of time discovering even little issues that may very well be improved and prolonged.

Final however not least, I bought loads of suggestions and feedback from the weblog readers, Patreon Discord Server (See @C++Tales @Patreon), and discussions at C++ Polska. Thanks all!

With the entire assist from these sort folks, the ebook high quality bought higher and higher!

Asking for assist and evaluation:

 

Please be a part of the reviewer record by offering me along with your strategies and enhancements. I’m pleased to replace the ebook. Simply ship an e mail to bartek AT cppstories.com.

If you have already got the ebook, please add your evaluation at: C++ Initialization Story by Bartłomiej Filipek | Goodreads.

Changelog

 

  • twentieth June 2022 – The primary public model! The books is sort of executed. Lacking elements: some sections in 10. Containers as Knowledge Members, some sections in 11. Non-regular Knowledge Members.
  • twenty second June 2022 – new sections on NSDMI, direct init and parens, extra about inheriting constructors, hyperlink to GoodReads, wording, hotfixes.
  • twenty fourth June 2022 – up to date the “copy and transfer constructor” chapter, typos and small wording enhancements.
  • sixteenth July 2022 – Containers as Knowledge Members chapter rewritten, noexcept consistency and noexcept transfer operations benefits within the transfer constructor part, wording, fixes, structure.
  • thirteenth September 2022 – modified title to “C++ Initialization Story”, tailored ebook construction, rewritten “Non-local objects” chapter (beforehand solely on inline variables), new extracted chapter on Methods, new part on CRTP.
  • 18th November 2022 – added 30 extra pages! closely up to date and accomplished “Non-regular knowledge members”) chapter, constinit and thread_local sections within the “Non-local objects” chapter, crammed the “implicit conversion” part within the “Constructors” chapter.
  • twenty third December 2022 – content material accomplished! Added Deduction chapter, crammed lacking sections within the Methods chapter. Format enhancements, just a few extra questions, workouts and fixes.

The way to Get the Guide?

 

Right here’s the hyperlink to the ebook @Leanpub:


C++ Initialization Story @Leanpub

Leanpub gives a 60-day refund interval!

And a number of other choices to get it cheaper:

It’s also possible to obtain a free pattern that comprises virtually 60 pages (obtainable from the Leanpub web page)!

[ad_2]

Leave a Reply

Your email address will not be published. Required fields are marked *