标签:stream inf stdin ifstream oid 对象 code 等价 cout
读字符时, std::istream_iterator 默认跳过空白符(除非用 std::noskipws 或等价物禁用,而 std::istreambuf_iterator 不跳过。另外, std::istreambuf_iterator 更有效率,因为它避免对每个字符构造并析构一次 sentry 对象的开销。
void test_istreambuf_iterator()
{
std::cout << " test istreambuf_iterator : " << std::endl;
std::ifstream inFile{"./test.cpp" };
std::istreambuf_iterator
std::ostreambuf_iterator
while (start != end)
{
*toStdin++ = *start++;
}
std::cout << std::endl;
}
void test_istream_iterator()
{
std::cout << " test istream_iterator : " << std::endl;
std::ifstream inFile("./test.cpp");
std::istream_iterator
std::ostream_iterator
while (start != end)
{
*toStdin++ = *start++;
}
std::cout << std::endl;
}
istream_iterator && istream_iteratorbuf
标签:stream inf stdin ifstream oid 对象 code 等价 cout
原文地址:https://www.cnblogs.com/s3320/p/12709531.html