C++11 support for new versions of erase and insert in the STL containers.
The erase and insert methods in the containers use const_iterator instead of iterator in C++11. There are times when the methods wrapped must match the parameters exactly. Specifically when full type information for template types is missing or SWIG fails to look up the type correctly, for example: %include <std_vector.i> typedef float Real; %template(RealVector) std::vector<Real>; SWIG does not find std::vector<Real>::iterator because %template using typedefs does not always work and so SWIG doesn't know if the type is copyable and so uses SwigValueWrapper<iterator> which does not support conversion to another type (const_iterator). This resulted in compilation errors when using the C++11 version of the containers. Closes #73
This commit is contained in:
parent
cf92954bc0
commit
92128eef44
6 changed files with 56 additions and 16 deletions
|
|
@ -5,6 +5,27 @@ See the RELEASENOTES file for a summary of changes in each release.
|
|||
Version 3.0.0 (in progress)
|
||||
============================
|
||||
|
||||
2013-12-22: wsfulton
|
||||
C++11 support for new versions of erase and insert in the STL containers.
|
||||
|
||||
The erase and insert methods in the containers use const_iterator instead
|
||||
of iterator in C++11. There are times when the methods wrapped must match
|
||||
the parameters exactly. Specifically when full type information for
|
||||
template types is missing or SWIG fails to look up the type correctly,
|
||||
for example:
|
||||
|
||||
%include <std_vector.i>
|
||||
typedef float Real;
|
||||
%template(RealVector) std::vector<Real>;
|
||||
|
||||
SWIG does not find std::vector<Real>::iterator because %template using
|
||||
typedefs does not always work and so SWIG doesn't know if the type is
|
||||
copyable and so uses SwigValueWrapper<iterator> which does
|
||||
not support conversion to another type (const_iterator). This resulted
|
||||
in compilation errors when using the C++11 version of the containers.
|
||||
|
||||
Closes #73
|
||||
|
||||
2013-12-18: ianlancetaylor
|
||||
[Go] Don't require that Go environment variables be set
|
||||
when running examples or testsuite when using Go 1 or
|
||||
|
|
|
|||
|
|
@ -46,8 +46,11 @@
|
|||
void resize(size_type new_size);
|
||||
|
||||
#ifdef SWIG_EXPORT_ITERATOR_METHODS
|
||||
iterator erase(iterator pos);
|
||||
iterator erase(iterator first, iterator last);
|
||||
%extend {
|
||||
// %extend wrapper used for differing definitions of these methods introduced in C++11
|
||||
iterator erase(iterator pos) { return $self->erase(pos); }
|
||||
iterator erase(iterator first, iterator last) { return $self->erase(first, last); }
|
||||
}
|
||||
#endif
|
||||
|
||||
%enddef
|
||||
|
|
@ -68,8 +71,11 @@
|
|||
void resize(size_type new_size, const value_type& x);
|
||||
|
||||
#ifdef SWIG_EXPORT_ITERATOR_METHODS
|
||||
iterator insert(iterator pos, const value_type& x);
|
||||
void insert(iterator pos, size_type n, const value_type& x);
|
||||
%extend {
|
||||
// %extend wrapper used for differing definitions of these methods introduced in C++11
|
||||
iterator insert(iterator pos, const value_type& x) { return $self->insert(pos, x); }
|
||||
void insert(iterator pos, size_type n, const value_type& x) { $self->insert(pos, n, x); }
|
||||
}
|
||||
#endif
|
||||
|
||||
%enddef
|
||||
|
|
@ -89,8 +95,11 @@
|
|||
void resize(size_type new_size, value_type x);
|
||||
|
||||
#ifdef SWIG_EXPORT_ITERATOR_METHODS
|
||||
iterator insert(iterator pos, value_type x);
|
||||
void insert(iterator pos, size_type n, value_type x);
|
||||
%extend {
|
||||
// %extend wrapper used for differing definitions of these methods introduced in C++11
|
||||
iterator insert(iterator pos, value_type x) { return $self->insert(pos, x); }
|
||||
void insert(iterator pos, size_type n, value_type x) { $self->insert(pos, n, x); }
|
||||
}
|
||||
#endif
|
||||
|
||||
%enddef
|
||||
|
|
|
|||
|
|
@ -12,9 +12,11 @@
|
|||
size_type count(const key_type& x) const;
|
||||
|
||||
#ifdef SWIG_EXPORT_ITERATOR_METHODS
|
||||
// iterator insert(iterator position, const value_type& x);
|
||||
void erase(iterator position);
|
||||
void erase(iterator first, iterator last);
|
||||
%extend {
|
||||
// %extend wrapper used for differing definitions of these methods introduced in C++11
|
||||
void erase(iterator position) { $self->erase(position); }
|
||||
void erase(iterator first, iterator last) { $self->erase(first, last); }
|
||||
}
|
||||
|
||||
iterator find(const key_type& x);
|
||||
iterator lower_bound(const key_type& x);
|
||||
|
|
|
|||
|
|
@ -29,8 +29,11 @@
|
|||
reverse_iterator rbegin();
|
||||
reverse_iterator rend();
|
||||
|
||||
void erase(iterator pos);
|
||||
void erase(iterator first, iterator last);
|
||||
%extend {
|
||||
// %extend wrapper used for differing definitions of these methods introduced in C++11
|
||||
void erase(iterator pos) { $self->erase(pos); }
|
||||
void erase(iterator first, iterator last) { $self->erase(first, last); }
|
||||
}
|
||||
|
||||
iterator find(const key_type& x);
|
||||
iterator lower_bound(const key_type& x);
|
||||
|
|
|
|||
|
|
@ -15,9 +15,11 @@
|
|||
size_type count(const key_type& x) const;
|
||||
|
||||
#ifdef SWIG_EXPORT_ITERATOR_METHODS
|
||||
// iterator insert(iterator position, const value_type& x);
|
||||
void erase(iterator position);
|
||||
void erase(iterator first, iterator last);
|
||||
%extend {
|
||||
// %extend wrapper used for differing definitions of these methods introduced in C++11
|
||||
void erase(iterator position) { $self->erase(position); }
|
||||
void erase(iterator first, iterator last) { $self->erase(first, last); }
|
||||
}
|
||||
|
||||
iterator find(const key_type& x);
|
||||
iterator lower_bound(const key_type& x);
|
||||
|
|
|
|||
|
|
@ -29,8 +29,11 @@
|
|||
iterator begin();
|
||||
iterator end();
|
||||
|
||||
void erase(iterator pos);
|
||||
void erase(iterator first, iterator last);
|
||||
%extend {
|
||||
// %extend wrapper used for differing definitions of these methods introduced in C++11
|
||||
void erase(iterator pos) { $self->erase(pos); }
|
||||
void erase(iterator first, iterator last) { $self->erase(first, last); }
|
||||
}
|
||||
|
||||
iterator find(const key_type& x);
|
||||
std::pair<iterator,iterator> equal_range(const key_type& x);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue