std :: wstring.length()函數的結果是什麼,wchar_t(s)中的長度或符號的長度?爲什麼?std :: wstring長度
TCHAR r2[3];
r2[0] = 0xD834; // D834, DD1E - musical G clef
r2[1] = 0xDD1E; //
r2[2] = 0x0000; // '/0'
std::wstring r = r2;
std::cout << "capacity: " << r.capacity() << std::endl;
std::cout << "length: " << r.length() << std::endl;
std::cout << "size: " << r.size() << std::endl;
std::cout << "max_size: " << r.max_size() << std::endl;
Output>
capacity: 351
length: 2
size: 2
max_size: 2147483646
大小和長度是同義詞 – 2010-11-15 11:21:19
size_type string :: capacity()const 返回字符串可以容納的字符數量,無需重新分配。 – 2010-11-15 11:22:07