- A series of articles to feature in Overload in 09
- Monolith
1. Output a string that uses a single argument twice, with default formatting in each case:
ff::fmtln(std::cout, "x={0}; y={0};", "abc");
This prints x=abc; y=abc;
2. Specify a minimum width for the first parameter:
ff::fmtln(std::cout, "x={0}; y={0,10};", "abc");
This prints x=abc; y= abc;
3. Specify a minimum width and right alignment (which is the default) for the first parameter:
ff::fmtln(std::cout, "x={0}; y={0,10,,>};", "abc");
This prints x=abc; y= abc;
4. Specify a minimum width and left alignment for the first parameter:
ff::fmtln(std::cout, "x={0}; y={0,10,,<};", "abc");
This prints x=abc; y=abc ;
5. Specify a minimum width and centre alignment for the first parameter:
ff::fmtln(std::cout, "x={0}; y={0,10,,^};", "abc");
This prints x=abc; y= abc ;
6. Specify a maximum width for the second parameter:
ff::fmtln(std::cout, "x={0}; y={0,,2};", "abc");
This prints x=abc; y=bc;
7. Specify a maximum width and left alignment for the second parameter:
ff::fmtln(std::cout, "x={0}; y={0,,2,<};", "abc");
This prints x=abc; y=ab;
The precise semantics of the alignment and fill (not shown above) options may still be changed, but the basis of the parameter syntax (four fields: index, min-width, max-width, alignment-and-fill) seem to work out well.
And the really great news late last night was that this new functionality has no appreciable cost over 0.2, so FastFormat is still head and shoulders ahead of Boost.Format, Loki.SafeFormat, and the IOStreams in performance (as it also is in robustness, expressiveness and flexibility).
I've released beta 7 of 0.2.1 today, and hope to be releasing an alpha of 0.3 in the next couple of weeks.
No comments:
Post a Comment