tailieunhanh - HandBooks Professional Java-C-Scrip-SQL part 37

Tham khảo tài liệu 'handbooks professional java-c-scrip-sql part 37', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | How Does the Smart_ptr Library Improve Your Programs Automatic lifetime management of objects with shared_ptr makes shared ownership of resources effective and safe. Safe observation of shared resources through weak_ptr avoids dangling pointers. Scoped resources using scoped_ptr and scoped_array make the code easier to write and maintain and helps in writing exception-safe code. Smart pointers solve the problem of managing the lifetime of resources typically dynamically allocated objects 1 . Smart pointers come in different flavors. Most share one key featureautomatic resource management. This feature is manifested in different ways such as lifetime control over dynamically allocated objects and acquisition and release of resources files network connections . The Boost smart pointers primarily cover the first casethey store pointers to dynamically allocated objects and delete those objects at the right time. You might wonder why these smart pointers don t do more. Couldn t they just as easily cover all types of resource management Well they could and to some extent they do but not without a price. General solutions often imply increased complexity and with the Boost smart pointers usability is of even higher priority than flexibility. However through the support for custom deleters Boost s arguably smartest smart pointer boost shared_ptr supports resources that need other destruction code than delete. The five smart pointer types in are tailor-made to fit the most common needs that arise in everyday programming. 1 Just about any type of resource can be handled by a generic smart pointer type. When Do We Need Smart Pointers There are three typical scenarios when smart pointers are appropriate Shared ownership of resources When writing exception-safe code Avoiding common errors such as resource leaks Shared ownership is the case when two or more objects must use a third object. How or rather when should that third object be deallocated To be sure that

TÀI LIỆU LIÊN QUAN
10    127    1
6    150    1
7    127    1
5    125    1
6    127    1
6    115    1
6    122    1
6    174    1
7    122    1
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.