Item 13: Use objects to manage resources.(Effective C++)
2010-01-05 22:09
531 查看
To prevent resource leaks, use RAII objects that acquire
resources in their constructors and release them in their destructors.
Two commonly useful RAII classes are TR1::shared_ptr
and auto_ptr. tr1::shared_ptr is usually the better choice,
because its behavior when copied is intuitive. Copying an auto_ptr sets
it to null.
resources in their constructors and release them in their destructors.
Two commonly useful RAII classes are TR1::shared_ptr
and auto_ptr. tr1::shared_ptr is usually the better choice,
because its behavior when copied is intuitive. Copying an auto_ptr sets
it to null.
相关文章推荐
- Effective C++ Item 13 Use object to manage resources
- [EffectiveC++]item13:Use objects to manage resources(RAII)
- Item13: Use objects to manage resources
- 条款13:以对象管理资源(use objects to manage resources)
- [Effective C++] Rules 13: Use objects to manage resources
- Item3:Use objects to manage resources--以对象管理资源
- effective c++ 条款13 use object to manage resources.
- Effective C# Item 23: Avoid Returning References to Internal Class Objects
- Effective C++ Item 18 Make interfaces easy to use correctly and hard to use incorrectly
- Use System.Transactions namespace to manage your own resources
- Item 18: Make interfaces easy to use correctly and hard to use incorrectly(Effective C++)
- Item 45: Use member function templates to accept "all compatible types."(Effective C++)
- [翻译] Effective C++, 3rd Edition, Item 13: 使用 objects(对象)管理资源
- Item 15: Provide access to raw resources in resource-managing classes.(Effective C++)
- Item32 Use Init capture to move objects into closures
- Effective C++ Item 15 Provide access to raw resources in resource-managing classes
- Effective Java 21 Use function objects to represent strategies
- <Effective Mordern C++>笔记:Item 8:prefer nullptr to 0 and NULL.
- Effective Java 19 Use interfaces only to define types
- [systemd]How To Use Systemctl to Manage Systemd Services and Units