{"id":4104,"date":"2014-03-30T07:43:03","date_gmt":"2014-03-30T07:43:03","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/dynamic-array-c-collection-of-common-programming-errors\/"},"modified":"2014-03-30T07:43:03","modified_gmt":"2014-03-30T07:43:03","slug":"dynamic-array-c-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/dynamic-array-c-collection-of-common-programming-errors\/","title":{"rendered":"Dynamic array C++-Collection of common programming errors"},"content":{"rendered":"<p>If your &#8216;inner&#8217; arrays are all 8 elements each, you can use this approach for a dynamically resizable array of <code>complex<\/code> arrays of 8 elements:<\/p>\n<pre><code>std::vector c(line);\n\/\/ new and delete are not needed here\n<\/code><\/pre>\n<p>You could of course substitute <code>std::vector<\/code> for <code>std::array<\/code> in this case &#8212; <code>std::array<\/code> may not be available depending on the library you&#8217;re using.<\/p>\n<p><code>std::array<\/code> is a little more exact than <code>std::vector<\/code> when the element count is invariant. Thus, <code>std::array<\/code> can make a ton of optimizations <code>std::vector<\/code> cannot. How that affects your program may or may not be measurable.<\/p>\n<p>The good thing about this is that the library implementations are well tested, will insulate you from and detect some usage errors.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If your &#8216;inner&#8217; arrays are all 8 elements each, you can use this approach for a dynamically resizable array of complex arrays of 8 elements: std::vector c(line); \/\/ new and delete are not needed here You could of course substitute std::vector for std::array in this case &#8212; std::array may not be available depending on the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4104","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4104","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4104"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4104\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4104"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4104"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4104"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}