Boostは便利

最近になってBoostを知ったので、いろいろと勉強してます。
特にformatが便利ですね。

・ソース

#include <iostream>
#include <boost/format.hpp>

using namespace std;
using namespace boost;

int main(void)
{	
	cout << format("%1%") % "boostって便利だなー"  << endl;
	cout << format("%3% %2% %1%") % 1 % 2 % 3 << endl;
	cout << format("%d + %d = %d") % 10 % 20 % (10 + 20) << endl;

	return 0;
}

・実行結果

boostって便利だなー
3 2 1
10 + 20 = 30

これがあればprintfともおさらばじゃー。