尝试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 和 Apple的C++ 标准库专家:
技术报告 #1 (TR1) 是 C++03 标准的一组库添加。代表它们不是“官方”标准的一部分,它们被放置在命名空间 std::tr1 中。
在 c++11 中,它们正式成为标准的一部分,并存在于命名空间 std 中,就像向量和字符串一样。包含文件也不再位于“tr1”文件夹中。
带走: