#include
// Prints "xx13 1 xx13 / n" // printf Directives's type-flag can be used to pass formatting options: cout << format ("_% 1 $ 4D_ IS: _% 1 $ # 4x_, _% 1 $ # 4O_, AND _% 1 $ s_ by default / n ")% 18; //prints" _ 18_ is: _0x12_, _ 022_, and _18_ by default / n "// taking the string value: std :: string s; S = STR (Format ("% D% D")% 11% 22); assert (s == "11 22"); // ------------------ ----------------------------- // %% Prints '%' cout << Format ("%% ##% # x ")% 20 << endl; //prints"% ## 0x14 "// ----------------------------- ---------------- // Enforcing the right number of arguments // Too Much arguments Will throw an exception when feeding the unwanted argument: try {format ("% 1%% 1% ")% 101% 102; // the format-string refers to one argument, twice. Not 2 arguments. // thus giving 2 arguments is an error} catch (boost :: oose :: TOO_MANY_ARGS & EXC) {CERR << EXC .what () << "/ n / t / t *** DONT WORRY, THAT WAS Planned / N ";} // Too Few Arguments When Requesting The Result Will Also Throw An Exception: Try {CERR Hello 3O OO O OO O (X, Y) = (-23, 35) Writing Toto, X = 40.23: 50-TH Step (x, y) = (-23, 35) (x, y) = -23, 35) = (-23, 35) XX13 1 XX13_ 18_ IS: _0X12_, _ 022_, and _18_ by default% ## 0x14 boost :: TOO_MANY_ARGS: Format-String Refered to Less Arguments Than were passed *** DONT WORRY, THAT WAS Plannedboost :: Too_Few_Args: format-string refered to more arguments Than wele passed *** Dont Worry, That Was Plannedesthing Went Ok, Exiting.