Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-02-04 05:23:40

Terje Slettebø wrote:

>>This example should one case where manipulators are desirable:
>> vector< vector<int> > v;
>> cout << v ;
>>Here, each nested vector better go on a separate line. I suggest:
>> cout << multiline << v;
>>where "multiline" manipulator causes each element of the next output
> container
>>to go on separate line.
> The above io_format<>'s are intended to be manipulators. You could get this
> manipulator with:
> io_format<vector<int> >("\n","","") multiline;
> You could also make it so that this manipulator set the format for any
> container, but in cases where you have arbitrary deep nesting of containers
> (like in Peter Dimov's posting), it may be better to set the format on a
> per-type basis.

I think that when more that double nesting is involed you have problems

> Incidentally, I've just made a version that does exactly this. :) I've
> attached it, including a test, with this posting.

I've take a look and I like it -- quite lean and does the work. I've some
concerns, though:

1. Are "default" breaces/separators possible? I'd rather not use
    io_format every time I had to output a vector.
2. Is that good idea to set brace style on vector<int> and vector<double>
    separately? It would increase pword() array, and not sure if this will
    benefit us much. Are nested containers the primary motivation?

- Volodya

Boost list run by bdawes at, gregod at, cpdaniel at, john at