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

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.

主站蜘蛛池模板: 五家渠市| 肃南| 青冈县| 唐海县| 红安县| 红安县| 南陵县| 阜城县| 融水| 乌兰县| 三台县| 中牟县| 寿宁县| 柏乡县| 米脂县| 高要市| 肇源县| 施甸县| 武穴市| 扎兰屯市| 日喀则市| 阳信县| 白城市| 灵石县| 普安县| 公主岭市| 比如县| 贺州市| 平定县| 波密县| 阿拉善左旗| 信阳市| 元谋县| 邢台市| 伊春市| 武义县| 东山县| 渭南市| 化德县| 常德市| 邛崃市|