Text: 1. Character conversion 1.1 Related class lexical_cast bad_lexical_cast 1.2 definition file: #include 1.3 Function Description: Used to convert, here you want to explain, I think the type conversion has two categories: A. Conversion of grammar, such as INT to Double, derived class to base class conversion, pointer conversion, etc., Semantic conversion, such as "1234" string to integer 1234 conversion. This lexical_cast's conversion is considered to be semantically converted. 1.4 Example of use: UltraEdit10.10c MS C / C Compiler12.00.8804 for 80x86 win2k (sp5) test passes. #Include #include
Using namespace std;
Main () {int i = 100; char * pstr = "10101"; cout << "Before Convert I is:" << i << endl; i = boost :: lexical_cast (pstr); cout << "After Convert I is:" << i << Endl; Return 0;} // Print: Before Convert I is: 100 // After Convert I is: 10101 1.5 Other: The exception handling of the conversion is the same as the general exception handling. Such as: try {// convert} catch (bad_lexical_cast &) {// Handling exception} 2, formatted strings 2.1 Related class format 2.2 definition files: #include 2.3 Features: Build a format The character string, where some characters are pending, which can be written in the form of a parameter. 2.4 Example of use: UltraEdit10.10c MS C / C compiler12.00.8804 for 80x86 win2k (sp5) test passes. #Include #include #include
Using namespace std; using boost :: format; using boost :: IO :: group;
Main () {boost :: format FMT ("% 1%% 2%% 3%% 2%% 1% / N"); string str; cout << fmt% 1% 2% 3 << endl; return 0 } // print: 1 2 3 2 1 2.5 Others: å, it, such as advanced applications, user-defined types Please refer to the Boost library related documentation. Summary: until it is not finished.