{"id":94,"date":"2008-11-25T19:43:57","date_gmt":"2008-11-26T02:43:57","guid":{"rendered":"http:\/\/www.venzon.org\/?p=94"},"modified":"2008-11-25T19:44:22","modified_gmt":"2008-11-26T02:44:22","slug":"standard-c-and","status":"publish","type":"post","link":"http:\/\/www.venzon.org\/?p=94","title":{"rendered":"Standard C++ algorithm and functional headers"},"content":{"rendered":"<p>I&#8217;ve found joy in the standard C++ algorithm and functional headers.  I finally found a nice, neat way to iterate through a container calling a specific function on all elements of the container!  I used to do this sort of thing everywhere in my code:<\/p>\n<pre lang=\"cpp\">for (std::list <ROADSTRIP>::iterator i = roads.begin(); i != roads.end(); i++)\r\n\t\ti->Reverse();<\/pre>\n<p>This seems pretty simple, but believe me, it&#8217;s a lot of typing, especially if the contained type is complicated.  Well, instead of doing that, just include algorithm and functional and then do:<\/p>\n<pre lang=\"cpp\">std::for_each(roads.begin(), roads.end(), std::mem_fun_ref(&ROADSTRIP::Reverse));<\/pre>\n<p>&#8230; beautiful.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve found joy in the standard C++ algorithm and functional headers. I finally found a nice, neat way to iterate through a container calling a specific function on all elements of the container! I used to do this sort of thing everywhere in my code: for (std::list ::iterator i = roads.begin(); i != roads.end(); i++) [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-94","post","type-post","status-publish","format-standard","hentry","category-prototyping"],"_links":{"self":[{"href":"http:\/\/www.venzon.org\/index.php?rest_route=\/wp\/v2\/posts\/94","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.venzon.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.venzon.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.venzon.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.venzon.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=94"}],"version-history":[{"count":4,"href":"http:\/\/www.venzon.org\/index.php?rest_route=\/wp\/v2\/posts\/94\/revisions"}],"predecessor-version":[{"id":100,"href":"http:\/\/www.venzon.org\/index.php?rest_route=\/wp\/v2\/posts\/94\/revisions\/100"}],"wp:attachment":[{"href":"http:\/\/www.venzon.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=94"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.venzon.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=94"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.venzon.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=94"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}