Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/utility.h

    r5f2f2d7 r843054c2  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Jun  8 14:43:54 2015
    13 // Update Count     : 13
     12// Last Modified On : Tue May 19 15:34:57 2015
     13// Update Count     : 3
    1414//
    1515
     
    1818
    1919#include <iostream>
    20 #include <sstream>
     20#include <strstream>
    2121#include <iterator>
    2222#include <string>
     
    6060        for ( typename Container::const_iterator i = container.begin(); i != container.end(); ++i ) {
    6161                if ( *i ) {
    62                         os << std::string( indent,  ' ' );
     62                        os << std::string(indent,  ' ');
    6363                        (*i)->print( os, indent + 2 );
    6464                        os << std::endl;
     
    130130template < typename T >
    131131std::string toString ( T value ) {
    132         std::ostringstream os;
     132        std::ostrstream os;
     133 
    133134        os << value; // << std::ends;
    134         return os.str();
     135        os.freeze( false );
     136
     137        return std::string(os.str(), os.pcount());
    135138}
    136139
     
    148151template< typename T >
    149152void replace( std::list< T > &org, typename std::list< T >::iterator pos, std::list< T > &with ) {
     153        // TIter should secretly be a typename std::list< T >::iterator
     154        //   ( g++ 3.2 issues a 'is implicitly a typename' warning if I make this explicit )
    150155        typename std::list< T >::iterator next = pos; advance( next, 1 );
    151156
     
    191196        while ( b1 != e1 && b2 != e2 )
    192197                *out++ = func(*b1++, *b2++);
    193 }
    194 
    195 // it's nice to actually be able to increment iterators by an arbitrary amount
    196 template< typename Iterator >
    197 Iterator operator+(Iterator i, int inc) {
    198         while ( inc > 0 ) {
    199                 ++i;
    200                 --inc;
    201         }
    202         return i;
    203198}
    204199
Note: See TracChangeset for help on using the changeset viewer.