修改std :: string的运行时是什么?我假设时间是固定的,还是在字符串类的后台进行了更多的工作?
#include <string> int main() { std::string str = "Hello World!" str[1] = 'a'; // <--- what is the runtime? }
干杯
是的,它是恒定的。根据此:
复杂 不变。
复杂
不变。
也就是说,对于C ++ 11,它对于C ++ 98未指定,但是我不认为使用非常量实现std::string::operator[]是司空见惯的。
std::string::operator[]
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
点击生成二维码
我来说两句