This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


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

c++/4436: const_reverse_iterator rend()const;



>Number:         4436
>Category:       c++
>Synopsis:       const_reverse_iterator rend()const;
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 01 11:16:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Tyler Holcomb
>Release:        2.96 20000731
>Organization:
>Environment:
Red Hat Linux 7.1 2.96-81
>Description:
const_reverse_iterator rend()const;

is not defined for <vector> and <deque>, although

reverse_iterator rend(); is
>How-To-Repeat:
g++ the attached  16 line source file
>Fix:
I an new, and haven't found which directory has the source 
AAARRGH.  The naive answer is:

Cut & Paste the code for reverse_iterator rend();  adding const, so now the
presumably one line routine  is

const_reverse_iterator() rend()const{return ??;}

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="bug_report.txt"
Content-Disposition: inline; filename="bug_report.txt"

Greetings,

I am using g++  with version:
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-81)

It appears that the function

const_reverse_interator rend() const;

has been left out of the <vector> and <deque> standard tempate libraries.
I searched the gcc bug lists but could not find the bug listed/fixed, although
these three issues from the Revision 19 list seem related (and open)

200 forward iterators don't allow constant iterators
279 const and non-const iterators should have equivalent typedefs
280 comparison of reverse_iterator to const reverse_iterator

 Here is an example of my bug:


//************BEGIN SOURCE************
#include <fstream>
#include <vector>

int main()
{
  vector<int> d;
  for ( int i = 0; i < 5; i++)
    d.push_back(i);

  vector<int>::const_reverse_iterator di;
  for (di = d.rbegin(); 
	di != d.rend() ;
	di++)
    cout <<"\t"<<(*di);
  cout << endl;
};
//************END SOURCE************

produces the following compile error:

g++ test.cpp
test.cpp: In function `int main ()':
test.cpp:12: no match for `reverse_iterator<const int *> & != 
reverse_iterator<int *>'

However, switching from  const_reverse_iterator to reverse_iterator
yields a program that compiles and prints the integers 0 to 4 inclusive
 in reverse order, as intended.

I hope this is useful.  

In any event, thank you for your time.







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