What is the complexity of std::string::substr
member function? Is it defined by standard or implementation-defined?
This is all that standard has to say about it:
n3242, 21.4.7.8
- Requires:
pos <= size()
- Throws:
out_of_range
ifpos > size()
- Effects: Determines the effective length
rlen
of the string to copy as the smaller ofn
andsize() - pos
- Returns:
basic_string
.(data()+pos,rlen)
So the answer would be no, the complexity is not defined.
EDIT: Corrected as per n3242, pos > size not pos >= size