Title
istreambuf_iterator(basic_streambuf<charT, traits>* s) effects unclear when s is 0
Status
c++17
Section
[istreambuf.iterator.cons]
Submitter
S. B. Tam

Created on 2015-10-05.00:00:00 last changed 89 months ago

Messages

Date: 2016-08-07.15:39:41

Proposed resolution:

This wording is relative to N4606.

  1. Change [istreambuf.iterator.cons] as indicated:

    [Drafting note: The proposed wording changes also performs some editorial clean-up of the existing mismatches of the declarations in the class template synopsis and the individual member specifications. The below wording is simplified by requiring sbuf_ to be a null pointer for an end-of-stream iterator value, since I have not yet seen any implementation where this requirement does not hold. Even if there were such an implementation, this would still be conforming, because concrete exposition-only member values are not part of public API. — end drafting note]

    For each istreambuf_iterator constructor in this section, an end-of-stream iterator is constructed if and only if the exposition-only member sbuf_ is initialized with a null pointer value.

    constexpr istreambuf_iterator() noexcept;
    

    -1- Effects: Initializes sbuf_ with nullptrConstructs the end-of-stream iterator.

    istreambuf_iterator(basic_istream<charT,traits>istream_type& s) noexcept;
    istreambuf_iterator(basic_streambuf<charT,traits>* s) noexcept;
    

    -2- Effects: Initializes sbuf_ with s.rdbuf()Constructs an istreambuf_iterator<> that uses the basic_streambuf<> object *(s.rdbuf()), or *s, respectively. Constructs an end-of-stream iterator if s.rdbuf() is null.

    istreambuf_iterator(streambuf_type* s) noexcept;
    

    -?- Effects: Initializes sbuf_ with s.

    istreambuf_iterator(const proxy& p) noexcept;
    

    -3- Effects: Initializes sbuf_ with p.sbuf_Constructs a istreambuf_iterator<> that uses the basic_streambuf<> object pointed to by the proxy object's constructor argument p.

Date: 2016-08-03.00:00:00

[ 2016-08-03 Chicago ]

Fri AM: Moved to Tentatively Ready

Date: 2015-10-15.00:00:00

[ 2015-10-20, Daniel provides alternative wording ]

Date: 2015-10-19.22:27:14

N4527 [istreambuf.iterator.cons] does not mention what the effect of calling istreambuf_iterator(basic_streambuf<charT, traits>* s) is when s is a null pointer. It should be made clear that this case is well-formed and the result is a end-of-stream iterator.

Daniel:

According to [istreambuf.iterator] p1:

[…] The default constructor istreambuf_iterator() and the constructor istreambuf_iterator(0) both construct an end-of-stream iterator object suitable for use as an end-of-range. […]

This indicates that the described constructor creates an end-of-stream iterator, but this wording is part of the introductory wording and I recommend to make [istreambuf.iterator.cons] clearer, because the existing specification is already flawed, e.g. it never specifies when and how the exposition-only-member sbuf_ is initialized. The proposed wording below attempts to solve these problems as well.

Previous resolution [SUPERSEDED]:

This wording is relative to N4527.

  1. Change [istreambuf.iterator.cons] as indicated:

    [Editorial note: The proposed wording changes also performs some editorial clean-up of the existing mismatches of the declarations in the class template synopsis and the individual member specifications. The below wording intentionally does not say anything about the concrete value of sbuf_ for end-of-stream iterator values, because that was never specified before; in theory, this could be some magic non-null pointer that can be used in constant expressions. But the wording could be drastically simplified by requiring sbuf_ to be a null pointer for an end-of-stream iterator value, since I have not yet seen any implementation where this requirement does not hold. — end editorial note]

    constexpr istreambuf_iterator() noexcept;
    

    -1- Effects: Constructs the end-of-stream iterator.

    istreambuf_iterator(basic_istream<charT,traits>istream_type& s) noexcept;
    istreambuf_iterator(basic_streambuf<charT,traits>* s) noexcept;
    

    -2- Effects: If s.rdbuf() is a null pointer, constructs an end-of-stream iterator; otherwise initializes sbuf_ with s.rdbuf() and constructs an istreambuf_iterator that uses the streambuf_type object *sbuf_Constructs an istreambuf_iterator<> that uses the basic_streambuf<> object *(s.rdbuf()), or *s, respectively. Constructs an end-of-stream iterator if s.rdbuf() is null.

    istreambuf_iterator(streambuf_type* s) noexcept;
    

    -?- Effects: If s is a null pointer, constructs an end-of-stream iterator; otherwise initializes sbuf_ with s and constructs an istreambuf_iterator that uses the streambuf_type object *sbuf_.

    istreambuf_iterator(const proxy& p) noexcept;
    

    -3- Effects: Initializes sbuf_ with p.sbuf_ and constructs an istreambuf_iterator that uses the streambuf_type object *sbuf_Constructs a istreambuf_iterator<> that uses the basic_streambuf<> object pointed to by the proxy object's constructor argument p.

History
Date User Action Args
2017-07-30 20:15:43adminsetstatus: wp -> c++17
2016-11-14 03:59:28adminsetstatus: pending -> wp
2016-11-14 03:55:22adminsetstatus: ready -> pending
2016-08-06 20:44:18adminsetmessages: + msg8436
2016-08-06 20:44:18adminsetstatus: new -> ready
2015-10-20 16:22:53adminsetmessages: + msg7574
2015-10-11 13:27:56adminsetmessages: + msg7562
2015-10-05 00:00:00admincreate