C++ 使用未声明的标识符'make_unique'
C++ Use of undeclared identifier 'make_unique'
我在构建时不断收到以下错误
使用未声明的标识符"make_unique"m_planet=make_unique();
我的头文件,它给出了错误,
#include "planet.h"
#include <memory>
using namespace std;
class PlanetBuilder
{
public:
PlanetBuilder();
virtual ~PlanetBuilder();
void createNewPlanetProduct() {
m_planet = make_unique<Planet>();
}
protected:
unique_ptr<Planet> m_planet;
};
#endif // PLANETBUILDER_H
我正在运行QtCreator 3.6.0,在Mac和Windows平台上都尝试过,错误是一致的。。我哪里错了?
make_unique需要#include <memory>
但既然你已经这样做了,我认为你没有使用C++14或更高版本。尝试在make文件中添加以下标志。
-std=c++14
对于5.7的当前QT,我使用#include。通过以下链接,您可以了解更多信息。QScopedPointer链接
相关文章:
- 为什么 std::unique 不调用 std::sort?
- VS Code "command":"make"与终端窗口中的命令行"make"不同
- 使用 make 编译 MPI,几个命名空间错误,例如"错误:未知类型名称'使用'?
- make 命令如何避免重新编译未更改的源文件?
- MAKE:找不到包含的用户定义的头文件?
- 'make check' GLIBC 运行时的链接问题
- 生成"unique"矩阵
- Qt5 [make -snap] 无法正确编译:进程"/usr/bin/snap"代码 1 退出
- mingw32-make 使用"MinGW Makefiles"生成器跟踪 CMAKE 无法将可执行文件链接到对象库
- 我对 std::unique(算法)C++有问题
- make 命令创建 .file,但不创建应用程序文件
- 如何摆脱导入的 make 项目中的 Eclipse 索引器"Type std::... could not be resolved"错误
- Qt Creator 在执行步骤 "make" 时出现编译错误,-fno-stack-limit
- 如何使用MySQL Connector and Make设置C++项目
- 使用 make 将对象文件放在特定目录中
- 我是 C++ 的新手,我试图调用 make 一个以 2 个类作为其参数的类构造函数
- "Make"失败并出现 Clang 错误 - 如何从 Clang 获得错误?
- 防止 GNU Make 在每次构建时生成 protobuf 代码
- Make zmqpp::socket::connect a std::future
- 链接从命令行转换为Make的库