I wrote a class template and use it in different DLLs, so wish to hide some parts of the implementation.
To do this, I use "template instantiation", but export it, like this, here is the header file:
#include <iostream>
#include <exception>
using namespace std;
template<typename T>
class __declspec(dllexport) Templated
{
public:
Templated();
};
template __declspec(dllexport) Templated<int>;
int main()
{
cout << "Hello World" << endl;
}
And the definition is in a separate file (.cpp)
template<typename T>
Templated<T>::Templated() {}
template Templated<int>;
My problem is that I got a warning, even if the instantiation is marked as exported!
You can test this code here : http://webcompiler.cloudapp.net/, it will generate the C4661 warning!
Is this normal?