{"id":610,"date":"2022-08-30T15:04:13","date_gmt":"2022-08-30T15:04:13","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/problem-about-incomplete-type-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:04:13","modified_gmt":"2022-08-30T15:04:13","slug":"problem-about-incomplete-type-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/problem-about-incomplete-type-collection-of-common-programming-errors\/","title":{"rendered":"problem about incomplete-type-Collection of common programming errors"},"content":{"rendered":"<ul>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/dde3a5048e456c451b7c518857e1818c?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nBen Voigt<br \/>\nc++ c++11 pimpl-idiom incomplete-type gotw<br \/>\nFirst read Herb&#8217;s Sutters GotW posts concerning pimpl in C++11:GotW #100: Compilation Firewalls (Difficulty: 6\/10) GotW #101: Compilation Firewalls, Part 2 (Difficulty: 8\/10)I&#8217;m having some trouble understanding the solution proposed in GotW #101. As far as I can understand, all the problems laboriously solved in GotW #100 are back with a vengeance:The pimpl members are out-of-line templates, and the definitions are not visible at the poi<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/bc790307b3c4cdbd25f582d9067651f1?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\naschepler<br \/>\nc++ templates incomplete-type<br \/>\nI am very surprised that on various sampled versions of g++, the following compiles without error or warning:\/\/ Adapted from boost::checked_delete() template inline void assert_complete() {typedef char type_must_<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/8854a441d1fd8518cd87c2429fed15ef?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nPotatoswatter<br \/>\nc++ templates stl incomplete-type<br \/>\nSometimes it&#8217;s useful to instantiate a standard container with an incomplete type to obtain a recursive structure:struct multi_tree_node { \/\/ Does work in most implementationsstd::vector&lt; multi_tree_node &gt; child; };struct trie_node { \/\/ Does not work in most implementationsstd::map&lt; char, trie_node &gt; next; };This tends to work because containers don&#8217;t have members of type value_type or member functions that pass or return any value_type objects by value. The Standard doesn&#8217;t seem to say very much about incomplete template arguments, but there is one bit under C++11 \u00a717.<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/2385676760fc16f76a43f3319faaa843?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nJohannes Schaub &#8211; litb<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/c73732232595afca920089aa1c915cc4?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nChubsdad<br \/>\nc++ delete destructor incomplete-type<br \/>\nReference hereThat destructor will also implicitlycall the destructor of the auto_ptrobject. And that will delete thepointer it holds, that points to the Cobject &#8211; without knowing thedefinition of C! That appeared in the.cpp file where struct A&#8217;s constructoris defined.This was curious and then5.3.5\/5 states &#8211; &#8220;I<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/082b8ee2b0aebb430b8d4d98e6a5c32f?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nFredOverflow<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/acebaaf02be9bbc7319c51af806f9ec2?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nNawaz<br \/>\nc++ handles incomplete-type empty-class<br \/>\nMicrosoft&#8217;s GDI+ defines many empty classes to be treated as handles internally. For example, (source GdiPlusGpStubs.h)\/\/Approach 1class GpGraphics {};class GpBrush {}; class GpTexture : public GpBrush {}; class GpSolidFill : public GpBrush {}; class GpLineGradient : public GpBrush {}; class GpPathGradient : public GpBrush {}; class GpHatch : public GpB<\/li>\n<li><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/eaba19c9e2f10246fec81bc679d5ca88?s=32&amp;d=identicon&amp;r=PG\" \/><br \/>\nuser1166025<br \/>\ncompilation incomplete-type<br \/>\nif got a quite simple question (at least I hope so), but I cannot figure out what to do to tell g++ in what order to &#8220;complete&#8221; my classes. I reduced it to this simple example:base.h:#ifndef BASE_H_ #define BASE_H_#include &#8220;otherclass.h&#8221; class otherclass;class base {public:base(otherclass* other);protected:otherclass* m_other; };#endif \/* BASE_H_ *\/derived.h:#ifndef DERIVED_H_ #define<\/li>\n<\/ul>\n<p id=\"rop\"><small>Originally posted 2013-11-09 21:07:30. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Ben Voigt c++ c++11 pimpl-idiom incomplete-type gotw First read Herb&#8217;s Sutters GotW posts concerning pimpl in C++11:GotW #100: Compilation Firewalls (Difficulty: 6\/10) GotW #101: Compilation Firewalls, Part 2 (Difficulty: 8\/10)I&#8217;m having some trouble understanding the solution proposed in GotW #101. As far as I can understand, all the problems laboriously solved in GotW #100 are [&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-610","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/610","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=610"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/610\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=610"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=610"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=610"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}