Andre Poenitz <[EMAIL PROTECTED]> writes: | On Fri, Nov 21, 2003 at 08:51:36AM +0000, Angus Leeming wrote: >> In turn, buffer.h has this: >> #include "ParagraphList_fwd.h" >> class Buffer { >> public: >> class inset_iterator { >> private: >> ParagraphList::iterator pit; >> ParagraphList::iterator pend; >> }; >> }; >> >> So, my question becomes: do you need to know 'paragraph' to >> instantiate std::list<paragraph>::iterator? I guess the answer to >> that is 'yes' (or the compiler would not be complaining). That being >> the case, then I also guess that the CORRECT place to #include >> "paragraph" (and I hate to say this) is buffer.h itself. >> >> Thoughts? > | I seem to remember a discussion that resulted in "a declaration of a | class (without definition) is sufficient to _declare_ (but not to | instantiate) a template based on that class" (either here or in | comp.lang.c++[.moderated]/de.comp.lang.iso-c++) > | But this is really walking the edge and probably difficult to get right | for the compiler implementors. > >> Why do non-g++3.4 compilers seem quite happy with this though? > | Maybe this debug modus Lars was speaking of instantiates the template.
Right. With debug mode turned on it uses safe iterators (checked iterators), that check if iterators compared belong to the same container etc. checks some bounds for containers, check that algorithm requirements are fullfilled etc. So if we are able to run in debug mode without warnings we will have a more robust program. So... only the two files in question needed to have paragraph.h included. -- Lgb