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)...));
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/121219.html