Changeset b3f252a for src/Common/utility.h
- Timestamp:
- Sep 7, 2017, 10:36:35 AM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- e0886db
- Parents:
- 871cdb4 (diff), 416cc86 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Common/utility.h
r871cdb4 rb3f252a 174 174 } 175 175 176 template <typename E, typename UnaryPredicate, template< typename, typename...> class Container, typename... Args > 177 void filter( Container< E *, Args... > & container, UnaryPredicate pred, bool doDelete ) { 178 auto i = begin( container ); 179 while ( i != end( container ) ) { 180 auto it = next( i ); 181 if ( pred( *i ) ) { 182 if ( doDelete ) { 183 delete *i; 184 } // if 185 container.erase( i ); 186 } // if 187 i = it; 188 } // while 189 } 190 176 191 template< typename... Args > 177 192 auto zip(Args&&... args) -> decltype(zipWith(std::forward<Args>(args)..., std::make_pair)) { … … 207 222 std::cerr << "Warning: "; 208 223 warn_single( params... ); 224 } 225 226 /// determines if `pref` is a prefix of `str` 227 static inline bool isPrefix( const std::string & str, const std::string & pref ) { 228 if ( pref.size() > str.size() ) return false; 229 auto its = std::mismatch( pref.begin(), pref.end(), str.begin() ); 230 return its.first == pref.end(); 209 231 } 210 232
Note: See TracChangeset
for help on using the changeset viewer.