TAILIEUCHUNG - HandBooks Professional Java-C-Scrip-SQL part 77

Tham khảo tài liệu 'handbooks professional java-c-scrip-sql part 77', 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ả | p_statuses 2 - break_it We can still use both the Standard Library but we can no longer use mem_fun_ref. We need help from the adaptor mem_fun which is considered a bit of a misnomer but again does the job that needs to be done. std for_each std mem_fun status report Although this works too the syntax has changed even though we are trying to do something very similar. It would be nice if the syntax was identical to the first example so that the focus is on what the code really does rather than how it does it. Using bind we do not need to be explicit about the fact that we are dealing with elements that are pointers this is already encoded in the type of the container and redundant information of this kind is typically unnecessary for modern libraries . std for_each boost bind status report _1 As you can see this is exactly what we did in the previous example which means that if we understood bind then we should understand it now too. Now that we have decided to switch to using pointers we are faced with another problem namely that of lifetime control. We must manually deallocate the elements of p_statuses and that is both error prone and unnecessary. So we may decide to start using smart pointers and again change our code. std vector boost shared_ptr status s_statuses boost shared_ptr status new status status 1 boost shared_ptr status new status status 2 boost shared_ptr status new status status 3 boost shared_ptr status new status status 4 s_statuses 1 - break_it s_statuses 2 - break_it Now which adaptor from the Standard Library do we use mem_fun and mem_fun_ref do not apply because the smart pointer doesn t have a member function called report and thus the following code fails to compile. std for_each std mem_fun status report The fact of the matter is that we lucked outthe Standard .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.