Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/utility.h

    r490fb92e r77d2432  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Feb 11 13:00:36 2020
    13 // Update Count     : 50
     12// Last Modified On : Wed Jul 24 14:28:19 2019
     13// Update Count     : 41
    1414//
    1515
     
    2929#include <utility>
    3030#include <vector>
    31 #include <cstring>                                                                              // memcmp
    3231
    3332#include "Common/Indenter.h"
     
    265264}
    266265
    267 // determines if pref is a prefix of str
    268 static inline bool isPrefix( const std::string & str, const std::string & pref, unsigned int start = 0 ) {
     266/// determines if `pref` is a prefix of `str`
     267static inline bool isPrefix( const std::string & str, const std::string & pref ) {
    269268        if ( pref.size() > str.size() ) return false;
    270     return 0 == memcmp( str.c_str() + start, pref.c_str(), pref.size() );
    271         // return prefix == full.substr(0, prefix.size()); // for future, requires c++17
     269        auto its = std::mismatch( pref.begin(), pref.end(), str.begin() );
     270        return its.first == pref.end();
    272271}
    273272
     
    360359        reverse_iterate_t( T & ref ) : ref(ref) {}
    361360
    362         // this does NOT work on const T!!!
    363         // typedef typename T::reverse_iterator iterator;
    364         auto begin() { return ref.rbegin(); }
    365         auto end() { return ref.rend(); }
     361        typedef typename T::reverse_iterator iterator;
     362        iterator begin() { return ref.rbegin(); }
     363        iterator end() { return ref.rend(); }
    366364};
    367365
Note: See TracChangeset for help on using the changeset viewer.