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

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.

主站蜘蛛池模板: 兴宁市| 梁平县| 迁西县| 锡林浩特市| 新巴尔虎右旗| 元朗区| 分宜县| 泽库县| 揭东县| 尖扎县| 柯坪县| 闽清县| 拉萨市| 奈曼旗| 理塘县| 无极县| 湾仔区| 安国市| 文成县| 赤壁市| 蓬安县| 独山县| 精河县| 印江| 彩票| 青阳县| 东阿县| 新河县| 日土县| 福海县| 武安市| 萨嘎县| 永嘉县| 西和县| 会东县| 连云港市| 鄂伦春自治旗| 额敏县| 菏泽市| 孟连| 秦安县|