What is the complexity of std::string::substr member function?

前端 未结 3 768
悲&欢浪女
悲&欢浪女 2020-12-18 07:37

What is the complexity of std::string::substr member function? Is it defined by standard or implementation-defined?

3条回答
  •  既然无缘
    2020-12-18 07:45

    The C++11 standard does not define the performance characteristics of substr, either in 21.4.7.8 or anywhere else I could find. In practice you can almost certainly expect O(n) performance with n being the length of the result.

提交回复
热议问题