#15192 closed enhancement (fixed)

wxVector::const_reverse_iterator

Reported by: troelsk Owned by: vadz
Priority: normal Milestone:
Component: base Version: stable-latest
Keywords: wxVector Cc:
Blocked By: Blocking:
Patch: yes

Description

For compatibility with std::vector

Patch:
I tried to implement it but did not succeed, am getting this error

[using VS2008]

wxVector<int> int_vector;
int_vector.push_back(1);
int_vector.push_back(2);
int_vector.push_back(3);
for (wxVector<int>::const_reverse_iterator it = int_vector.rbegin(); // error C2440: 'initializing' : cannot convert from 'wxVector<T>::reverse_iterator' to 'wxVector<T>::const_reverse_iterator'
     it != int_vector.rend();
     it++)
{
    wxMessageBox(wxString::Format("%d", *it));
}

Attachments (2)

vector.h.patch download (2.8 KB) - added by troelsk 17 months ago.
const_reverse_iterator
vector.h.2.patch download (3.1 KB) - added by troelsk 17 months ago.
New try

Download all attachments as: .zip

Change History (7)

Changed 17 months ago by troelsk

const_reverse_iterator

comment:1 Changed 17 months ago by vadz

To fix that problem you need to provide a (non-explicit) ctor of const_reverse_iterator from reverse_iterator.

Changed 17 months ago by troelsk

New try

comment:2 Changed 17 months ago by troelsk

Right. Now it is compiling, and running fine. Am not happy with the result though, the protected/friend class hack

comment:3 Changed 17 months ago by vadz

  • Owner set to vadz
  • Status changed from new to accepted

Why did you need to replace private with protected? Just using the friend declaration should have been enough and seems to work fine for me...

comment:4 Changed 17 months ago by troelsk

Indeed, it can stay private. Disclaimer: Tested with only one compiler (VS2008).
And I am less than comfortable with this template code...

comment:5 Changed 17 months ago by VZ

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [73947]) Add wxVector<>::const_reverse_iterator.

Provide this type too for compatibility with std::vector<>.

Closes #15192.

Note: See TracTickets for help on using tickets.