如何在动态链接库dll/so中导出自定义的模板类template class
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 本文首发于个人博客 https://kezunlin.me/post/4ec4ae49/ ,欢迎阅读最新内容! how to implement a template class with c++ and export in dll/so <!--more--> Guide questions 模板类必须在header中实现,而不能在cpp中实现,否则作为dll调用进行链接的时候回出错。 common solutions(Recommend) implement template functions in header. ThreadPool.h class SHARED_EXPORT ThreadPool { public: static ThreadPool* Instance(size_t max_thread_pool_size); ~ThreadPool(); // Add new work item to the pool. template<class F> inline void Enqueue(F f) { io_service_.post(f);//sync, return immediately } void Free(); private: static std::shared_ptr