I am using Visual Studio right now. I have a classic macro to mark dll api functions and classes. My understanding is that marking a class dllexport makes it's functions visible from other binaries, making possible to use the type provided by the dll.
I would like to know what is the behaviour of dllexport and dllimport when the class contain template member functions? My initial suspicion is that it just ignore them, and that would be exactly what I want.
But I can't find where in the MSDN they explain this specific case (they explain other cases though).
Example:
class MY_API Log // MY_API is either __declspec( dllexport ) or __declspec( dllimport ) depending on if we are compiling the library or using it's header
{
public:
// is this ignored?
template< typename TypeOfSomething >
Log& write( const TypeOfSomething& something )
{
test_stream << something;
}
~Log(); // ok this is exported/imported
private:
std::stringstream text_stream;
};
I simplified the code to give this example.
What I suspect is that if the client code use the write() function, it will instantiate the template, generating a real function code, maybe inlined. In this case, will the compiler mark it "dllimport" as it should with all member functions, or will it do nothing and just use that version in the client code?