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

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.

主站蜘蛛池模板: 林西县| 崇州市| 德州市| 新兴县| 恩平市| 陇西县| 微山县| 包头市| 呼图壁县| 台北县| 长沙市| 襄垣县| 稻城县| 兴山县| 嘉义县| 盐池县| 昌图县| 巫山县| 鲁甸县| 大兴区| 文安县| 宜丰县| 尉犁县| 石河子市| 加查县| 手游| 衡阳县| 汝城县| 济源市| 紫金县| 雷波县| 潮州市| 鸡东县| 武义县| 临江市| 宜良县| 丹寨县| 镇雄县| 丽水市| 普格县| 沁水县|