{"id":6432,"date":"2022-08-14T18:30:11","date_gmt":"2022-08-14T18:30:11","guid":{"rendered":"https:\/\/www.modernescpp.com\/index.php\/and-the-five-winners-for-c-20-stl-cookbook-are\/"},"modified":"2022-08-14T18:30:11","modified_gmt":"2022-08-14T18:30:11","slug":"and-the-five-winners-for-c-20-stl-cookbook-are","status":"publish","type":"post","link":"https:\/\/www.modernescpp.com\/index.php\/and-the-five-winners-for-c-20-stl-cookbook-are\/","title":{"rendered":"And the Five Winners for the &#8220;C++20 STL Cookbook&#8221; are"},"content":{"rendered":"<p>Today, I want to present the five winners for the pdf of the book &#8220;<a href=\"https:\/\/www.packtpub.com\/product\/c-20-stl-cookbook\/9781803248714\">C++20 STL Cookbook<\/a>&#8221; by Bill Weinman.<\/p>\n<p><!--more--><\/p>\n<p>&nbsp;<img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-6426\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/CoverBig.png\" alt=\"CoverBig\" width=\"300\" height=\"369\" style=\"display: block; margin-left: auto; margin-right: auto;\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/CoverBig.png 582w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/CoverBig-244x300.png 244w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>To get the book, you had to answer the following question by Bill Weinmann: &#8220;<em>What are the major advantages of the C++20 format library over printf and iostream?<\/em>&#8220;. Here are the best five answers. Two answers were almost literally identical, but I had to decide for one of them.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Manali\"><\/span>Manali<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<div dir=\"auto\">1. Format () is clean, precise , flexible variadic template function in terms of its usage and code readability.<\/div>\n<div dir=\"auto\">2. With iostream we use for example: std::cout, std::cin . This use of scope resolution (namespaces) and insertion \/ extraction operations is overcome with help of format function , improving performance and efficiency.<\/div>\n<div dir=\"auto\">3. format() function provides type safety ,<\/div>\n<div dir=\"auto\">Formatting options, supporting classes and objects , positional arguments.<\/div>\n<h2><span class=\"ez-toc-section\" id=\"Uzoochogu\"><\/span>Uzoochogu<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>&nbsp;<img loading=\"lazy\" decoding=\"async\" class=\" size-full wp-image-6427\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/format1.png\" alt=\"format\" width=\"500\" height=\"198\" style=\"display: block; margin-left: auto; margin-right: auto;\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/format1.png 1223w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/format1-300x119.png 300w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/format1-1024x406.png 1024w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/format1-768x305.png 768w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Gabriel\"><\/span>Gabriel<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Disadvantages:<br \/>&#8211; not Type safe<br \/>&#8211; it is not extensible because it only supports a specific number of types.<\/p>\n<p>Advantages:<br \/>&#8211; Type safe<br \/>&#8211; now extensible ( yay :D )<br \/>&#8211; readable<br \/>&#8211; easier to localize\/translate<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Roberto\"><\/span>Roberto<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" alignleft size-full wp-image-6428\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/printf.jpg\" alt=\"printf\" width=\"500\" height=\"187\" style=\"float: left;\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/printf.jpg 1825w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/printf-300x112.jpg 300w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/printf-1024x383.jpg 1024w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/printf-768x287.jpg 768w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/printf-1536x574.jpg 1536w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"i\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-2\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-3\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-4\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\" alignleft size-full wp-image-6429\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/iostreams.jpg\" alt=\"iostreams\" width=\"550\" height=\"229\" style=\"float: left;\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/iostreams.jpg 1828w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/iostreams-300x125.jpg 300w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/iostreams-1024x425.jpg 1024w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/iostreams-768x319.jpg 768w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/iostreams-1536x638.jpg 1536w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><\/p>\n<h2><span class=\"ez-toc-section\" id=\"i-5\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-6\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-7\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-8\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><img loading=\"lazy\" decoding=\"async\" class=\" alignleft size-full wp-image-6430\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/format1.jpg\" alt=\"format1\" width=\"650\" height=\"392\" style=\"float: left;\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/format1.jpg 2150w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/format1-300x181.jpg 300w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/format1-1024x618.jpg 1024w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/format1-768x463.jpg 768w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/format1-1536x927.jpg 1536w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/format1-2048x1235.jpg 2048w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-9\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-10\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-11\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-12\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-13\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-14\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><img loading=\"lazy\" decoding=\"async\" class=\" alignleft size-full wp-image-6431\" src=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/format2.jpg\" alt=\"format2\" width=\"650\" height=\"530\" style=\"float: left;\" srcset=\"https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/format2.jpg 1422w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/format2-300x245.jpg 300w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/format2-1024x836.jpg 1024w, https:\/\/www.modernescpp.com\/wp-content\/uploads\/2022\/08\/format2-768x627.jpg 768w\" sizes=\"auto, (max-width: 650px) 100vw, 650px\" \/><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-15\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-16\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-17\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-18\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-19\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-20\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-21\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-22\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-23\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h2><span class=\"ez-toc-section\" id=\"i-24\"><\/span>&nbsp;<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><a href=\"https:\/\/godbolt.org\/z\/67r3Ys9Kh\">Demo<\/a><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Hyper\"><\/span>Hyper<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>my answer is that the C++20 format library provides a rich set of formatting options that exceeds even that of prinf. It provides a positional arguments and is extensible to support more values and classes. It is like it was isnpired by Python str.format method.<br \/>the C++20 format() function is a variadic template function which provides type safety, along with the performance and efficiency advantages of iostream. the format library also provides vformat(), a type-erased interface that prevents generating multiple instances of complex template function for each combination of arguments.<br \/>the make_formate_arge() function creates a type-erased parameter stack to pass to vformat(), which does the heavy lifting of formatting the string. This is how the format() library operates so efficiently.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today, I want to present the five winners for the pdf of the book &#8220;C++20 STL Cookbook&#8221; by Bill Weinman.<\/p>\n","protected":false},"author":21,"featured_media":6426,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[360],"tags":[],"class_list":["post-6432","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"_links":{"self":[{"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/posts\/6432","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/comments?post=6432"}],"version-history":[{"count":0,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/posts\/6432\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/media\/6426"}],"wp:attachment":[{"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/media?parent=6432"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/categories?post=6432"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.modernescpp.com\/index.php\/wp-json\/wp\/v2\/tags?post=6432"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}