title: What would be the reason that the explicit instantiation failed?
body: <pre><code>/* MyClass.h */
  class MyClass
  {
  public:
      template &lt;typename T&gt;
      void Foo(const T &amp;val);
  };
  
  /* MyClass.cpp */
  #include &lt;string&gt;
  #include &lt;iostream&gt;
  
  #define EXPLICIT_INSTANTIATION_FOO(MyType) \
      template void MyClass::Foo(const MyType &amp;val)
  
  EXPLICIT_INSTANTIATION_FOO(int);
  EXPLICIT_INSTANTIATION_FOO(float);
  EXPLICIT_INSTANTIATION_FOO(std::string);
  
  template &lt;typename T&gt;
  void MyClass::Foo(const T &amp;val)
  {
      std::cout &lt;&lt; "My Value: " &lt;&lt; val &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>For some other reason, I couldn't define the Foo in the header file, then I try to explicitly instantiate all the types I need in the source file. And it works pretty well on g++-4.8.</p>
  
  <p>Then once it I submit the codes, I find the building failed on <code>Windows 10, x86_64, cl19</code>. It was an unresolved symbol error there and was look like my instantiations weren't be exposed from the object.</p>
  
  <p>But interestingly, when I try to reproduce this error on my own Windows by making that simple snippet above. I found it works well on my vs2017 with cl19...</p>
  
  <p>There would be thousands of configuration differs between the company and the personal machine, but I just don't have any idea that what would be the reason why the instantiations don't work there... Any ideas appreciated! :)</p>
  
  <p>SUPPLEMENTS:</p>
  
  <p>FYI, the complete codes are here:</p>
  
  <pre><code>/* MyClass.h */
  #pragma once
  class MyClass
  {
  public:
      MyClass();
      ~MyClass();
  
      template &lt;typename T&gt;
      void Foo(const T &amp;val);
  };
  
  /* MyClass.cpp */
  #include "MyClass.h"
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  
  #define EXPLICIT_INSTANTIATION_FOO(MyType) \
      template void MyClass::Foo(const MyType &amp;val)
  
  EXPLICIT_INSTANTIATION_FOO(int);
  EXPLICIT_INSTANTIATION_FOO(float);
  EXPLICIT_INSTANTIATION_FOO(std::string);
  
  MyClass::MyClass() {}
  
  MyClass::~MyClass() {}
  
  template &lt;typename T&gt;
  void MyClass::Foo(const T &amp;val)
  {
      std::cout &lt;&lt; "My Value: " &lt;&lt; val &lt;&lt; std::endl;
  }
  
  /* main.cpp */
  #include "MyClass.h"
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  
  int main()
  {
      std::string v = "hello";
      MyClass cls;
  
      cls.Foo(v);
  
      std::cin.get();
      return 0;
  }
  </code></pre>
  
  <p>Which passed the compilation on msvc.</p>