C++ Templates started in my mind in 1995, after I had developed a number of interesting template techniques (e.g., what would later be called expression templates). Some time before that, I had accidentally received a copy of an early draft of the C++ standard, and after reading it, I decided that a vulgarization of Chapter 14 (the templates chapter in the standard) along with an annotated catalog of my techniques would make a nice little book.
I had never written a book. I didn't know where to begin. I had no contacts in the publishing world. The book was just a castle in the air.
In those days I was a student at Rensselaer and after some time I got to know David Musser, well-known as one of the bright minds behind the STL. Dave had been asked to review a draft of the third edition of Bjarne Stroustrup's classic The C++ Programming Language, but because of lack of time he asked if I could be a reviewer instead. My review made Stroustrup suggest to Addison-Wesley that I might be a good person to prepare some web-pages with solutions to selected exercises presented in his new book. I accepted that project, and eventually it turned into a little book of its own: C++ Solutions.
C++ Solutions brought me in contact with the publishing process, and with Addison-Wesley in particular. So a few months after the publication of C++ Solutions I told my editors that I was interested in writing a more advanced book about C++ templates. As it turns out, they had observed that there was a growing demand for more advanced books about C++ programming, and so the project started.
Within a few short weeks I had about a hundred pages of material covering various significant portions of what are now parts 2 through 4. The presentation of that original material was, in hindsight, probably too terse (even for an advanced book). This brisk start was unfortunately quickly stemmed by various events in early 1999, and for many months the manuscript (if you can call a FrameMaker document a “manuscript”) remained almost untouched. C++ Templates was in a coma.
Fortunately, Nico Josuttis also had come to the conclusion that a book on templates was needed: He approached Addison-Wesley with the idea, and learned about my existing contract with them. He then offered to collaborate on the project, and we quickly agreed to revise the contract (to accomodate two authors). Nico's experience with writing books is considerably more mature than mine. He easily transferred my existing manuscript to the writing tools he had developed over the years (e.g., to automate testing of the compilable code examples). He also pointed out that the existing text was too opaque/terse for a large part of our intended readership. This prompted a thorough reorganization of the material into the four “parts” that make up the book as finally published.
Nico took on the task of writing Part I (a soft introduction to the concepts behind templates) and I worked on completing Part II (which covers the formal template principles). Similarly, we divided up the work for the other parts and the appendices. With a bit of prodding on Debbie Lafferty's part (she's our editor at Addison-Wesley), most of the book's content was completed in about a year. (Note that neither Nico nor I write full-time: In my case, most of the writing was done on Saturday and Sunday afternoons. Karina was fortunately quite supportive of the effort.) The result was sent out for review, and the feedback we received from that was very exciting. We then used a few more months to incorporate additional requested material (e.g., the appendix on overloading) and modify/clarify the presentation according to feedback.