Improve backwards compatibility in C# std::vector wrappers
For users who have typemaps for the parameters in the setitem method. Correct definitions of const_reference to match the those in the (C++11) standard.
This commit is contained in:
parent
05c8c972cc
commit
c79cf79085
1 changed files with 6 additions and 6 deletions
|
|
@ -233,15 +233,15 @@
|
||||||
else
|
else
|
||||||
throw std::out_of_range("index");
|
throw std::out_of_range("index");
|
||||||
}
|
}
|
||||||
CONST_REFERENCE getitem(int index) throw (std::out_of_range) {
|
const_reference getitem(int index) throw (std::out_of_range) {
|
||||||
if (index>=0 && index<(int)$self->size())
|
if (index>=0 && index<(int)$self->size())
|
||||||
return (*$self)[index];
|
return (*$self)[index];
|
||||||
else
|
else
|
||||||
throw std::out_of_range("index");
|
throw std::out_of_range("index");
|
||||||
}
|
}
|
||||||
void setitem(int index, CTYPE const& value) throw (std::out_of_range) {
|
void setitem(int index, CTYPE const& val) throw (std::out_of_range) {
|
||||||
if (index>=0 && index<(int)$self->size())
|
if (index>=0 && index<(int)$self->size())
|
||||||
(*$self)[index] = value;
|
(*$self)[index] = val;
|
||||||
else
|
else
|
||||||
throw std::out_of_range("index");
|
throw std::out_of_range("index");
|
||||||
}
|
}
|
||||||
|
|
@ -351,7 +351,7 @@
|
||||||
%define SWIG_STD_VECTOR_ENHANCED(CTYPE...)
|
%define SWIG_STD_VECTOR_ENHANCED(CTYPE...)
|
||||||
namespace std {
|
namespace std {
|
||||||
template<> class vector< CTYPE > {
|
template<> class vector< CTYPE > {
|
||||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, %arg(CTYPE const&), %arg(CTYPE))
|
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, %arg(CTYPE))
|
||||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE)
|
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -384,11 +384,11 @@ namespace std {
|
||||||
// primary (unspecialized) class template for std::vector
|
// primary (unspecialized) class template for std::vector
|
||||||
// does not require operator== to be defined
|
// does not require operator== to be defined
|
||||||
template<class T> class vector {
|
template<class T> class vector {
|
||||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, T const&, T)
|
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IEnumerable, const value_type&, T)
|
||||||
};
|
};
|
||||||
// specialization for pointers
|
// specialization for pointers
|
||||||
template<class T> class vector<T *> {
|
template<class T> class vector<T *> {
|
||||||
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, T *const&, T *)
|
SWIG_STD_VECTOR_MINIMUM_INTERNAL(IList, const value_type&, T *)
|
||||||
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T *)
|
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T *)
|
||||||
};
|
};
|
||||||
// bool is specialized in the C++ standard - const_reference in particular
|
// bool is specialized in the C++ standard - const_reference in particular
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue