c++ - 什么是 "visual studio 2008"的 unique_ptr 替换,没有第 3 个库(例如 boost)

标签 c++ visual-studio-2008 unique-ptr

Visual Studio 2008 中有类似 unique_ptr<> 的东西吗?

事件 Visual Studio 只有标题也可以。

我想要此功能但不想使用第 3 方库。因为我正在编写示例/学习代码。

如果没有,为了简化,我将不得不直接使用原始指针。虽然心里不舒服....

最佳答案

VS2008 不支持右值引用,因此不支持移动操作。 unique_ptr 行为依赖于这些,因此在 C++03 中可能没有确切的替代品。 auto_ptr 使用 copy-Ctor 来完成应该由 move-Ctor 完成的事情。您可以使用它们,但我建议您不要这样做,因为编译器无法像他使用 unique_ptr 那样帮助您找到不需要的拷贝。

另见此处:unique_ptr boost equivalent?

关于c++ - 什么是 "visual studio 2008"的 unique_ptr 替换,没有第 3 个库(例如 boost),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15222161/

相关文章:

c++ - 为什么这个 type_traits 代码给我一个整数到指针转换警告?

c++ - 由于折旧导致 Arduino FastLED 编译错误

visual-studio-2008 - Visual Studio 部署项目 : Conditional Files Depending on Build Configuration

c++ - 如何为类 unique_ptr 创建运算符->

c++ - 如何在 Google Mock 中模拟返回类型为 unique_ptr 的方法?

c++运算符重载看不到其他运算符

c++ - Bullet Physics 最简单的碰撞示例

asp.net - 使用 Firefox 时如何在 visual studio 2008 中启用脚本调试

c# - Visual Studio 2008 : Step to next line is very slow when debugging managed code

c++ - 将唯一指针传递给模板函数