Opened 3 years ago

Closed 3 years ago

#15192 closed enhancement (fixed)


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


For compatibility with std::vector

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

[using VS2008]

wxVector<int> int_vector;
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();
    wxMessageBox(wxString::Format("%d", *it));

Attachments (2)

vector.h.patch download (2.8 KB) - added by troelsk 3 years ago.
vector.h.2.patch download (3.1 KB) - added by troelsk 3 years ago.
New try

Download all attachments as: .zip

Change History (7)

Changed 3 years ago by troelsk


comment:1 Changed 3 years ago by vadz

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

Changed 3 years ago by troelsk

New try

comment:2 Changed 3 years 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 3 years 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 3 years 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 3 years 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.