Opened 9 years ago

Closed 9 years ago

#13134 closed defect (fixed)

wxSortedArrayString not sorted when using standard C++ containers

Reported by: disc Owned by:
Priority: normal Milestone:
Component: wxMSW Version: stable-latest
Keywords: Cc:
Blocked By: Blocking:
Patch: no

Description

[MSVC9, trunk@67411]

Attached is a diff to the minimal sample demonstrating wxSortedArrayString not being automatically sorted when wxUSE_STD_CONTAINERS==1. This (probably) occurs with a default wx setup since r67343. I get the following assert:

"
[...]
File: C:\Program Files\VS9\VC\include\algorithm
Line: 2290

Expression: sequence not ordered
[...]
"

A workaround is to set wxUSE_STD_CONTAINERS to 0.

Attachments (1)

non-sorted-array.diff download (678 bytes) - added by disc 9 years ago.
Diff to the minimal sample demonstrating wxSortedArrayString not being sorted

Download all attachments as: .zip

Change History (3)

Changed 9 years ago by disc

Diff to the minimal sample demonstrating wxSortedArrayString not being sorted

comment:1 Changed 9 years ago by vadz

  • Status changed from new to confirmed

Indeed, wxSortedArrayString::push_back() doesn't work, onlyAdd() does. So I guess we need to override push_back() in _WX_DEFINE_SORTED_TYPEARRAY_2 macro. This will probably provoke warnings from some compilers but I don't see how can the problem be fixed in any other way...

comment:2 Changed 9 years ago by VZ

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

(In [67429]) Re-define push_back() in wxSortedArrayString to behave correctly.

Adding items to wxSortedArrayString should always keep them sorted but while
Add() did this, push_back() didn't breaking the class invariant.

Redefine push_back() in _WX_DEFINE_SORTED_TYPEARRAY_2 macro to fix this and
add a unit test checking that wxSortedArrayString::push_back() does work now.

Closes #13134.

Note: See TracTickets for help on using tickets.