Add missing typedefs to std::list + typedef corrections

Numerous missing typedefs added.
std::list<T*>::const_reference and std::list<T*>::reference
specialization typedef fixes.
This commit is contained in:
William S Fulton 2019-02-14 07:31:21 +00:00
commit 440264e479
6 changed files with 39 additions and 32 deletions

View file

@ -28,12 +28,16 @@ namespace std{
template<class T> class list template<class T> class list
{ {
public: public:
typedef size_t size_type;
typedef T &reference; typedef ptrdiff_t difference_type;
typedef const T& const_reference; typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef T &iterator; typedef T &iterator;
typedef const T& const_iterator; typedef const T& const_iterator;
list(); list();
list(unsigned int size, const T& value = T()); list(unsigned int size, const T& value = T());
list(const list<T> &other); list(const list<T> &other);
@ -46,21 +50,20 @@ namespace std{
const_reference back(); const_reference back();
const_iterator begin(); const_iterator begin();
const_iterator end(); const_iterator end();
void resize(unsigned int n, T c = T()); void resize(unsigned int n, T c = T());
bool empty() const; bool empty() const;
void push_front(const T& INPUT); void push_front(const T& INPUT);
void push_back(const T& INPUT); void push_back(const T& INPUT);
void pop_front(); void pop_front();
void pop_back(); void pop_back();
void clear(); void clear();
unsigned int size() const; unsigned int size() const;
unsigned int max_size() const; unsigned int max_size() const;
void resize(unsigned int n, const T& INPUT); void resize(unsigned int n, const T& INPUT);
void remove(const T& INPUT); void remove(const T& INPUT);
void unique(); void unique();
void reverse(); void reverse();
@ -153,7 +156,7 @@ namespace std{
if (j<0) j += size; if (j<0) j += size;
if (i<0) i = 0; if (i<0) i = 0;
if (j>size) j = size; if (j>size) j = size;
for (int k=0;k<i;k++) for (int k=0;k<i;k++)
{ {
first++; first++;
@ -174,7 +177,7 @@ namespace std{
if (j<0) j += size; if (j<0) j += size;
if (i<0) i = 0; if (i<0) i = 0;
if (j>size) j = size; if (j>size) j = size;
for (int k=0;k<i;k++) for (int k=0;k<i;k++)
{ {
first++; first++;
@ -200,7 +203,6 @@ namespace std{
} }
else self->insert(self->end(),v.begin(),v.end()); else self->insert(self->end(),v.begin(),v.end());
} }
} }
unsigned int __len__() unsigned int __len__()
{ {
@ -218,8 +220,7 @@ namespace std{
{ {
self->pop_back(); self->pop_back();
} }
}
};
}; };
} }

View file

@ -1,5 +1,5 @@
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* std_vector.i * std_list.i
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
%{ %{
@ -9,7 +9,7 @@
namespace std { namespace std {
template<class T, class Alloc = allocator<T> > template<class T>
class list { class list {
public: public:
typedef size_t size_type; typedef size_t size_type;
@ -19,7 +19,6 @@ namespace std {
typedef const value_type* const_pointer; typedef const value_type* const_pointer;
typedef value_type& reference; typedef value_type& reference;
typedef const value_type& const_reference; typedef const value_type& const_reference;
typedef Alloc allocator_type;
list(); list();
size_type size() const; size_type size() const;

View file

@ -130,8 +130,12 @@ namespace std {
public: public:
typedef size_t size_type; typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type; typedef T value_type;
typedef T &reference; typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
/* /*
* We'd actually be better off having the nested class *not* be static in the wrapper * We'd actually be better off having the nested class *not* be static in the wrapper

View file

@ -13,16 +13,20 @@
%} %}
namespace std{ namespace std {
template<class T> class list template<class T> class list
{ {
public: public:
typedef size_t size_type;
typedef T &reference; typedef ptrdiff_t difference_type;
typedef const T& const_reference; typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
typedef T &iterator; typedef T &iterator;
typedef const T& const_iterator; typedef const T& const_iterator;
list(); list();
list(unsigned int size, const T& value = T()); list(unsigned int size, const T& value = T());
list(const list<T>& other); list(const list<T>& other);
@ -35,28 +39,25 @@ namespace std{
const_reference back(); const_reference back();
const_iterator begin(); const_iterator begin();
const_iterator end(); const_iterator end();
void resize(unsigned int n, T c = T()); void resize(unsigned int n, T c = T());
bool empty() const; bool empty() const;
void push_front(const T& x); void push_front(const T& x);
void push_back(const T& x); void push_back(const T& x);
void pop_front(); void pop_front();
void pop_back(); void pop_back();
void clear(); void clear();
unsigned int size() const; unsigned int size() const;
unsigned int max_size() const; unsigned int max_size() const;
void resize(unsigned int n, const T& value); void resize(unsigned int n, const T& value);
void remove(const T& value); void remove(const T& value);
void unique(); void unique();
void reverse(); void reverse();
void sort(); void sort();
%extend %extend
{ {
const_reference __getitem__(int i) throw (std::out_of_range) const_reference __getitem__(int i) throw (std::out_of_range)
@ -206,9 +207,7 @@ namespace std{
{ {
self->pop_back(); self->pop_back();
} }
}
};
}; };
} }

View file

@ -189,7 +189,11 @@ namespace std {
} }
public: public:
typedef size_t size_type; typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T value_type; typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference; typedef const value_type& const_reference;
list(); list();

View file

@ -106,8 +106,8 @@ namespace std {
typedef _Tp* value_type; typedef _Tp* value_type;
typedef value_type* pointer; typedef value_type* pointer;
typedef const value_type* const_pointer; typedef const value_type* const_pointer;
typedef value_type reference; typedef value_type& reference;
typedef value_type const_reference; typedef const value_type& const_reference;
typedef _Alloc allocator_type; typedef _Alloc allocator_type;
%traits_swigtype(_Tp); %traits_swigtype(_Tp);