Does std::map<K,V>::iterator instantiate std::map<K,V>?
This results in undefined behavior.
In the declaration MyMap::iterator i;
, MyMap
is required to be a complete type, thus it is implicitly instantiated. However, Foo
and Bar
are not complete at this point of instantiation, so the behavior is undefined according to [res.on.functions]/2:
In particular, the effects are undefined in the following cases:
- ...
- if an incomplete type ([basic.types]) is used as a template argument when instantiating a template component or evaluating a concept, unless specifically allowed for that component.