0

I have a class that has a template method:

class DoStuffWithAnything {
public:
    template <typename T>
    void doStuff(const T&);
};

Note that the method is not defined and will never be defined generically. Compilation units will define the implementation for these methods.

On gcc, I actually have no issue, because if a symbol is not defined it will be searched on the DSO.

On msvc I have a problem, how can I tell MSVC that it should import the definition (and when compiling the DSO, that it should export the definition)?

Clarifications

Suppose I have a lib called XX. and the libXX has a class XX. Also, the libXX defines <> doStuff(const XX&).

So, XX.hpp

class XX {
    //...
};

And, XX.cpp:

#include <XX.hpp>
#include <do_stuff_with_anything.hpp>

//...
template <>
void DoStuffWithAnything::doStuff(const XX&) {
    //...
}

So, my app.exe, would have a code like that:

#include <XX.hpp>
#include <do_stuff_with_anything.hpp>

int main() {
    XX a;
    DoStuffWithAnything stuffer;
    stuffer.doStuff(a);
}

app.exe must know that doStuff<XX> is imported. How can I tell that?

Community
  • 1
  • 1
André Puel
  • 8,741
  • 9
  • 52
  • 83

0 Answers0