jeudi 2 janvier 2020

std::search extracting current iterator and moving iterator forward using std::advance

I have a function which utilizes std::search to look over a certain memory region provided from start to end and find a certain byte pattern. However, under certain conditions I would like to skip over a portion of this region rather than iterate over it from start to end byte by byte. For example move 50 bytes forward from current iterator position or something similar. Is there a way extract the current iterator object and move the iterator forward using std::advance?

const auto address = std::search( address_start, address_end, byte_pattern.cbegin(), byte_pattern.cend(),
    []( const uint8_t &current_byte, const memory::byte_t &pattern_byte ) { 
        // address of current byte in memory
        // this is also the current position of the search itterator
        const auto data = &current_byte;

        if( CERTAIN CONDITION ) {
            MOVE ITTERATOR FORWARD SO THAT WE MOVE FORWARD IN MEMORY WE ARE SCANNING BETWEEN [address_start, address_end]

        }

        return pattern_byte.compare( current_byte );
    }
);

Aucun commentaire:

Enregistrer un commentaire