「More C++ Idioms/反復子対(Iterator Pair)」の版間の差分
削除された内容 追加された内容
en:More C++ Idioms/Iterator Pair (20:00, 4 May 2008 UTC) に同期 |
|||
83 行
char buf[] = { 'A', 'B', 0, 'C', 0, 'D'};
std::string str1 (buf); // "AB" だけが作成される。
std::string str2 (buf, buf + sizeof (buf)); // 反復子対を利用する。"
// buf は範囲の先頭で、buf + sizeof(buf) が範囲の終端
std::cout << str1 << " length = " << str1.length() << std::endl; // AB length = 2
std::cout << str2 << " length = " << str2.length() << std::endl; //
</source>
|