3108. istreambuf_iterator::proxy::operator* should be const

Section: 24.6.4.2 [istreambuf.iterator.proxy] Status: New Submitter: Billy O'Neal III Opened: 2018-04-26 Last modified: 2020-09-06

Priority: 3

View all issues with New status.

Discussion:

operator* on iterators is usually intended to be const; see 24.3.5.3 [input.iterators] Table 87, *a, where a is of type X or const X. (Technically, proxy is implementing the *r++ requirement in this table, and r doesn't imply a const iterator, but there's no reason for the iterator's operator* to differ from the proxy)

[2018-06-18 after reflector discussion]

Priority set to 3

Proposed resolution:

This wording is relative to N4741.

  1. Edit 24.6.4.2 [istreambuf.iterator.proxy] as indicated:

    namespace std {
      template<class charT, class traits = char_traits<charT>>
      class istreambuf_iterator<charT, traits>::proxy { // exposition only
        charT keep_;
        basic_streambuf<charT,traits>* sbuf_;
        proxy(charT c, basic_streambuf<charT,traits>* sbuf)
          : keep_(c), sbuf_(sbuf) { }
        public:
          charT operator*() const { return keep_; }
      };
    }