This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: another effc++ spurious warning?


Gabriel Dos Reis wrote:

>> I don't see anything in the standard which says that, for Input/Output
>> iterators, operator++(int) should return a reference (possibly to this).

> Good!  Then, why do you insist that you should warn about what they
> return, and expecially that [io]stream_iterator<> are
> special cases then?

Please, show me how to implement a well-formed operator++(int) which returns a
reference, for *any* kind of iterator. I will also notice that
Boost.IteratorAdaptor also generates operator++(int) which returns by value.

Maybe you can have some luck with input/output iterators and show me that we
can play tricks and return a reference, but there is nothing wrong them
returning by value either. I can write a well-formed Input/Output iterator
which uses operator++(int) returning by value, AFAICT. The only place where we
are forced to return by reference are where the standard says so,
istreambuf_iterator and insert_iterator.

> You said that only specially advanced programming do something
> silly vs. -Weffc++; I'm saying you "No, because by the very
> nature of Input/Output iterator", you can't go and
> warn against them.  If you do, then you're hurting any modern
> C++ use.  And modern C++ use need not be advanced.

If you can show me that Input/Output iterators (besides the standard ones) are
*forced* to define an operator++(int) which returns by reference, I will drop
this.

>> Maybe it makes sense to special case them in the warning.
> That would be a real mistake and disaster.

It's not that bad, really.

Giovanni Bajo



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]