一、boost::format工作的方式
基本的語法,boost::format( format-string ) % arg1 % arg2 % ... % argN
下面的例子說明boost::format簡單的工作方式
二、boost::format實際使用的實例
格式化語法: [ N$ ] [ flags ] [ width ] [ . precision ] type-char
三、boost::format新的格式說明符
%{nt}
當n是正數時,插入n個絕對製表符
cout << boost::format("[%10t]") << endl;
%{nTX}
使用X做爲填充字符代替當前流的填充字符(一般缺省是一個空格)
cout << boost::format("[%10T*]") << endl;
四、異常處理
一般寫法:
boost::format的文檔中有選擇處理異常的辦法,不過個人感覺實用性可能不強,下面是文檔中的例子
五、還有其它一些功能,但暫時感覺派不上用處,就不去深究了。