I
Ian Collins
Which would cause it to fail to compile in this case. If std::list onlyJames said:True, but that only happens when a CFoo is created and fully declared.
How's that? The class itself must be instantiated immediately,
in CFoo, since a non-static member variable requires a complete
type. Member functions (and static member variables) will not
be instantiated until used, but the compiler needs the class
itself in order to layout CFoo. And according to the
requirements of the standard, instantiating the class over an
incomplete type is undefined behavior. (The class instance of
std::list could contain something like
unsigned char buf[ sizeof(A) ] ;
for example, either directly, or in a member or base class.
Unlikely, but the standard explicitly leaves this up to the
implementation.)
contains pointers to its value type, then its size is known and it will
compile.
It's not uncommon for classes to have std::auto_ptr members which use
incomplete types.
I can see why this area needs some cleaning up in the new standard.