just to rephrase i meant the incomplete type is only incomplete at the instantiation of the pair & vector, |
It's incomplete at the time the
vector is instantiated. But do we have any reason to believe any
pair objects are being instantiated when the vector is instantiated, if you're using the default constructor to create it in an empty state?
Seems to me the answer is "no" - and that compilation would fail if the implementation of
std::vector that you're using were actually trying to instantiate the
std::pair objects before the type was complete.
Albatross wrote: |
---|
Do you have a better way of communicating the distinction between an object + all of the memory it owns, versus just the data members (+ a vtable pointer in some cases)? I'm pretty sure OP was referring to the latter. |
Not in any way more concise than yours, I suppose. But given that other things in the OP were vague and seemed to suggest some misunderstandings, I thought it would be best to make sure we were being absolutely clear.
The point is that at some point, the
vector code will need to use actual
pair objects, rather than just pointers, and that when that happens, the definition will need to be complete.
To summarize:
1. When the
vector code needs to create
std::pair objects, those objects will need to be completely defined.
2. The default constructor for vector may not need to create any
std::pair objects, so they can be incomplete at this point.