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:
William S Fulton 2013-12-22 19:39:21 +00:00
commit 92128eef44
6 changed files with 56 additions and 16 deletions

View file

@ -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);