0
通過C++代碼挖掘,它看起來像它做了一個副本,但我無法確定。通過「複製」,我的意思是類似strcpy內部發生。並且std:string不會以指向內部傳遞的相同char *的指針結束。將std :: string.assign(const char *)或op =(with const char *)創建一個char *的副本?
const char *somestring = ...
std::string str;
str.assign(somestring);
// or
str = somestring; //in my impl, op= calls to assign(const char*)
參考複製字符串時,計數可能發生。但是這個問題是關於複製一個'const char *',它不能被引用計數。 – interjay 2014-09-05 18:52:08
@interjay:也提到operator = though。 – 2014-09-05 18:52:53
它用'const char *'參數提到'operator ='。 – interjay 2014-09-05 18:54:36