typedef of templates having incomplete type
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/3074872/typedef-and-incomplete-type">typedef and incomplete type</a>  </p>
</blockquote>



<p>if I do</p>

<pre><code>class foo;
typedef list&lt;foo&gt; myList;
typedef myList::iterator myListIter;

class foo{};
</code></pre>

<p>And if the code compiles, then can I assume that the program will not cause undefined behavior at run time? I believe that the code should work, because had the template instantiation tried to use template argument type to instantiate an object of that type, the compiler would have caught it at the compile time. If the template code is using it as a pointer or a reference then definitely it would get a definition latter as and when the type is defined; otherwise first use of myList would cause the compiler error.</p>

<p>Please let me know your thoughts. Note that here the question is specific about when the code compiles and not what standard says about use of incomplete type in a template instantiation. </p>
