title: dllimport and templates in MS Visual C++
body: <p>I have a class like this</p>
  
  <pre><code>class A_DLL A
  {
     ...
     template &lt;class T&gt; someFunction(const T &amp;v);
  }
  </code></pre>
  
  <p>in library a.dll. A_DLL is <code>__declspec(dllexport)</code> when building a.dll and <code>__declspec(dllimport)</code> when using a.dll.</p>
  
  <p>The problem is when I try to use 'someFunction' in some executable module linked against a.dll it works. However when I use it in some other library (b.dll) it gives me an error message about unresolved externals (someFunction and other templates). Obviously I should not use <code>__declspec</code> on templates but how then to make a class with <code>__declspec</code>?</p>