What is the complexity of std::string::substr member function? Is it defined by standard or implementation-defined?
std::string::substr
A na?ve implementation would be O(k) where k is the length of the resulting substring. std::string does not support copy-on-write. If you want O(1) substring operations, use a data structure such as a Rope.
2.1m questions
2.1m answers
60 comments
57.0k users