简体   繁体   English

为什么支持 C++11 及更高版本的 C++ 编译器需要 Boost.SmartPtr?

[英]Why do I need Boost.SmartPtr for the C++ compiler that supports C++11 and later?

The boost C++ library is a famous sandbox for the language and Standard Library features that absorbed with each new version of the Standard C++. Boost C++ 库是一个著名的沙箱,用于吸收每个新版本的标准 C++ 的语言和标准库功能。 However boost components that eventually became a part of the Standard are still present in boost.然而,最终成为标准一部分的升压组件仍然存在于升压中。 One of the classic examples of said above are smart pointers.上述的经典示例之一是智能指针。 So why do I need Boost.SmartPtr for the C++ compiler that supports C++11 and later?那么为什么支持 C++11 及更高版本的 C++ 编译器需要Boost.SmartPtr呢?

Why do I need Boost.SmartPtr for the C++ compiler that supports C++11 and later?为什么支持 C++11 及更高版本的 C++ 编译器需要 Boost.SmartPtr?

Because:因为:

  1. You may need your program to compile with another compiler that doesn't support C++11 or later.您可能需要使用另一个不支持 C++11 或更高版本的编译器来编译您的程序。
  2. You may not want to bother implementing make_unique yourself.您可能不想自己实现make_unique Sure it's easy, but why do it when you can use an existing implementation?当然这很容易,但是当您可以使用现有实现时,为什么要这样做呢?
  3. You may want to use one of the smart pointers provided by Boost.SmartPtr besides shared pointer.除了共享指针之外,您可能还想使用 Boost.SmartPtr 提供的智能指针之一。
  4. You may already have been using it, and don't want to pay for the effort of stopping using it.您可能已经在使用它,并且不想为停止使用它付出代价。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM