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

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.

主站蜘蛛池模板: 山东省| 吴旗县| 弥渡县| 宁明县| 沧州市| 五大连池市| 尚义县| 安达市| 友谊县| 金溪县| 阿坝县| 宿州市| 闽清县| 金门县| 临武县| 图们市| 景洪市| 炎陵县| 义马市| 乌拉特前旗| 英德市| 团风县| 密云县| 临清市| 双江| 武宣县| 图木舒克市| 宜春市| 江口县| 繁峙县| 南乐县| 余庆县| 芦山县| 灵台县| 霸州市| 克什克腾旗| 卓资县| 庆安县| 三河市| 乌海市| 扎兰屯市|