lundi 12 août 2019

mid point using reverse iterators

palindromes implementation using reverse iterators

the error in code is of operator /, being not defined for iterators

s1 == std::string{ s1.rbegin(), s1.rend() }    // works fine
s == string{ s.rbegin(), (s.rend()/2) }        // gives error
s == string{ s.rbegin(), s.rbegin() + (s.rend()/2) } // also gives error

I'm expecting a one or two lines of code for palindrome check. Is there an elegant code. Am I missing something about reverse iterators?

Aucun commentaire:

Enregistrer un commentaire