使用Travis-CI
,我试图构建一个使用std::make_unique
的C++项目。但是,我得到了一个构建错误:
no member named 'make_unique' in namespace 'std'
mFiles.emplace_back(std::make_unique<File>(*this, rec));
我已经包含了memory
,这段代码在VS2013和gcc 4.8中用-std=c++14
编译。如果在clang3.4中使用此标志,则会得到一个错误:
error: invalid value 'c++14' in '-std=c++14'
根据clang文档:
我应该使用-std=c++1y
,但这仍然是相同的no member named 'make_unique' in namespace 'std'
。那我怎么才能让它起作用?
发布于 2015-04-04 19:42:57
这不取决于编译器,而取决于标准库实现。std::make_unique
不是一个核心语言特性,而是一个库函数。
检查Travis使用的libstdc++
版本。
据GCC 4.9变化g报道,GCC·4.9释放后,std::make_unique
被引入libstdc++
。
如果特拉维斯在4.9之前使用GCC的版本,那么它的libstdc++
版本很可能还没有std::make_unique
。
https://stackoverflow.com/questions/29432033
复制相似问题