Boost logo

Boost Users :

From: Terje Slettebų (tslettebo_at_[hidden])
Date: 2003-03-14 16:19:44


>From: "Reece H Dunn" <yg-boost-users_at_[hidden]>

> I have a manipulator that will display lists in the basic form:
> [ i1, i2, ... , in ]
>
> It has a usage for a container where it prints the entire container in the
> list notation; it also has the ability to select the range to be
displayed:
>
> template< typename ForwardIterator >
> inline formatlist_t< ForwardIterator > formatlist( ForwardIterator
> first, ForwardIterator last );
>
> template< typename Container >
> inline formatlist_t< typename Container::iterator > formatlist(
> Container & c );
>
> Example usage of the manipulator is thus:
>
> std::vector< int > v( 10 );
> std::generate( v.begin(), v.end(), std::rand );
>
> // basic list formatting
> std::cout << "list = " << stl::formatlist( v ) << '\n';
> // use the form :- ( i1, ..., in )
> std::cout << "list = " << stl::formatlist( v ).format( '(', ')' ) <<
> '\n';
> // use the form :- [ i1 | ... | in ]
> std::cout << "list = " << stl::formatlist( v ).format( '|' ).space(
> true, true ) << '\n';
>
> You can currently configure the opening and closing elements of the list
> (default to '[' and ']'); the seperator used (defaults to ','); the
spacing
> around the list (default true) and before/after the seperator (defaults to
> after the seperator only).
>
> I would like to submit it into the boost library. Are there any
> comments/suggestions/questions?

I've been working on something similar, here
(http://groups.yahoo.com/group/boost/files/composite_stream_operators/).
Perhaps we could exchange ideas.

Also, maybe you could have provided the code?

Regards,

Terje


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net