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

Tham khảo tài liệu 'handbooks professional java-c-scrip-sql part 43', 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ả | class derived_class public another_class template typename T void intrusive_ptr_add_ref T t t- add_ref template typename T void intrusive_ptr_release T t if t- release 0 t- call_before_destruction delete t Here we have implemented generic versions of intrusive_ptr_add_ref and intrusive_ptr_release. We must therefore remove the generic versions that we previously put in the global namespace and replace them with non-templated versions accepting a pointer to reference_counter as their argument. Or we could omit these functions from the global namespace altogether to avoid cluttering it. For the two classes my_namespace another_class and my_namespace derived_class the special version which calls a member function call_before_destruction on its arguments is called. Other types either have corresponding functions in the namespace where they are defined or use the version in the global namespace if it exists. Here s a short program to illustrate how this works int main boost intrusive_ptr my_namespace another_class p1 new my_namespace another_class boost intrusive_ptr A p2 new good_class boost intrusive_ptr my_namespace derived_class p3 new my_namespace derived_class First the intrusive_ptr pl is passed a new instance of my_namespace another_class. When resolving the call to intrusive_ptr_add_ref the compiler finds the version in my_namespace the namespace of the my_namespace another_class argument. Thus the generic function which is provided for types in that namespace is correctly invoked. This applies when finding intrusive_ptr_release too. Then the intrusive_ptr p2 is created and passed a pointer of type A the one we created earlier . That type resides in the global namespace so when the compiler tries to find the best match for the call to intrusive_ptr_add_ref it finds only one which is the version accepting an argument of type pointer to reference_counter you ll recall that we had to remove the generic version from the global namespace . Because A inherits .

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.