error: ‘make_unique’ is not a member of ‘std’
问题解释:
在编译使用了std::make_unique
语句的代码时,如果出现上述的错误,说明该编译器不支持C++14标准,因为std::make_unique
是在C++14以后新加入的函数,用来创建std::unique_ptr
智能指针对象。
解决方法:
1、尝试升级编译器版本支持C++14标准;
2、在代码中自己定义这个函数:
#include <memory>
namespace std {
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args&&... args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
}