c++ - export specialized template function from a dll -


i have template function define in header file in dll. don't need export function because of consumers read in header file , have whole function anyway. however, have specialization of template can't defined in header file (or redefinition linker errors), has go in source file.

what normal way export function?

template <typename t> bool functionname(/*params*/){ //..... }  template<> importexportmacro bool functionname(/*params*/); 

and source file has

template<> bool functionname(/*params*/){ //... 

importexportmacro 1 of macros either __declspec(dllimport) or dllexport

thanks

template things indeed place holders. until use , compiler not replace real (function / class) thing. can't place in dll. way provide in header file. if want hide implementation, consider using class hierarchy (runtime polymorphism)


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -