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

Tham khảo tài liệu 'handbooks professional java-c-scrip-sql part 70', 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ả | public void operator int i const std cout It s an int i n void operator std string s const std cout It s a std string s n void operator double d const std cout It s a double d n If we compile the example again the compiler will be really upset saying something like this c boost_cvs boost boost variant In member function typename Visitor result_type boost detail variant invoke_visitor Visitor internal_visit T int with T char Visitor print_visitor Snipped lines of irrelevant information here c boost_cvs boost boost variant 807 error no match for call to print_visitor char 40 error candidates are void print_visitor operator int const variant_sample 1. cpp 44 error void print_visitor operator std string const variant_sample 1. cpp 48 error void print_visitor operator double const This error pinpoints the problem There is no candidate function for char arguments That s one important reason why typesafe compile time visitation is such a powerful mechanism. It makes the visitation robust with regard to types and avoids the tedium of type-switching. Creating visitors is just as easy as creating other function objects so the learning curve here isn t very steep. When the set of types in the variants may change they tend to do that creating visitor classes is much more robust than relying solely on get. There is a higher initial cost but it s typically worth it for non-trivial uses. Generic Visitors By using the visitor mechanism and a parameterized function call operator it s possible to create generic visitors that are capable of accepting values of any type that can syntactically and semantically handle whatever the generic function call operator implementation requires . This is very useful for treating disparate types uniformly. Typical examples of universal features are the C operators such as arithmetic and lOStreams shift operators. The following example uses operator to print the variant values to a stream. include .

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.