Explicit instantiation of boost::shared_ptr<SomeClasss>

I am trying to do explicitly instantiate specific shared_ptr class for export from a Win32 DLL (currently with MSVC6, and eventually in VS2003). I have followed the Win32 rules found at: http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q168/9/58.ASP&NoWebContent=1 and have something like: // Provide the storage class specifier (extern for an .exe file, null // for DLL) and the __declspec specifier (dllimport for .an .exe file, // dllexport for DLL). // You must define EXP_STL when compiling the DLL. // You can now use this header file in both the .exe file and DLL - a // much safer means of using common declarations than two different // header files. #ifdef EXP_STL # define DECLSPECIFIER __declspec(dllexport) # define EXPIMP_TEMPLATE #else # define DECLSPECIFIER __declspec(dllimport) # define EXPIMP_TEMPLATE extern #endif EXPIMP_TEMPLATE template class DECLSPECIFIER boost::shared_ptr<SomeClass>; When I look through the exports, some needed class functions seem to be missing from the DLL, and linking fails. Most notable are: void boost::shared_ptr<SomeClass>::reset(SomeClass*) This function is declared in the shared_ptr header file as: template<class Y> void reset(Y * p); The reset function which does not take an argument is in the export list which is defined as: void reset(); // never throws And if I have a forward declaration of class followed by explicit instantiation, such as found below: class SomeClass; EXPIMP_TEMPLATE template class DECLSPECIFIER boost::shared_ptr<SomeClass>; The constructor that takes a class pointer is not generated: public: __thiscall boost::shared_ptr<class SomeClass>::shared_ptr<class SomeClass>(class SomeClass *) which is declared as: template<class Y> explicit shared_ptr(Y * p); Do I need to do extra explicit instantiations for the class members whose declarations start with "template<class Y>"? If so how does this syntax work? Any help or tips would be most appreciated. Greg Clayton

Greg Clayton wrote:
I am trying to do explicitly instantiate specific shared_ptr class for export from a Win32 DLL (currently with MSVC6, and eventually in VS2003).
First things first. Why do you need to do that? Have you tried not exporting it, have you encountered any problems? [...]
When I look through the exports, some needed class functions seem to be missing from the DLL, and linking fails. Most notable are:
void boost::shared_ptr<SomeClass>::reset(SomeClass*)
This function is declared in the shared_ptr header file as: template<class Y> void reset(Y * p);
This is a function template. A template can't be exported, only an instantiation. template void boost::shared_ptr<SomeClass>::reset(SomeClass*); should instantiate reset with Y=SomeClass.
participants (2)
-
Greg Clayton
-
Peter Dimov