Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/utility.h

    r843054c2 r5f2f2d7  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 19 15:34:57 2015
    13 // Update Count     : 3
     12// Last Modified On : Mon Jun  8 14:43:54 2015
     13// Update Count     : 13
    1414//
    1515
     
    1818
    1919#include <iostream>
    20 #include <strstream>
     20#include <sstream>
    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::ostrstream os;
    133  
     132        std::ostringstream os;
    134133        os << value; // << std::ends;
    135         os.freeze( false );
    136 
    137         return std::string(os.str(), os.pcount());
     134        return os.str();
    138135}
    139136
     
    151148template< typename T >
    152149void 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 )
    155150        typename std::list< T >::iterator next = pos; advance( next, 1 );
    156151
     
    196191        while ( b1 != e1 && b2 != e2 )
    197192                *out++ = func(*b1++, *b2++);
     193}
     194
     195// it's nice to actually be able to increment iterators by an arbitrary amount
     196template< typename Iterator >
     197Iterator operator+(Iterator i, int inc) {
     198        while ( inc > 0 ) {
     199                ++i;
     200                --inc;
     201        }
     202        return i;
    198203}
    199204
Note: See TracChangeset for help on using the changeset viewer.