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

Tham khảo tài liệu 'handbooks professional java-c-scrip-sql part 38', 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ả | scoped_array Header boost The need for dynamically allocated arrays is usually best handled by std vector but there are two cases when it makes good sense to use arrays for optimization as there is some overhead in size and speed for vector and for expression of intent making it clear that bounds are fixed. 5 Dynamically allocated arrays are exposed to the same dangers as ordinary pointers with the added and all too common mistake of invoking the delete operator instead of the delete operator. I ve seen that mistake in places one could hardly imagine such as in widely used proprietary container classes scoped_array does for arrays what scoped_ptr does for pointers to single objects It deletes the memory. The difference is that scoped_array does it using the delete operator. 5 These are not clear-cut advantages. Indeed it is usually best to use std vector until performance measurements suggest the benefits of scoped_array are warranted. The reason that scoped_array is a separate class rather than being a specialization of scoped_ptr is because it is not possible to distinguish between pointers to single objects and pointers to arrays using metaprogramming techniques. Despite efforts to make that distinction no one has found a reliable way to do that because arrays decay so easily into pointers that carry no type information indicating that they point to arrays. As a result the onus is on you to use scoped_array rather than scoped_ptr just as you must otherwise choose to use the delete operator rather than the delete operator. The benefits are that scoped_array handles deletion for you and that scoped_array conveys that we are dealing with an array whereas a raw pointer doesn t. scoped_array is very similar to scoped_ptr with the differences that it provides operator to mimic a raw array. scoped_array is a superior alternative to ordinary dynamically allocated arrays. It handles lifetime management of dynamically allocated arrays similar to how .

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.