Make wxVector reverse iterators conform to iterator requirements
This is similar to a recent commit adding the missing typedefs to wxList iterators and defines the types required by the iterator concept in wxVector::reverse_iterator and const_reverse_iterator classes (simple iterators are just pointers and are already covered by the standard iterator_traits specialization).
This commit is contained in:
parent
382a5a156e
commit
cc8fccf0bc
@ -69,7 +69,7 @@ Changes in behaviour which may result in build errors
|
||||
|
||||
All:
|
||||
|
||||
- Make wxList iterators conform to input iterator requirements.
|
||||
- Make wxList and wxVector iterators conform to input iterator requirements.
|
||||
|
||||
|
||||
3.1.1: (released 2018-02-19)
|
||||
|
@ -33,6 +33,9 @@ inline void wxVectorSort(wxVector<T>& v)
|
||||
#include "wx/meta/if.h"
|
||||
|
||||
#include "wx/beforestd.h"
|
||||
#if wxUSE_STD_CONTAINERS_COMPATIBLY
|
||||
#include <iterator>
|
||||
#endif
|
||||
#include <new> // for placement new
|
||||
#include "wx/afterstd.h"
|
||||
|
||||
@ -172,6 +175,14 @@ public:
|
||||
class reverse_iterator
|
||||
{
|
||||
public:
|
||||
#if wxUSE_STD_CONTAINERS_COMPATIBLY
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
#endif
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef value_type* pointer;
|
||||
typedef value_type& reference;
|
||||
|
||||
reverse_iterator() : m_ptr(NULL) { }
|
||||
explicit reverse_iterator(iterator it) : m_ptr(it) { }
|
||||
reverse_iterator(const reverse_iterator& it) : m_ptr(it.m_ptr) { }
|
||||
@ -218,6 +229,14 @@ public:
|
||||
class const_reverse_iterator
|
||||
{
|
||||
public:
|
||||
#if wxUSE_STD_CONTAINERS_COMPATIBLY
|
||||
typedef std::random_access_iterator_tag iterator_category;
|
||||
#endif
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T value_type;
|
||||
typedef const value_type* pointer;
|
||||
typedef const value_type& reference;
|
||||
|
||||
const_reverse_iterator() : m_ptr(NULL) { }
|
||||
explicit const_reverse_iterator(const_iterator it) : m_ptr(it) { }
|
||||
const_reverse_iterator(const reverse_iterator& it) : m_ptr(it.m_ptr) { }
|
||||
|
@ -22,6 +22,10 @@
|
||||
|
||||
#include "wx/vector.h"
|
||||
|
||||
#if wxUSE_STD_CONTAINERS_COMPATIBLY
|
||||
#include <vector>
|
||||
#endif // wxUSE_STD_CONTAINERS_COMPATIBLY
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// simple class capable of detecting leaks of its objects
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -360,6 +364,13 @@ TEST_CASE("wxVector::reverse_iterator", "[vector][reverse_iterator]")
|
||||
ri = rb + 2;
|
||||
CHECK( ri - rb == 2 );
|
||||
CHECK( re - ri == 8 );
|
||||
|
||||
#if wxUSE_STD_CONTAINERS_COMPATIBLY
|
||||
std::vector<int> stdvec(rb, re);
|
||||
REQUIRE( stdvec.size() == 10 );
|
||||
CHECK( stdvec[0] == 10 );
|
||||
CHECK( stdvec[9] == 1 );
|
||||
#endif // wxUSE_STD_CONTAINERS_COMPATIBLY
|
||||
}
|
||||
|
||||
TEST_CASE("wxVector::capacity", "[vector][capacity][shrink_to_fit]")
|
||||
|
Loading…
Reference in New Issue
Block a user