Which is faster C++ String length() or size()?

Both have the same complexity: Constant. From the N4431 working draft, §21.4.4 size_type size() const noexcept; Returns: A count of the number of char-like objects currently in the string. Complexity: Constant time. And size_type length() const noexcept; Returns: size(). […] iterates through all the characters and counts the length […] That’s C strings you’re thinking … Read more