Skip to content

Beginner here! #2549

Answered by amezents
VukMar asked this question in Q&A
Discussion options

You must be logged in to vote

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.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by VukMar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants