c++ 中程序模板方法 提示 more than one instance of overloaded function 错误 , 有可能是调用的时候没有加空间名称,或者

模板方法放置的空间不对。

如我在头文件 定义了 模板方法 

namespace threading {

template <typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
 
实现文件中,正常理解应该不用加 threading, 可是这里不加,就会提示错误。所以解决就是加上。
namespace threading {

Executor::Executor()
: m_taskQueue{std::make_shared<TaskQueue>()},
m_taskThread{threading::make_unique<TaskThread>(m_taskQueue)} {
m_taskThread->start();
}
 
posted on 2021-01-08 16:38  swing07  阅读(1545)  评论(0编辑  收藏  举报