"Chris \( Val \)" <chrisval@bigpond.com.au> scribbled on the stall wall:[color=blue]
>
> "Wiseguy" <noone@uber.usachoice.net> wrote in message
> news:42955871$1_2@spool9-west.superfeed.net...[color=green]
>>[/color]
> If you only want a fixed width for each element, then you can
> easily set the width of the string:
>
> std::ostream_iterator<int> i( std::cout, " " );[/color]
[color=blue]
> Better yet, you might obtain it dynamically:
>
> std::string Width( 4, ' ' );
> std::ostream_iterator<int> i( std::cout, Width.c_str() );
>[/color]
how does that enforce a field width?...the above would just ALWAYS put
n-spaces after each item sent to the stream, right? that's not what I
want because my purpose is to use the iterators in stl algorithms like
copy.
[color=blue]
> Even better yet, what about using a function object ?:[color=green]
>>[/color]
> inline void SpecialFormat( int n )
> {
> }[/color]
unfortunately the function object is not generic enough and needs to work with
stl algorithms. that's the whole purpose behind my quest: a generic ways of
using iterators that preserve the special formatting and (state) information of
the stream they are acting upon.
seems that for something like
o << setw(4) << something;
the field width restriction is only valid for the duration of the previous
statement and that adding another
o << somethign_else;
would NOT respect the previous setw()...that's the point of my contention.
so, a more related question would be "how to make something like setw()
permanent for the duration of a stream's existence?"
--
--
dual 2.8Ghz Xeon; 2GB RAM; 500GB ATA-133; nVidia powered
Linux 2.6.10; glibc-2.3.5; vendor neutral home-brewed installation
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----