title: Does extern template prevent inlining of functions?
body: <p>I'm not entirely clear on how the new <code>extern template</code> feature is meant to work in C++11.  I understand that it is intended to help speed up compilation time, and simplify linking issues with shared libraries.  Does that mean that the compiler does not even parse the function body, forcing a non-inlined call to be made?  Or does it simply instruct the compiler to not generate an actual method body when a non-inlined call is made?  Obviously, link-time code generation not withstanding.</p>
  
  <p>As a concrete example of where the difference might matter, consider a function that operates on an incomplete type.</p>
  
  <pre><code>//Common header
  template&lt;typename T&gt;
  void DeleteMe(T* t) {
      delete t;
  }
  
  struct Incomplete;
  extern template void DeleteMe(Incomplete*);
  
  //Implementation file 1
  #include common_header
  struct Incomplete { };
  template void DeleteMe(Incomplete*);
  
  //Implementation file 2
  #include common_header
  int main() {
     Incomplete* p = factory_function_not_shown();
     DeleteMe(p);
  }
  </code></pre>
  
  <p>Within "Implementation file 2", it is unsafe to <code>delete</code> a pointer to <code>Incomplete</code>.  So an inlined version of <code>DeleteMe</code> would fail.  But if it is left as an actual function call, and the function itself were generated within "Implementation file 1", everything will work correctly.</p>
  
  <p>As a corollary, are the rules the same for member functions of templated classes with a similar <code>extern template class</code> declaration?</p>
  
  <p>For experimental purposes, MSVC produces the correct output to the above code, but if the <code>extern</code> line is removed generates a warning about deleting an incomplete type.  However, this is the remnants of a non-standard extension they introduced years ago so I'm not sure how much I can trust this behavior.  I don't have access to any other build environments to experiment on [save ideone et al, but being limited to one translation unit is rather limiting in this case].</p>