tag:blogger.com,1999:blog-9450905394509459152024-03-14T05:09:48.216-07:00Advanced C++ MetaprogrammingThe official place to find book errata, updates and discussionsadminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.comBlogger24125tag:blogger.com,1999:blog-945090539450945915.post-6141779568739181002022-01-08T00:25:00.005-08:002022-01-08T00:25:52.382-08:00Bonus chapter (fixed link)<p>The original edition of the book is not available anymore, and it's not maintained. You should get the book from <a href="https://www.amazon.com/Advanced-Metaprogramming-Classic-Davide-Gennaro-ebook/dp/B01JCOFWD4/" target="_blank">this page</a> instead, but if for any reason you need the old files, here they are:</p><p>Bonus <a href="https://drive.google.com/file/d/0BxqfrvPWIaAoQjJwVXZsc2s1Szg/view?usp=sharing&resourcekey=0-XYV1zBQJvJYcEUvi5GMKxw">chapter</a></p><p><a href="https://drive.google.com/file/d/0BxqfrvPWIaAoT1IyNklydmF5ZVE/view?usp=sharing&resourcekey=0-MpGrrUPqv-W61U0_6xrGyg">Section 5.2.2</a><br /></p>Mycroft Holmeshttp://www.blogger.com/profile/02035876952317280386noreply@blogger.com0tag:blogger.com,1999:blog-945090539450945915.post-73574197411595340962015-10-20T00:19:00.001-07:002015-10-20T17:02:09.105-07:00The Lion Sleeps Tonight<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjt9axIB3SBVHqp0mTgH_-HvEdlU5nfixFFocJ4UcSQd9nr0vyJF7aFGSUzABNlkuTafP00KI_oF9EFLYtZTxOVTMIJKJfeTFnrGJ2XVUuxAZA0YzV3FxHUDX1KIuNftap9KFOPD8GPp2Q/s1600/_DSC5976.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="266" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjt9axIB3SBVHqp0mTgH_-HvEdlU5nfixFFocJ4UcSQd9nr0vyJF7aFGSUzABNlkuTafP00KI_oF9EFLYtZTxOVTMIJKJfeTFnrGJ2XVUuxAZA0YzV3FxHUDX1KIuNftap9KFOPD8GPp2Q/s400/_DSC5976.jpg" width="400" /></a></div>
<br />
2015, October 18<br />
<br />
Tibet is now in a better place, where all C++ programs compile and run, and there are no debuggers.<br />
Now I'm still crying, and we already miss him, but here are a few things that he taught me:<br />
<br />
<ul>
<li>you can be ugly and beautiful at the same time</li>
<li>there's nothing like spaghetti made by mom</li>
<li>you can fight until the end</li>
<li>you can play until the end</li>
<li>a true shih-tzu does whatever he wants</li>
</ul>
<div>
One day we will play together again.</div>
Mycroft Holmeshttp://www.blogger.com/profile/02035876952317280386noreply@blogger.com0tag:blogger.com,1999:blog-945090539450945915.post-56176259876825687012013-05-20T06:58:00.002-07:002013-05-20T06:58:57.016-07:00Self Promotion?<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJ1iBbmJJ3sIJXG2P0Oc1RIi_hMs8fT6FaJjqe_Nm7e-ECMFKWG_4SxasrN52oRDVqi6L-UAz_W5bc87sOsz7Qb5RrVjhvdkp4doGTefl-dYJKbHql2MlPrBx0wR4am_4BE3QsxQPAZ1OV/s1600/amazon.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiJ1iBbmJJ3sIJXG2P0Oc1RIi_hMs8fT6FaJjqe_Nm7e-ECMFKWG_4SxasrN52oRDVqi6L-UAz_W5bc87sOsz7Qb5RrVjhvdkp4doGTefl-dYJKbHql2MlPrBx0wR4am_4BE3QsxQPAZ1OV/s1600/amazon.png" height="355" width="400" /></a></div>
<br />
Amazon is advising <i>me</i> to buy this book...adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com0tag:blogger.com,1999:blog-945090539450945915.post-75018624873714009392013-05-02T11:12:00.003-07:002013-05-02T11:12:42.809-07:00The most popular book among smart people<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0JN1RFX3cDTXUrQIkSsJ2Hu1quLqWocIzair50oFjkrK29bn7WsEdahmGDne7DZ8PJn793kMla3nMdfH95dE5Gc0Qr5EnGAxWxndL6s6XmAW0FAbSsWzEDcnXmr3vYwb1aQKH1tbTPLQy/s1600/book_reader.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh0JN1RFX3cDTXUrQIkSsJ2Hu1quLqWocIzair50oFjkrK29bn7WsEdahmGDne7DZ8PJn793kMla3nMdfH95dE5Gc0Qr5EnGAxWxndL6s6XmAW0FAbSsWzEDcnXmr3vYwb1aQKH1tbTPLQy/s400/book_reader.jpg" width="396" /></a></div>
<br />adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com0tag:blogger.com,1999:blog-945090539450945915.post-1464672292411607022012-10-19T23:53:00.001-07:002012-10-19T23:53:13.725-07:00Bonus chapter<br />
Download the pdf <a href="https://docs.google.com/open?id=0BxqfrvPWIaAoQjJwVXZsc2s1Szg">here</a><br />
<br />adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com0tag:blogger.com,1999:blog-945090539450945915.post-37189856638859919312012-10-03T02:37:00.000-07:002012-10-03T02:37:01.648-07:00Book review (in German)"<span style="background-color: white; color: #494949; font-family: verdana, sans-serif; font-size: 12.727272033691406px; line-height: 16.24242401123047px;">Wer Templates auf einem hohen Niveau meistern möchte, für den ist "Advanced C++ Metaprogramming" Pflichtlektüre"</span><br />
<br />
<a href="http://www.linux-magazin.de/Heft-Abo/Ausgaben/2012/11/Buecher">http://www.linux-magazin.de/</a><br />
<br />
<br />adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com0tag:blogger.com,1999:blog-945090539450945915.post-89068481026953574962012-07-26T00:11:00.002-07:002012-07-26T00:11:36.766-07:00High return for the money<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiD7W5fs0mLXSqNBL3BpGcJszK82JiEj-fDq5JTiT1JdwQ-HZ10ooHUWra8McmcI_hIOVyLxdFmaIE9yhSeFliDVz5qtQIpa69_Tj-rXDa26BMj9Wxqvhk51h7GrT6HyukBC3GYK-9wh0Cy/s1600/Book+at+999.99.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="257" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiD7W5fs0mLXSqNBL3BpGcJszK82JiEj-fDq5JTiT1JdwQ-HZ10ooHUWra8McmcI_hIOVyLxdFmaIE9yhSeFliDVz5qtQIpa69_Tj-rXDa26BMj9Wxqvhk51h7GrT6HyukBC3GYK-9wh0Cy/s640/Book+at+999.99.png" width="640" /></a></div>
<br />
<div>
Buy the book at 39.99, resell at 999.99...</div>adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com0tag:blogger.com,1999:blog-945090539450945915.post-20873003718052087532012-06-11T13:13:00.002-07:002012-06-11T13:13:37.090-07:00Section 5.2.2This section was an unfortunate mix of unexpressed ideas, a couple of mistakes and a poor structure.<br />
I'm reposting the entire section here, hopefully it should be better.<br />
<br />
<a href="https://docs.google.com/open?id=0BxqfrvPWIaAoT1IyNklydmF5ZVE">Download</a><br />
<br />
Casual readers, please don't take this file as a meaningful sample of the quality of the book.adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com2tag:blogger.com,1999:blog-945090539450945915.post-78195906135326846202012-05-08T03:13:00.001-07:002012-05-08T03:13:07.656-07:00Book available in amazon.[your country]I'm happy to announce that the book is now available in most european countries:<br />
<br />
<a href="http://www.amazon.it/Advanced-C-Metaprogramming-Davide-di-Gennaro/dp/1460966163/">www.amazon.it</a><br />
<a href="http://www.amazon.co.uk/Advanced-C-Metaprogramming-Davide-di-Gennaro/dp/1460966163/">www.amazon.co.uk</a><br />
<a href="http://www.amazon.de/Advanced-C-Metaprogramming-Davide-di-Gennaro/dp/1460966163/">www.amazon.de</a><br />
<br />
<br />adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com4tag:blogger.com,1999:blog-945090539450945915.post-28900518871975588562012-04-15T01:50:00.002-07:002012-04-15T01:51:38.189-07:00Fresh typos<br />
<h2>
Section 6.4.2</h2>
<div>
There's a missing &:<br />
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">vtable_impl<T>::destroy</span></div>
<div>
<br /></div>
<div>
should be:</div>
<div>
<br /></div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">&vtable_impl<T>::destroy</span></div>
<div>
<br /></div>
</div>
<div>
<br /></div>
<div>
<br /></div>
The code for <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">rebuild</span> says:<br />
<br />
<div>
<div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">const vtable* oldvt = vt;</span></div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">vt = vtable_singleton<void>::get(); </span></div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">(oldvt->destroy)(storage_);</span></div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">(<span class="Apple-style-span" style="background-color: #ffd966;">vt</span>->construct)(storage_, src);</span></div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">vt = newvt;</span></div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"></span></div>
</div>
<div>
But it should be:</div>
<div>
<br /></div>
<div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">const vtable* oldvt = vt;</span></div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">vt = vtable_singleton<void>::get(); </span></div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">(oldvt->destroy)(storage_);</span></div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">(<span class="Apple-style-span" style="background-color: #ffd966;">newvt</span>->construct)(storage_, src);</span></div>
<div>
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">vt = newvt;</span></div>
</div>
<div>
<br /></div>
<div>
The pointer has been replaced by a dummy for exception safety, so obviously <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">vt</span> will do nothing. </div>
<div>
Note that you should not swap lines #4 and #5</div>
<h2>
Section 6.3.5</h2>
<div>
<div>
There's a pointer to a type called <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">fptbl_t</span>, which does not exist.</div>
<div>
It's actually called <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">virtual_function_table</span> (fptbl stands <u>F</u>unction <u>P</u>ointer <u>T</u>a<u>BL</u>e)</div>
</div>
<div>
<br /></div>
<div>
There's an incorrect function call, spelled <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">table.del(p)</span>. But <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">table</span> is a pointer, so it should read: <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">(table->del)(p)</span></div>
<div>
<h2>
Section 6.3.6</h2>
<div>
<div>
The function <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">safe_cast</span>, has an argument called <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">p </span>but the code calls it <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">src.</span></div>
</div>
<div>
<h2>
Section 5.2.1</h2>
<div>
<div>
The class <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">string_traits</span> contains typedefs <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">argument_type</span> and <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">char_type</span>,<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> </span>but for compactness, they are later referred to as <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">arg_t</span><span class="Apple-style-span" style="font-family: inherit;"> and </span><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">char_t.</span></div>
</div>
<div>
<br /></div>
</div>
</div>
</div>adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com2tag:blogger.com,1999:blog-945090539450945915.post-46726597742184113772012-04-01T05:39:00.001-07:002012-04-15T01:51:38.191-07:00Typos that survived in the second revision<br />
<br />
<div>
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;">
I'm showing the section numbers, instead of pages, because they are valid in both revisions.</div>
</div>
<ol>
<li>In section 4.6.7 about template rotation, there's some confusion between a template parameter called <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">Dn</span> and <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">D9</span>: the intent is that <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">D9</span> is the last in the series, so it should be called <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">Dn</span> and <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">D8</span> is thus <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">D<span class="Apple-style-span" style="font-size: x-small;">n-1</span></span>.</li>
<li>In section 4.6.6 there's a spurious comma: <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">template <P1, P2<u>,</u> = default...></span> should read <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">template <P1, P2 = default...></span> </li>
<li>In section 4.3.1 <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">[[CONDITION]]</span> is mis-spelled as <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">[[CONDITION]</span></li>
</ol>adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com0tag:blogger.com,1999:blog-945090539450945915.post-80559989589481667442012-03-14T00:16:00.001-07:002012-03-18T02:39:34.491-07:00FAQI keep receiving the same questions over and over, so I decided to publish the official answers here (but I tend to reply to individual messages anyway, when feasible).<br />
<br />
<i>Q: How do I tell if I have the first revision or the second?</i><br />
<i>A: In the first page, you can see the list of revisions (the last is the current)</i><br />
<i><br /></i><br />
<i>
</i><br />
<div style="text-align: center;">
<i><span style="font-family: TimesNewRoman; font-size: 12pt;">First revision: 2011-05-15 </span></i></div>
<div style="text-align: center;">
<i><span style="font-family: TimesNewRoman; font-size: 12pt;">Second revision: 2012-02-07</span></i></div>
<div style="text-align: left;">
<i><span class="Apple-style-span" style="font-family: TimesNewRoman;"><br /></span></i></div>
<div style="text-align: left;">
<i><span class="Apple-style-span" style="font-family: TimesNewRoman;">Q: Is the second revision on sale?</span></i></div>
<div style="text-align: left;">
<i><span class="Apple-style-span" style="font-family: TimesNewRoman;">A: YES, and it should be on sale everywhere; the book is printed on demand.</span></i></div>
<div style="text-align: left;">
<i><span class="Apple-style-span" style="font-family: TimesNewRoman;"><br /></span></i></div>
<div style="text-align: left;">
<i><span class="Apple-style-span" style="font-family: TimesNewRoman;">Q: What are the differences between rev.1 and rev.2?</span></i></div>
<div style="text-align: left;">
<i><span class="Apple-style-span" style="font-family: TimesNewRoman;">A: Mostly cosmetic: I changed some styles in the template, fixed all the typos and all the problems that are mentioned in this site, added an index and added a couple of paragraphs. The differences are not enough to call it "second edition", that's why I prefer the name "rev.2".</span></i></div>
<div style="text-align: left;">
<i><span class="Apple-style-span" style="font-family: TimesNewRoman;"><br /></span></i></div>
<div style="text-align: left;">
<i><span class="Apple-style-span" style="font-family: TimesNewRoman;">Q: Your fixes didn't involve C++11. In rev.2 you still say: "the next standard", etc.</span></i></div>
<div style="text-align: left;">
<i><span class="Apple-style-span" style="font-family: TimesNewRoman;">A: Yes, this is a book published in early 2011, and a revision does not change this fact. rev.2 is "how the book should have been since the beginning", not "how the book would be today".</span></i></div>
<div style="text-align: left;">
<i><span class="Apple-style-span" style="font-family: TimesNewRoman;"><br /></span></i></div>
<div style="text-align: left;">
<i><span class="Apple-style-span" style="font-family: TimesNewRoman;">Q: But you don't mention variadic templates...</span></i></div>
<div style="text-align: left;">
<i><span class="Apple-style-span" style="font-family: TimesNewRoman;">A: Yes, it's correct and on purpose. I believe C++0x is not something that you can just mention, and the focus of the book is on C++03.</span></i></div>
<div style="text-align: left;">
<i><span class="Apple-style-span" style="font-family: TimesNewRoman;"><br /></span></i></div>
<div style="text-align: left;">
<i><span class="Apple-style-span" style="font-family: TimesNewRoman;">Q: If I send you a photo, can I have a pdf?</span></i></div>
<div style="text-align: left;">
<i><span class="Apple-style-span" style="font-family: TimesNewRoman;">A: Generally not. I published a similar offer, stating very clearly that it was valid for about one week. The idea was to give a cheap upgrade to rev.2 to all the people who bought rev.1 just before rev.2 was on sale. If you think this general principle holds true in your case (so: you have the paper book rev.1, and you bought approximately late February 2012), write me anyway and we can discuss.</span></i></div>
<div style="text-align: left;">
<i><span class="Apple-style-span" style="font-family: TimesNewRoman;"><br /></span></i></div>
<div style="text-align: left;">
<i><span class="Apple-style-span" style="font-family: TimesNewRoman;">Q: Is there any other way to get a pdf?</span></i></div>
<div style="text-align: left;">
<i><span class="Apple-style-span" style="font-family: TimesNewRoman;">A: YES. As promised in the book, if you find a (new) typo and you explicitly ask for it, I'll send you the pdf.</span></i></div>adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com5tag:blogger.com,1999:blog-945090539450945915.post-52084391216002879792012-02-27T23:57:00.002-08:002012-02-27T23:57:44.881-08:00New Table of ContentsThe second revision is on sale, even if <a href="http://www.amazon.com/Advanced-C-Metaprogramming-Davide-Gennaro/dp/1460966163/">Amazon</a> didn't update the "look inside" preview yet.<br />
Here's the new <a href="https://docs.google.com/open?id=0BxqfrvPWIaAoSFJQenV5MXBTUmlxc2EzZENnamJoQQ">table of contents</a>.adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com2tag:blogger.com,1999:blog-945090539450945915.post-55536257986944490722012-02-24T08:47:00.003-08:002012-02-24T08:47:59.259-08:00PDF Offer Officially ExpiredI just sent the PDF to all the readers who requested it.<br />
Since the majority asked not to publish their photo, I decided to publish none of them.<br />
<br />
Enjoy the second revision.adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com3tag:blogger.com,1999:blog-945090539450945915.post-66886312245299943942012-02-16T01:42:00.000-08:002012-02-16T01:42:58.354-08:00Second revision available soonIt's not really a <i>second edition</i>, it's jut a revised version, which also includes feedback from the readers.<br />
Visually more appealing, less typos and a couple of additional paragraphs.<br />
<br />
<b>If bought the book, write me an email with your photo holding the book, and I will send you back the pdf of the new revision. </b><b>Offer valid until February 24 (excluded).</b><br />
<br />
On February 24, I'll collect all the eligible recipients and send the file.<br />
Please, state explicitly in the email if you allow the photo to be published on this site.adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com4tag:blogger.com,1999:blog-945090539450945915.post-55502858612292022742011-12-27T02:34:00.000-08:002011-12-27T02:35:01.724-08:00Christmas Typos<br />
<br />
Page 17:<br />
<br />
<i>Y is a dependent name, since its meaning depends on <span class="Apple-style-span" style="background-color: yellow;">X</span></i><br />
<br />
Should be:<br />
<br />
<i>Y is a dependent name, since its meaning depends on <span class="Apple-style-span" style="background-color: yellow;">T</span></i><br />
<br />
<br />
<br />
<br />
Page 146:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">copy_q<double [3], int&>::type err2; //error: <span class="Apple-style-span" style="background-color: yellow;">test</span> is an array of 'int&'</span><br />
<br />
Should be:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace; font-size: x-small;">copy_q<double [3], int&>::type err2; //error: <span class="Apple-style-span" style="background-color: yellow;">type</span> is an array of 'int&'</span>adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com1tag:blogger.com,1999:blog-945090539450945915.post-71567035558599595152011-12-18T11:51:00.000-08:002011-12-18T11:54:31.960-08:00A couple of typos<br />
On page 464:<br />
<br />
<span class="Apple-style-span" style="background-color: #cccccc; font-family: 'Courier New', Courier, monospace;">template <typename T, size_t N> </span><br />
<span class="Apple-style-span" style="background-color: #cccccc; font-family: 'Courier New', Courier, monospace;">struct array </span><br />
<span class="Apple-style-span" style="background-color: #cccccc; font-family: 'Courier New', Courier, monospace;">{ </span><br />
<span class="Apple-style-span" style="background-color: #cccccc; font-family: 'Courier New', Courier, monospace;"> scalar_t data[N]; </span><br />
<span class="Apple-style-span" style="background-color: #cccccc;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">};</span></span><br />
<br />
should be actually:<br />
<br />
<span class="Apple-style-span" style="background-color: #cccccc;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">template <typename T, size_t N> </span></span><br />
<span class="Apple-style-span" style="background-color: #cccccc;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">struct array </span></span><br />
<span class="Apple-style-span" style="background-color: #cccccc;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">{ </span></span><br />
<span class="Apple-style-span" style="background-color: #cccccc;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> T data[N]; </span></span><br />
<span class="Apple-style-span" style="background-color: #cccccc;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">};</span></span><br />
<br />
<br />
<br />
On page 226, missing open bracket before begin:<br />
<br />
<br />
<span class="Apple-style-span" style="background-color: #cccccc;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">for_each(v.begin), v.end(), my_functor());</span></span><br />
<span class="Apple-style-span" style="background-color: #cccccc;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> ^^ </span></span><br />adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com0tag:blogger.com,1999:blog-945090539450945915.post-74266504062973742712011-12-11T03:21:00.001-08:002011-12-27T02:36:06.335-08:00Paragraph missing from section 3.2.3<br />
Apparently nobody reported this issue yet.<br />
Section 3.2.3 does not have a conclusion. You can download a small <a href="https://docs.google.com/open?id=0BxqfrvPWIaAoNjljZjEwZTgtOGFhOS00ZTk3LTkzYjItYjhjMTU3YzZiNTMw">pdf</a> with the correction<br />
<br />
<br />adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com0tag:blogger.com,1999:blog-945090539450945915.post-43986684554034665352011-11-24T00:44:00.001-08:002011-11-24T00:45:56.847-08:00Thanks to all the readers<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQXhGl0_DuBEX0DA2N756kuD2TrrvrOVVMM0rRWVlQOqT_mka-aCmDsLUJhzzA6XykdeEPvcC4gYsTQ3btG0OXgUrZPvwIzIGUKQYPrqO6t3zmNfngw8L6m3EcagY-aws49cO-jmYBAjSV/s1600/screenshot.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="54" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgQXhGl0_DuBEX0DA2N756kuD2TrrvrOVVMM0rRWVlQOqT_mka-aCmDsLUJhzzA6XykdeEPvcC4gYsTQ3btG0OXgUrZPvwIzIGUKQYPrqO6t3zmNfngw8L6m3EcagY-aws49cO-jmYBAjSV/s400/screenshot.jpg" width="400" /></a></div>
<br />adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com4tag:blogger.com,1999:blog-945090539450945915.post-87811151693535419802011-11-21T14:04:00.001-08:002011-11-21T14:06:09.353-08:00Typo ((<span style="font-family: 'CourierNew'; font-size: 8.000000pt;">There's an extra/missing bracket on page 131. </span><br />
<span style="font-family: 'CourierNew'; font-size: 8.000000pt;"><br /></span><br />
<span style="background-color: #cccccc; font-size: 8pt;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">static const int value = ((X % 2) ? 0 : -1;</span></span><br />
<span style="background-color: #cccccc; font-size: 8pt;"><span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"> ^^ </span></span>adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com0tag:blogger.com,1999:blog-945090539450945915.post-91190163318082902822011-11-01T13:55:00.000-07:002011-11-01T13:55:16.597-07:00Syntax error in section 2.4.11For some reason (namely, abuse of find & replace...), in section 2.4.11 three cast operators are incorrect.<br />
<br />
<br />
<span class="Apple-style-span" style="background-color: #cccccc; font-family: 'Courier New', Courier, monospace;">bool operator() const </span><br />
<span class="Apple-style-span" style="background-color: #cccccc; font-family: 'Courier New', Courier, monospace;">{ </span><br />
<div>
<br /></div>
<div>
should be:</div>
<div>
<br /></div>
<div>
<div>
<span class="Apple-style-span" style="background-color: #cccccc; font-family: 'Courier New', Courier, monospace;">operator bool() const </span></div>
<div>
<span class="Apple-style-span" style="background-color: #cccccc; font-family: 'Courier New', Courier, monospace;">{ </span></div>
</div>
<div>
<br /></div>
<div>
<br /></div>adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com0tag:blogger.com,1999:blog-945090539450945915.post-88019997808363490332011-10-31T05:24:00.001-07:002011-12-27T02:35:43.551-08:00Table of contentsA couple of readers asked the <a href="https://docs.google.com/open?id=0BxqfrvPWIaAoOTc1Njc5YWItZWFkZS00MDgwLThlYjAtOWQ4NWUyZTJjODdi">table of contents</a>.<br />
Amazon does not display it, at the moment.adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com0tag:blogger.com,1999:blog-945090539450945915.post-17260780383190111682011-10-30T00:40:00.000-07:002011-10-30T00:58:16.449-07:00selector is not an empty class<br />
In paragraph 3.1.2 a selector is defined as an empty class, and later in 3.1.3 we observe that a selector is equivalent to a <span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">static_value<bool></span>, which in fact has a (static) member called value.<br />
However, from that point on, selectors are used as if they contain:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">static const bool value = ...; </span><br />
<br />
The first place where this is actually needed is in section 4.3.1 (otherwise static_OR would not contain a result).<br />
You can replace the definition of selector so that it indeed derives from static_value, or just add the boolean:<br />
<br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">template <bool B></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">struct selector : static_value<bool, B></span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">{</span><br />
<span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;">};</span><br />
<div>
<br /></div>adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com0tag:blogger.com,1999:blog-945090539450945915.post-16156605100988394112011-10-25T13:56:00.000-07:002011-10-25T13:58:04.407-07:00catch (Errata&) { return new Material; }Some time ago I promised to the readers who are writing me to collect their feedback into a website. A blog seems the appropriate place, since evolution comes from discussion.<br />
Some posts will be fixes, some posts will be new ideas.<br />
<br />
According to the C++ principle of minimal overhead, the number of posts will also be proportional to the number of visitors/followers.adminhttp://www.blogger.com/profile/04545335243084148561noreply@blogger.com0