|
Boost : |
From: Jonathan Turkanis (technews_at_[hidden])
Date: 2004-11-07 11:49:02
"Thorsten Ottosen" <nesotto_at_[hidden]> wrote in message
news:cmlhsv$63u$1_at_sea.gmane.org...
> Hi Jonathan,
>
> A smalll comment.
>
> Could syntax like
> << punctuate< vector<string> >("{ ", ", ", " }")be made into<< punctuate(
> my_variable )( "{ ", ", ", " }" )to deduce the arguments instead of specifying
> them?-Thorsten
Hi Thorsten,
Yes, it could work this way. But one of the features of this library --
which I realize now I never pointed out in the docs -- is that formatting
options for a particular type or collection of types can be set once and then
used many times.
cout << punctuate< vector<_> >("{ ", ", ", " }");
....
vector<string> v1 = list_of(...);
cout << v1;
...
vector< list<string> > v2 = list_of(...);
cout << v2
....
At the time you set the formatting options you might not have an instance of the
type lying around. Even if you have an instance of the outer type, you might
want to specify how some deeply nested types are formatted, and it may be hard
to get to them. Finally, I'm not sure how you would indicate whether the
formatting options apply to all specializations of a given template or only to
exact matches, without introducing more complex notation.
I guess I could add more overloads of punctuate and let users choose.
BTW, I used the Assign library in the examples and regression tests, and I don't
think I could have done without it. Thanks!
Jonathan
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk