-
I have a stupid question, but I started learning code on my own and I can't seam to understand this code #include int find_short(std::string str) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
cppreference states: std::string.size()(and std::string.length()) is defined as std::distance(begin(), end()), where begin() and end() are first and last input iterators. |
Beta Was this translation helpful? Give feedback.
cppreference states: std::string.size()(and std::string.length()) is defined as std::distance(begin(), end()), where begin() and end() are first and last input iterators.
std::distance is number of hops from first to last - positive number (positive direction is movement to right from lesser addresses to greater) . The value may be negative if random-access iterators are used and first is reachable from last. This means that me moves to the left (negative direction) from greater addresses to lesser So s.length() can be less then -1.