mercredi 24 mai 2017

warning C4661:no suitable definition provided for explicit template instantiation request

I wrote a template class 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:

#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; 
}

My problem is that I got a warning, even if the instantiation is marked as exported !

You can test this code here : http://ift.tt/1qXV1Ol , it will generate the C4661 warning !

It is normal ?

Aucun commentaire:

Enregistrer un commentaire