Bug 27404 - Rope iterators are not InputIterators
Summary: Rope iterators are not InputIterators
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 4.1.0
: P3 minor
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-05-02 21:43 UTC by Doug Gregor
Modified: 2006-05-04 09:40 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-05-03 00:08:30


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Doug Gregor 2006-05-02 21:43:22 UTC
Rope iterators (both const and mutable) do not meet the requirements of an Input Iterator, because their dereference operator only operates on non-const objects. Table 72 of the C++98 Standard requires the valid expression *a, where a is a const iterator, but this valid expression does not work with a non-const operator*.

To fix, make operator* and everything it relies on "const". This might have an unfortunate ripple effect; an alternative (but ugly) approach would be to add a new operator* to _Rope_iterator and _Rope_const_iterator that const_cast's and forwards:

  reference
  operator*() const
  {
    return *const_cast<_Rope_iterator&>(*this);
  }

  reference
  operator*() const
  {
    return *const_cast<_Rope_const_iterator&>(*this);
  }

This problem is very unlikely to cause problems in user code, but it makes ConceptGCC sad.
Comment 1 Paolo Carlini 2006-05-03 00:08:30 UTC
Hi Doug. I'm afraid that, everything considered - in particular the status of the rope extension - we have to go with the ugly approach: things like _Rope_iterator::_M_check() actively do change the object...
Comment 2 paolo@gcc.gnu.org 2006-05-04 09:38:47 UTC
Subject: Bug 27404

Author: paolo
Date: Thu May  4 09:37:56 2006
New Revision: 113519

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113519
Log:
2006-05-04  Douglas Gregor  <dgregor@cs.indiana.edu>

	PR libstdc++/27404
	* include/ext/rope (_Rope_const_iterator<>::operator*() const,
	_Rope_iterator<>::operator*() const): Add.

Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/ext/rope

Comment 3 Paolo Carlini 2006-05-04 09:40:07 UTC
Fixed.