叮当 3.1 看不到unique_ptr?
clang 3.1 can't see unique_ptr?
我刚刚开始使用clang并尝试编译以下示例程序:
#include <memory>
#include <iostream>
int main()
{
std::unique_ptr<unsigned> u(new unsigned(10));
std::cout << *u << std::endl;
return 0;
}
编译时出现以下错误:
$ clang++ helloworld.cpp
helloworld.cpp:6:10: error: no member named 'unique_ptr' in namespace 'std'
std::unique_ptr<unsigned> u(new unsigned(10));
~~~~~^
helloworld.cpp:6:29: error: expected '(' for function-style cast or type construction
std::unique_ptr<unsigned> u(new unsigned(10));
~~~~~~~~^
helloworld.cpp:6:31: error: use of undeclared identifier 'u'
std::unique_ptr<unsigned> u(new unsigned(10));
^
helloworld.cpp:7:19: error: use of undeclared identifier 'u'
std::cout << *u << std::endl;
^
4 errors generated.
我在 Mac OS X 上使用 Clang 3.1:
$ clang++ --version
Apple clang version 3.1 (tags/Apple/clang-318.0.61) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix
任何想法为什么不编译?
我让它使用
clang++ test.cpp -std=c++11 -stdlib=libc++
相关文章:
- 为什么 std::unique 不调用 std::sort?
- CLANG 编译器 说:变量"PTR"可能未初始化
- 在以唯一ptr为值的C++映射中,动态内存何时会被销毁
- 将 ptr 传递给 ptr 到 A 作为参数传递给 A 的函数是不好的做法吗?
- 为共享 ptr 向量实现复制 c'tor?
- 字符和整数中 **(ptr+1) 的值差异
- C++:在不中断共享的情况下通过引用传递共享 PTR?
- 生成"unique"矩阵
- 如何将派生类从基 ptr 分配给 nlohmann::json
- 引用 std::shared:ptr 以避免引用计数
- 我对 std::unique(算法)C++有问题
- 为什么我不能在不进行任何转换的情况下将浮点数放入任何类型的 ptr 中?
- 在调用函数时,ptr** 和 ptr*& 之间是否有区别,或者首选C++?
- 另一种类型的智能ptr,比如具有弱refs的unique_ptr
- 尝试打印出 *ptr++ 的值,以了解它是如何工作的
- 如何控制共享 ptr 引用计数?
- std::shared_ptr::unique(),复制和线程安全
- 如何在C++03中用自定义谓词调用std::unique
- C++中的指针否定 (!ptr == NULL)
- C++14 unique_ptr并使用已删除的函数'std::unique-ptr' unique_ptr错误