summaryrefslogtreecommitdiff
path: root/Lib/d
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2019-04-19 00:22:53 +0100
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2019-04-19 00:22:53 +0100
commit592b97a8cd8b6e535011a2e611b64c1af8d2bfe0 (patch)
treebc8a8f1d0ab0b3b1d7730d3ca2214e231046bae4 /Lib/d
parentc79cf790853d6e6d65aa7379ccb2e472b704e456 (diff)
downloadswig-592b97a8cd8b6e535011a2e611b64c1af8d2bfe0.tar.gz
Improve backwards compatibility in D std::vector wrappers
For users who have typemaps for the parameters in the setElement method. Correct definitions of const_reference to match the those in the (C++11) standard.
Diffstat (limited to 'Lib/d')
-rw-r--r--Lib/d/std_vector.i26
1 files changed, 13 insertions, 13 deletions
diff --git a/Lib/d/std_vector.i b/Lib/d/std_vector.i
index 9dcb184c6..fb8f7d2e0 100644
--- a/Lib/d/std_vector.i
+++ b/Lib/d/std_vector.i
@@ -135,7 +135,7 @@ public void capacity(size_t value) {
return $self->capacity() - $self->size();
}
- CONST_REFERENCE remove() throw (std::out_of_range) {
+ const_reference remove() throw (std::out_of_range) {
if ($self->empty()) {
throw std::out_of_range("Tried to remove last element from empty vector.");
}
@@ -145,7 +145,7 @@ public void capacity(size_t value) {
return value;
}
- CONST_REFERENCE remove(size_type index) throw (std::out_of_range) {
+ const_reference remove(size_type index) throw (std::out_of_range) {
if (index >= $self->size()) {
throw std::out_of_range("Tried to remove element with invalid index.");
}
@@ -160,7 +160,7 @@ public void capacity(size_t value) {
// Wrappers for setting/getting items with the possibly thrown exception
// specified (important for SWIG wrapper generation).
%extend {
- CONST_REFERENCE getElement(size_type index) throw (std::out_of_range) {
+ const_reference getElement(size_type index) throw (std::out_of_range) {
if ((index < 0) || ($self->size() <= index)) {
throw std::out_of_range("Tried to get value of element with invalid index.");
}
@@ -172,11 +172,11 @@ public void capacity(size_t value) {
// generation issue when using const pointers as vector elements (like
// std::vector< const int* >).
%extend {
- void setElement(size_type index, CTYPE const& value) throw (std::out_of_range) {
+ void setElement(size_type index, CTYPE const& val) throw (std::out_of_range) {
if ((index < 0) || ($self->size() <= index)) {
throw std::out_of_range("Tried to set value of element with invalid index.");
}
- (*$self)[index] = value;
+ (*$self)[index] = val;
}
}
@@ -478,7 +478,7 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg)
return pv;
}
- CONST_REFERENCE remove() throw (std::out_of_range) {
+ const_reference remove() throw (std::out_of_range) {
if ($self->empty()) {
throw std::out_of_range("Tried to remove last element from empty vector.");
}
@@ -488,7 +488,7 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg)
return value;
}
- CONST_REFERENCE remove(size_type index) throw (std::out_of_range) {
+ const_reference remove(size_type index) throw (std::out_of_range) {
if (index >= $self->size()) {
throw std::out_of_range("Tried to remove element with invalid index.");
}
@@ -520,7 +520,7 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg)
// Wrappers for setting/getting items with the possibly thrown exception
// specified (important for SWIG wrapper generation).
%extend {
- CONST_REFERENCE getElement(size_type index) throw (std::out_of_range) {
+ const_reference getElement(size_type index) throw (std::out_of_range) {
if ((index < 0) || ($self->size() <= index)) {
throw std::out_of_range("Tried to get value of element with invalid index.");
}
@@ -531,11 +531,11 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg)
// generation issue when using const pointers as vector elements (like
// std::vector< const int* >).
%extend {
- void setElement(size_type index, CTYPE const& value) throw (std::out_of_range) {
+ void setElement(size_type index, CTYPE const& val) throw (std::out_of_range) {
if ((index < 0) || ($self->size() <= index)) {
throw std::out_of_range("Tried to set value of element with invalid index.");
}
- (*$self)[index] = value;
+ (*$self)[index] = val;
}
}
@@ -558,7 +558,7 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg)
%define SWIG_STD_VECTOR_ENHANCED(CTYPE...)
namespace std {
template<> class vector<CTYPE > {
- SWIG_STD_VECTOR_MINIMUM_INTERNAL(%arg(CTYPE const&), %arg(CTYPE))
+ SWIG_STD_VECTOR_MINIMUM_INTERNAL(const value_type&, %arg(CTYPE))
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(CTYPE)
};
}
@@ -573,11 +573,11 @@ namespace std {
// primary (unspecialized) class template for std::vector
// does not require operator== to be defined
template<class T> class vector {
- SWIG_STD_VECTOR_MINIMUM_INTERNAL(T const&, T)
+ SWIG_STD_VECTOR_MINIMUM_INTERNAL(const value_type&, T)
};
// specializations for pointers
template<class T> class vector<T *> {
- SWIG_STD_VECTOR_MINIMUM_INTERNAL(T *const&, T *)
+ SWIG_STD_VECTOR_MINIMUM_INTERNAL(const value_type&, T *)
SWIG_STD_VECTOR_EXTRA_OP_EQUALS_EQUALS(T *)
};
// bool is a bit different in the C++ standard - const_reference in particular