Boost logo

Boost :

From: Paul A. Bristow (boost_at_[hidden])
Date: 2003-03-19 14:39:03


This is quite neat, and works for me using MSVC 7.0 but:

1 The layout is screwed up by the mail attachment process and requires some
editing to avoid compile errors.

2 The filename formatlist.hpp might be better?

3 Requires language extensions enabled.

Compiling...
testFomatList.cpp
testFomatList.cpp(38) : warning C4239: nonstandard extension used : 'argument' :
conversion from 'stl::formatlist_t<ForwardIterator>' to
'stl::formatlist_t<ForwardIterator> &'
        with
        [
            ForwardIterator=std::vector<int,std::allocator<int>>::iterator
        ]
        and
        [
            ForwardIterator=std::vector<int,std::allocator<int>>::iterator
        ]
        A reference that is not to 'const' cannot be bound to a non-lvalue
Linking...

Build log was saved at "file://j:\Cpp\FormatList\Debug\BuildLog.htm"
FormatList - 0 error(s), 1 warning(s)

but fails without

Compiling...
testFomatList.cpp
testFomatList.cpp(38) : error C2679: binary '<<' : no operator found which takes
a right-hand operand of type 'stl::formatlist_t<ForwardIterator>' (or there is
no acceptable conversion)
        with
        [
            ForwardIterator=std::vector<int,std::allocator<int>>::iterator
        ]

Build log was saved at "file://j:\Cpp\FormatList\Debug\BuildLog.htm"
FormatList - 1 error(s), 0 warning(s)

for the line

// default list: "[ i1, i2, ..., in ]"
std::cout << "list = " << stl::formatlist( v ) << '\n';

I suspect this can be cured to make it more Standard and more portable?

4 I haven't tried with the all important 3 and more dimensions like matrixes.

5 Many more examples and documentation desirable, of course. My slightly
longer test file attached. (Last example might suit input to a spreadsheet using
tab as a separator?)

and finally a nit - Separator is wrongly spelled.

Paul

Paul A Bristow, Prizet Farmhouse, Kendal, Cumbria, LA8 8AB UK
+44 1539 561830 Mobile +44 7714 33 02 04
Mobile mailto:pabristow_at_[hidden]
mailto:pbristow_at_[hidden]

> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]]On Behalf Of Reece Dunn
> Sent: Friday, March 14, 2003 6:07 PM
> To: boost_at_[hidden]
> Subject: [boost] Adding a generic list manipulator
>
>
> I have an output stream manipulator that allows the user of it to print out
> a list in a given range (first, last) or by a container c (c.begin(),
> c.end()).
>
> I am looking at adding this into the boost library. The source code for it
> is in the attachment (printlist.hpp).
>
> An example of its use is:
>
> std::vector< int > v( 10 );
> std::generate( v.begin(), v.end(), std::rand );
>
> // default list: "[ i1, i2, ..., in ]"
> std::cout << "list = " << stl::formatlist( v ) << '\n';
>
> // parenthesis: "( i1, i2, ..., in )"
> std::cout << "list = " << stl::formatlist( v ).format( '(', ')' ) << '\n';
>
> // special: "[ i1 | i2 | ... | in ]"
> std::cout << "list = " << stl::formatlist( v ).format( '|' ).space( true,
> true ) << '\n';
>
> At the moment I have only tested it on MS VC++.NET 7.0, but have only used
> the C++ standard language and the iostream header, so it should work on
> compliant compilers (with non-advanced template support).
>
> Is there any interest for this? Does anyone have comments, suggestions or
> questions? How do I go about adding this into boost and making it
> boost-compliant?
>
> Thanks for your assistance,
>
> -rhd-
> mailto:msclrhd_at_[hidden]
>
>
> _________________________________________________________________
>
>




Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk