官术网_书友最值得收藏!

Avoiding manual memory management with smart pointers

The smart pointers are highly useful and have an essential knowledge in using C++ efficiently. C++11 added many new abilities for the smart pointer we can find in the memory header file. For a long time, before C++11, we used auto_ptr as a smart pointer. However, it was quite unsafe since it had incompatible copy semantics. It's also deprecated now, and we should not use it anymore. Fortunately, C++ has presented unique_ptr, which has a similar functionality, but with additional features, such as adding deleters and support for arrays. Anything we can do with auto_pt, we can and should do with unique_ptr instead. We will discuss unique_ptr in depth along with other new smart pointers in C++11--shared_ptr and weak_ptr.

主站蜘蛛池模板: 五原县| 吉木乃县| 高碑店市| 松滋市| 平阳县| 黎川县| 博野县| 洛浦县| 镇雄县| 云浮市| 栾城县| 社会| 建水县| 湘乡市| 临安市| 雷山县| 新绛县| 涞水县| 华安县| 修水县| 沐川县| 沧源| 汪清县| 溆浦县| 镇安县| 台东市| 东丰县| 昌乐县| 东乡县| 庐江县| 漯河市| 祥云县| 巴塘县| 济阳县| 新兴县| 老河口市| 诏安县| 郎溪县| 高雄市| 比如县| 临沭县|