Changeset a32b204 for translator/Common
- Timestamp:
- May 17, 2015, 1:19:35 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 0dd3a2f
- Parents:
- b87a5ed
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
translator/Common/utility.h
rb87a5ed ra32b204 22 22 maybeClone( const T *orig ) 23 23 { 24 if ( orig ) {24 if ( orig ) { 25 25 return orig->clone(); 26 26 } else { … … 33 33 maybeBuild( const U *orig ) 34 34 { 35 if ( orig ) {35 if ( orig ) { 36 36 return orig->build(); 37 37 } else { … … 44 44 printEnums( Input_iterator begin, Input_iterator end, const char * const *name_array, std::ostream &os ) 45 45 { 46 for ( Input_iterator i = begin; i != end; ++i ) {46 for ( Input_iterator i = begin; i != end; ++i ) { 47 47 os << name_array[ *i ] << ' '; 48 48 } … … 53 53 deleteAll( Container &container ) 54 54 { 55 for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) {55 for ( typename Container::iterator i = container.begin(); i != container.end(); ++i ) { 56 56 delete *i; 57 57 } … … 62 62 printAll( const Container &container, std::ostream &os, int indent = 0 ) 63 63 { 64 for ( typename Container::const_iterator i = container.begin(); i != container.end(); ++i ) {65 if ( *i ) {64 for ( typename Container::const_iterator i = container.begin(); i != container.end(); ++i ) { 65 if ( *i ) { 66 66 os << std::string(indent, ' '); 67 67 (*i)->print( os, indent + 2 ); … … 77 77 typename SrcContainer::const_iterator in = src.begin(); 78 78 std::back_insert_iterator< DestContainer > out( dest ); 79 while ( in != src.end() ) {79 while ( in != src.end() ) { 80 80 *out++ = (*in++)->clone(); 81 81 } … … 87 87 { 88 88 int count = 0; 89 for ( typename Container::const_iterator i = container.begin(); i != container.end(); ++i ) {90 if ( !(*i) ) {89 for ( typename Container::const_iterator i = container.begin(); i != container.end(); ++i ) { 90 if ( !(*i) ) { 91 91 std::cerr << count << " is null" << std::endl; 92 92 } … … 97 97 assign_strptr( std::string *str ) 98 98 { 99 if ( str == 0 ) {99 if ( str == 0 ) { 100 100 return ""; 101 101 } else { … … 115 115 std::list<T> tail( std::list<T> l ) 116 116 { 117 if (! l.empty()){117 if (! l.empty()){ 118 118 std::list<T> ret(++(l.begin()), l.end()); 119 119 return ret; … … 127 127 Ts ret; 128 128 129 switch ( l.size() ){129 switch ( l.size() ){ 130 130 case 0: 131 131 return ret; … … 193 193 { 194 194 while ( begin++ != end ) 195 if ( pred(*begin) ) *out++ = *begin;195 if ( pred(*begin) ) *out++ = *begin; 196 196 197 197 return; … … 200 200 template< class InputIterator1, class InputIterator2, class OutputIterator > 201 201 void zip( InputIterator1 b1, InputIterator1 e1, InputIterator2 b2, InputIterator2 e2, OutputIterator out ) { 202 while ( b1 != e1 && b2 != e2 )202 while ( b1 != e1 && b2 != e2 ) 203 203 *out++ = std::pair<typename InputIterator1::value_type, typename InputIterator2::value_type>(*b1++, *b2++); 204 204 } … … 206 206 template< class InputIterator1, class InputIterator2, class OutputIterator, class BinFunction > 207 207 void zipWith( InputIterator1 b1, InputIterator1 e1, InputIterator2 b2, InputIterator2 e2, OutputIterator out, BinFunction func ) { 208 while ( b1 != e1 && b2 != e2 )208 while ( b1 != e1 && b2 != e2 ) 209 209 *out++ = func(*b1++, *b2++); 210 210 }
Note: See TracChangeset
for help on using the changeset viewer.