Ignore:
Timestamp:
Sep 7, 2017, 10:36:35 AM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/utility.h

    r871cdb4 rb3f252a  
    174174}
    175175
     176template <typename E, typename UnaryPredicate, template< typename, typename...> class Container, typename... Args >
     177void 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
    176191template< typename... Args >
    177192auto zip(Args&&... args) -> decltype(zipWith(std::forward<Args>(args)..., std::make_pair)) {
     
    207222        std::cerr << "Warning: ";
    208223        warn_single( params... );
     224}
     225
     226/// determines if `pref` is a prefix of `str`
     227static 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();
    209231}
    210232
Note: See TracChangeset for help on using the changeset viewer.