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

Tham khảo tài liệu 'handbooks professional java-c-scrip-sql part 49', 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ả | lexical_cast Header boost Lexical conversions are performed in virtually all applications. We convert strings to numeric values and vice versa. Many user-defined types can be converted to strings or created from strings. It is all too common to write the code for these conversions each time you need it which suggests that it is very much suited for a reusable implementation. That s lexical_cast s purpose. Think of lexical_cast as using a std stringstream as an interpreter between the string and other representation of a value. That means that it will work for any source with an appropriate output operator and any target with an appropriate operator . That s true for all of the built-in types and many user-defined types UDTs . Usage lexical_cast makes a conversion between types look like any other typeconverting cast. Of course there must be a conversion function somewhere to make it work but conceptually it can be thought of as a cast. Rather than calling one of a number of conversion routines or even coding the conversion locally lexical_cast does that job for any types that meet its requirements. The source type must be OutputStreamable and the destination type must be InputStreamable. In addition both types need to be CopyConstructible and the target also DefaultConstructible and Assignable. OutputStreamable means that there s an operator defined for the type and InputStreamable mandates an operator . This is true for many types including the built-in types and the string classes from the Standard Library. To use lexical_cast include boost . Putting lexical_cast to Work I won t bore you by producing conversion code manually to show how much code lexical_cast saves you because I m sure you ve written these conversions yourself and quite probably done so more than once. Instead the example just uses lexical_cast for a number of common lexical type conversions. include iostream include string include boost int main

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.