Boost logo

Boost Users :

From: Reece H Dunn (yg-boost-users_at_[hidden])
Date: 2003-03-14 08:49:13


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 have currently only tested it with MS VC++.NET 7, but have written the
code to not use any MS specific features so it should be usable on most of
the current compilers.

-rhd-
mailto:msclrhd_at_[hidden]


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