{"id":4105,"date":"2014-03-30T07:43:06","date_gmt":"2014-03-30T07:43:06","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/c11-smart-pointers-always-instead-of-new-delete-collection-of-common-programming-errors\/"},"modified":"2014-03-30T07:43:06","modified_gmt":"2014-03-30T07:43:06","slug":"c11-smart-pointers-always-instead-of-new-delete-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/c11-smart-pointers-always-instead-of-new-delete-collection-of-common-programming-errors\/","title":{"rendered":"C++11 smart pointers always instead of new\/delete?-Collection of common programming errors"},"content":{"rendered":"<p><code>unique_ptr<\/code> doesn&#8217;t (isn&#8217;t supposed to) have any runtime overhead whatsoever compared to using raw pointers. <code>shared_ptr<\/code> does have some memory and time overhead (how much depends on the implementation). The <em>practical<\/em> overhead here can easily be zero if you actually need something that behaves like a <code>shared_ptr<\/code> (that is, no other implementation you&#8217;d think of would be any faster or more memory efficient).<\/p>\n<p>That is not to say you&#8217;ll never use new\/delete in your code, but it&#8217;s not something you&#8217;ll do all the time.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>unique_ptr doesn&#8217;t (isn&#8217;t supposed to) have any runtime overhead whatsoever compared to using raw pointers. shared_ptr does have some memory and time overhead (how much depends on the implementation). The practical overhead here can easily be zero if you actually need something that behaves like a shared_ptr (that is, no other implementation you&#8217;d think of [&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-4105","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4105","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=4105"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4105\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4105"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4105"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4105"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}