{"id":3343,"date":"2011-03-08T17:01:00","date_gmt":"2011-03-08T17:01:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vcblog\/2011\/03\/08\/algorithm-optimizations-advanced-stl-part-2\/"},"modified":"2019-02-18T18:45:10","modified_gmt":"2019-02-18T18:45:10","slug":"algorithm-optimizations-advanced-stl-part-2","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/cppblog\/algorithm-optimizations-advanced-stl-part-2\/","title":{"rendered":"Algorithm Optimizations &#8211; Advanced STL, Part 2"},"content":{"rendered":"<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\"><a href=\"https:\/\/channel9.msdn.com\/Shows\/Going+Deep\/C9-Lectures-Stephan-T-Lavavej-Advanced-STL-2-of-n\"><span style=\"color: #0000ff\">Part 2<\/span><\/a> of my video lecture series exploring the Standard Template Library&#8217;s implementation is now available.&nbsp; In this part, I walk through how our STL algorithms equal() and copy() use template metaprogramming to detect when it&#8217;s safe to call memcmp() and memmove(), which are potentially faster than the generic loops.<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\">In Part 1&#8217;s comments, two customers reported compiler bugs to us.&nbsp; While I can&#8217;t promise that they&#8217;ll be fixed in VC11, I&#8217;m happy to report that fixes for them have been queued in our checkin system, which is certainly a prerequisite for shipping them.&nbsp; :-&gt;<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\">This advanced series assumes that you&#8217;re familiar with C++ and the STL&#8217;s interface, but not the STL&#8217;s implementation.&nbsp; If you haven&#8217;t used the STL extensively yet, I recommend watching my introductory series.&nbsp; For reference, here are all of the links:<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\">[STL Introduction]<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\"><a href=\"https:\/\/channel9.msdn.com\/shows\/Going+Deep\/C9-Lectures-Introduction-to-STL-with-Stephan-T-Lavavej\/\"><span style=\"color: #0000ff\">Part 1<\/span><\/a> (sequence containers)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\"><a href=\"https:\/\/channel9.msdn.com\/shows\/Going+Deep\/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-2-of-n\/\"><span style=\"color: #0000ff\">Part 2<\/span><\/a> (associative containers)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\"><a href=\"https:\/\/channel9.msdn.com\/shows\/Going+Deep\/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-3-of-n\/\"><span style=\"color: #0000ff\">Part 3<\/span><\/a> (smart pointers)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\"><a href=\"https:\/\/channel9.msdn.com\/shows\/Going+Deep\/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-4-of-n\/\"><span style=\"color: #0000ff\">Part 4<\/span><\/a> (Nurikabe solver) &#8211; see Wikipedia&#8217;s <a href=\"http:\/\/en.wikipedia.org\/wiki\/Nurikabe\"><span style=\"color: #0000ff\">article<\/span><\/a> and my <a href=\"http:\/\/cid-e66e02dc83efb165.office.live.com\/browse.aspx\/nurikabe\"><span style=\"color: #0000ff\">updated source code<\/span><\/a><\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\"><a href=\"https:\/\/channel9.msdn.com\/shows\/Going+Deep\/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-5-of-n\/\"><span style=\"color: #0000ff\">Part 5<\/span><\/a> (Nurikabe solver, continued)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\"><a href=\"https:\/\/channel9.msdn.com\/Shows\/Going+Deep\/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-6-of-n\"><span style=\"color: #0000ff\">Part 6<\/span><\/a> (algorithms and functors)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\"><a href=\"https:\/\/channel9.msdn.com\/Shows\/Going+Deep\/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-7-of-n\"><span style=\"color: #0000ff\">Part 7<\/span><\/a> (algorithms and functors, continued)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\"><a href=\"https:\/\/channel9.msdn.com\/Shows\/Going+Deep\/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-8-of-n\"><span style=\"color: #0000ff\">Part 8<\/span><\/a> (regular expressions)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\"><a href=\"https:\/\/channel9.msdn.com\/Shows\/Going+Deep\/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-9-of-n\"><span style=\"color: #0000ff\">Part 9<\/span><\/a> (rvalue references)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\"><a href=\"https:\/\/channel9.msdn.com\/Shows\/Going+Deep\/C9-Lectures-Stephan-T-Lavavej-Standard-Template-Library-STL-10-of-10\"><span style=\"color: #0000ff\">Part 10<\/span><\/a> (type traits)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\">[Advanced STL]<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\"><a href=\"https:\/\/channel9.msdn.com\/Shows\/Going+Deep\/C9-Lectures-Stephan-T-Lavavej-Advanced-STL-1-of-n\"><span style=\"color: #0000ff\">Part 1<\/span><\/a> (shared_ptr &#8211; type erasure)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\"><a href=\"https:\/\/channel9.msdn.com\/Shows\/Going+Deep\/C9-Lectures-Stephan-T-Lavavej-Advanced-STL-2-of-n\"><span style=\"color: #0000ff\">Part 2<\/span><\/a> (equal()\/copy() &#8211; algorithm optimizations)<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\">&nbsp;<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\">Stephan T. Lavavej<\/span><\/p>\n<p class=\"MsoNormal\"><span style=\"font-family: 'Verdana','sans-serif';font-size: 12pt\">Visual C++ Libraries Developer<\/p>\n<p><\/span><\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Part 2 of my video lecture series exploring the Standard Template Library&#8217;s implementation is now available.&nbsp; In this part, I walk through how our STL algorithms equal() and copy() use template metaprogramming to detect when it&#8217;s safe to call memcmp() and memmove(), which are potentially faster than the generic loops. &nbsp; In Part 1&#8217;s comments, [&hellip;]<\/p>\n","protected":false},"author":289,"featured_media":35994,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[9,3,32],"class_list":["post-3343","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cplusplus","tag-channel-9","tag-dev","tag-stl"],"acf":[],"blog_post_summary":"<p>Part 2 of my video lecture series exploring the Standard Template Library&#8217;s implementation is now available.&nbsp; In this part, I walk through how our STL algorithms equal() and copy() use template metaprogramming to detect when it&#8217;s safe to call memcmp() and memmove(), which are potentially faster than the generic loops. &nbsp; In Part 1&#8217;s comments, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/3343","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/users\/289"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/comments?post=3343"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/posts\/3343\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media\/35994"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/media?parent=3343"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/categories?post=3343"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/cppblog\/wp-json\/wp\/v2\/tags?post=3343"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}