Please check out this code snippet
std::istringstream s("abc");
std::istreambuf_iterator<char> i1(s), i2(s);
std::cout<< "i1 returns "<<*i1<<'\n'
<< "i2 returns "<<*i2<<'\n';
++i1;
std::cout<<"after incrementing i1, but not i2\n"
<<"i1 returns "<<*i1<<'\n'
<<"i2 returns "<<*i2<<'\n';
++i2; // this makes the apparent value of *i2 to jump from 'a' to 'c'
std::cout << "after incrementing i2, but not i1\n"
<< "i1 returns " << *i1 << '\n'
<< "i2 returns " << *i2 << '\n';
and i got the output like
a
a
b
b
c
c
which is totally different from what I expected, because i1 & i2 are two different iterators.
Anyone do me a favor?