Changes in src/Common/utility.h [234223f:bc3127d]
- File:
-
- 1 edited
-
src/Common/utility.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Common/utility.h
r234223f rbc3127d 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 … … 255 277 ~ValueGuardPtr() { if( ref ) *ref = old; } 256 278 }; 257 258 template< typename aT >259 struct FuncGuard {260 aT m_after;261 262 template< typename bT >263 FuncGuard( bT before, aT after ) : m_after( after ) {264 before();265 }266 267 ~FuncGuard() {268 m_after();269 }270 };271 272 template< typename bT, typename aT >273 FuncGuard<aT> makeFuncGuard( bT && before, aT && after ) {274 return FuncGuard<aT>( std::forward<bT>(before), std::forward<aT>(after) );275 }276 279 277 280 template< typename T >
Note:
See TracChangeset
for help on using the changeset viewer.