In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how to understand the scoped_ptr in the Boost library. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
1. VC and VS
The VC version is not the standard Clippers, the vs version is in line with the standard Clippers, and its syntax is quite strict.
Disadvantages: both VC and VS can only release a specific type space, not array space, and the problem of copying when writing
So it leads to the emergence of Boost library to solve this kind of problem.
2. Boost library
It is recommended that you take a look at the complete development guide for the Boost library.
Boost itself is an open source library and plays an important role in C++. Chapter III memory Management, Smart pointer
Smart pointers are also provided in C++, but they don't solve all the problems.
In smart_ptr library: incorrect use of new delete is the root cause of resource acquisition / release problems in C++.
3. Scoped_ptr (local smart pointer)
(1) how to use
Scoped_ptr is a smart pointer similar to auto_ptr, but the ownership of scoped_ptr is more strict and cannot be transferred, and once scoped_ptr has acquired the management of the object, you can no longer get it back from it.
The normal smart pointer plus the # comment header file, and the construction of the Boost library is copied to the corresponding directory; then compile and make an error to comment on all of the comments.
# include#include#include / /: the smart_ptr.hpp;using namespace std; / / opening in the boost directory under the include directory is the declaration of other smart pointers; the namespace int main (void) {int * p = new int (10) that must be introduced into the using namespace boost; / / boost library; scoped_ptr ps (p); cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.