相关疑难解决方法(0)

在 LLVM/Clang 下编译时,命名空间“std”中没有名为“unique_ptr”的类型

尝试unique_ptr在 Apple 平台上使用时遇到编译错误-std=c++11

$ make
c++ -std=c++11 -DNDEBUG -g2 -O3 -fPIC -march=native -Wall -Wextra -pipe -c 3way.cpp
In file included ...
./smartptr.h:23:27: error: no type named 'unique_ptr' in namespace 'std'
    using auto_ptr = std::unique_ptr<T>;
                     ~~~~~^
./smartptr.h:23:37: error: expected ';' after alias declaration
    using auto_ptr = std::unique_ptr<T>;
Run Code Online (Sandbox Code Playgroud)

根据 Marshall Clow 的说法,我认为他是Clang 和 AppleC++ 标准库专家:

技术报告 #1 (TR1) 是 C++03 标准的一组库添加。代表它们不是“官方”标准的一部分,它们被放置在命名空间 std::tr1 中。

在 c++11 中,它们正式成为标准的一部分,并存在于命名空间 std 中,就像向量和字符串一样。包含文件也不再位于“tr1”文件夹中。

带走:

  • Apple 和 C++03 = 使用 …

unique-ptr llvm-clang c-preprocessor c++11 c++03

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

c++03 ×1

c++11 ×1

c-preprocessor ×1

llvm-clang ×1

unique-ptr ×1