{"id":430,"date":"2010-07-30T09:32:47","date_gmt":"2010-07-30T08:32:47","guid":{"rendered":"http:\/\/www.nuonsoft.com\/blog\/?p=430"},"modified":"2010-07-30T09:32:47","modified_gmt":"2010-07-30T08:32:47","slug":"the-c0x-range-based-for-loop","status":"publish","type":"post","link":"https:\/\/www.nuonsoft.com\/blog\/2010\/07\/30\/the-c0x-range-based-for-loop\/","title":{"rendered":"The C++0x Range-Based For Loop"},"content":{"rendered":"<p>C++0x adds a new looping structure: the Range-Based for loop. This makes it easier to loop over elements of lists. It works with standard C arrays and types that have begin() and end() functions returning iterators like almost all STL containers.<\/p>\n<p>Below is an example of a range-based for loop looping over a standard C-style array, incrementing each value by 1.<\/p>\n<blockquote>\n<pre>int myArray[3] = {1, 2, 3};\r\nfor(auto&amp; el : myArray) {\r\n\u00a0\u00a0\u00a0 ++el;\r\n}<\/pre>\n<\/blockquote>\n<p>Note that this example also uses the auto type deduction introduced in C++0x.<br \/>\nNow it&#8217;s only waiting until the C++ compilers start supporting it \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>C++0x adds a new looping structure: the Range-Based for loop. This makes it easier to loop over elements of lists. It works with standard C arrays and types that have begin() and end() functions returning iterators like almost all STL containers. Below is an example of a range-based for loop looping over a standard C-style [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,17],"tags":[81,82],"class_list":["post-430","post","type-post","status-publish","format-standard","hentry","category-c","category-software-development","tag-c0x","tag-range-based-for-loop"],"_links":{"self":[{"href":"https:\/\/www.nuonsoft.com\/blog\/wp-json\/wp\/v2\/posts\/430","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.nuonsoft.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nuonsoft.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nuonsoft.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nuonsoft.com\/blog\/wp-json\/wp\/v2\/comments?post=430"}],"version-history":[{"count":3,"href":"https:\/\/www.nuonsoft.com\/blog\/wp-json\/wp\/v2\/posts\/430\/revisions"}],"predecessor-version":[{"id":433,"href":"https:\/\/www.nuonsoft.com\/blog\/wp-json\/wp\/v2\/posts\/430\/revisions\/433"}],"wp:attachment":[{"href":"https:\/\/www.nuonsoft.com\/blog\/wp-json\/wp\/v2\/media?parent=430"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nuonsoft.com\/blog\/wp-json\/wp\/v2\/categories?post=430"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nuonsoft.com\/blog\/wp-json\/wp\/v2\/tags?post=430"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}