https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105580

Tomasz Kamiński <tkaminsk at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|redi at gcc dot gnu.org            |tkaminsk at gcc dot 
gnu.org
                 CC|                            |tkaminsk at gcc dot gnu.org

--- Comment #11 from Tomasz Kamiński <tkaminsk at gcc dot gnu.org> ---
In the [istreambuf.iterator.ops] p1 the operator* is specified to return:
> Returns: The character obtained via the streambuf member sbuf_->sgetc().
I believe this implies that multiple istream-iterator to the same input buffer,
are allowed and required required to return current character, for example:
```
    std::istringstream in("abcdefghijkl");
    std::istreambuf_iterator<char> it1(in), it2(in), end;
    while (it1 != end && it2 != end) {
        std::cout << "-- it1: '" << *it1 << "'" << std::endl;
        std::cout << "-- it2: '" << *it2 << "'" << std::endl;
        ++it1;
    }
```
Should print:
-- it1: 'a'
-- it2: 'a'
-- it1: 'b'
-- it2: 'b'
-- it1: 'c'
-- it2: 'c'
-- it1: 'd'
-- it2: 'd'
...

We currently provide this behavior, however the suggestion in LWG2366 will
change that. I believe we should consider a change that will not affect such
(currently valid) programs, at least for back-ports.

Reply via email to