// test FormatList #include #include #include // for vector #include // for generate #include // for rand #include "formatList.hpp" // for formatlist using std::cout; using std::cin; using std::endl; using std::dec; using std::hex; using std::boolalpha; using std::string; using std::setprecision; using std::setw; using std::vector; using std::generate; const char nl = '\n'; const char tab = '\t'; const char space = ' '; int main() { cout << "Test"; #if defined(__FILE__) && defined(__TIMESTAMP__) cout << " " << __FILE__ << space << __TIMESTAMP__; #endif cout << endl; 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'; // special: "( i1 tab i2 tab ... tab in )" std::cout << "list = " << stl::formatlist( v ).format('(', ')', tab ).space( false, false ) << '\n'; return 0; } // main /* Boost post Reece Dunn msclrhd@hotmail.com Requires C++ language extension option. Test testFomatList.cpp Wed Mar 19 17:43:07 2003 list = [ 41, 18467, 6334, 26500, 19169, 15724, 11478, 29358, 26962, 24464 ] list = ( 41, 18467, 6334, 26500, 19169, 15724, 11478, 29358, 26962, 24464 ) list = [ 41 | 18467 | 6334 | 26500 | 19169 | 15724 | 11478 | 29358 | 26962 | 2446 4 ] list = ( 41 18467 6334 26500 19169 15724 11478 29358 26962 2 4464 ) Press any key to continue */