Work around differences in clang libc++ std::vector<bool>::const_reference
clang++ using -stdlib=libc++ defines const_reference as a class, to map boolean vectors onto a bit set. Because swig does not "see" the type as "const &" it generates incorrect code for this case, generating a declaration like: const_reference result; When const_reference is a typedef to 'bool' as is the case with stdlibc++ this works. When this is actually a constant reference, this is clearly invalid since it is not initialized. For libc++, this is a class which cannot be default constructed, resulting in an error. The fix is to explicitly define the various accessor extensions as having a bool return type for this specialization.
This commit is contained in:
parent
213774e0b6
commit
843aa7cd65
5 changed files with 10 additions and 10 deletions
|
|
@ -217,7 +217,7 @@
|
||||||
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
|
||||||
|
|
|
||||||
|
|
@ -128,7 +128,7 @@ public void capacity(size_t value) {
|
||||||
return $self->capacity() - $self->size();
|
return $self->capacity() - $self->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
const_reference remove() throw (std::out_of_range) {
|
CONST_REFERENCE remove() throw (std::out_of_range) {
|
||||||
if ($self->empty()) {
|
if ($self->empty()) {
|
||||||
throw std::out_of_range("Tried to remove last element from empty vector.");
|
throw std::out_of_range("Tried to remove last element from empty vector.");
|
||||||
}
|
}
|
||||||
|
|
@ -138,7 +138,7 @@ public void capacity(size_t value) {
|
||||||
return 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()) {
|
if (index >= $self->size()) {
|
||||||
throw std::out_of_range("Tried to remove element with invalid index.");
|
throw std::out_of_range("Tried to remove element with invalid index.");
|
||||||
}
|
}
|
||||||
|
|
@ -153,7 +153,7 @@ public void capacity(size_t value) {
|
||||||
// Wrappers for setting/getting items with the possibly thrown exception
|
// Wrappers for setting/getting items with the possibly thrown exception
|
||||||
// specified (important for SWIG wrapper generation).
|
// specified (important for SWIG wrapper generation).
|
||||||
%extend {
|
%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)) {
|
if ((index < 0) || ($self->size() <= index)) {
|
||||||
throw std::out_of_range("Tried to get value of element with invalid index.");
|
throw std::out_of_range("Tried to get value of element with invalid index.");
|
||||||
}
|
}
|
||||||
|
|
@ -464,7 +464,7 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg)
|
||||||
return pv;
|
return pv;
|
||||||
}
|
}
|
||||||
|
|
||||||
const_reference remove() throw (std::out_of_range) {
|
CONST_REFERENCE remove() throw (std::out_of_range) {
|
||||||
if ($self->empty()) {
|
if ($self->empty()) {
|
||||||
throw std::out_of_range("Tried to remove last element from empty vector.");
|
throw std::out_of_range("Tried to remove last element from empty vector.");
|
||||||
}
|
}
|
||||||
|
|
@ -474,7 +474,7 @@ int opApply(int delegate(ref size_t index, ref $typemap(dtype, CTYPE) value) dg)
|
||||||
return 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()) {
|
if (index >= $self->size()) {
|
||||||
throw std::out_of_range("Tried to remove element with invalid index.");
|
throw std::out_of_range("Tried to remove element with invalid index.");
|
||||||
}
|
}
|
||||||
|
|
@ -506,7 +506,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
|
// Wrappers for setting/getting items with the possibly thrown exception
|
||||||
// specified (important for SWIG wrapper generation).
|
// specified (important for SWIG wrapper generation).
|
||||||
%extend {
|
%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)) {
|
if ((index < 0) || ($self->size() <= index)) {
|
||||||
throw std::out_of_range("Tried to get value of element with invalid index.");
|
throw std::out_of_range("Tried to get value of element with invalid index.");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ namespace std {
|
||||||
%rename(add) push_back;
|
%rename(add) push_back;
|
||||||
void push_back(const value_type& x);
|
void push_back(const value_type& x);
|
||||||
%extend {
|
%extend {
|
||||||
const_reference get(int i) throw (std::out_of_range) {
|
bool get(int i) throw (std::out_of_range) {
|
||||||
int size = int(self->size());
|
int size = int(self->size());
|
||||||
if (i>=0 && i<size)
|
if (i>=0 && i<size)
|
||||||
return (*self)[i];
|
return (*self)[i];
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ namespace std {
|
||||||
%rename(add) push_back;
|
%rename(add) push_back;
|
||||||
void push_back(const value_type& x);
|
void push_back(const value_type& x);
|
||||||
%extend {
|
%extend {
|
||||||
const_reference get(int i) throw (std::out_of_range) {
|
bool get(int i) throw (std::out_of_range) {
|
||||||
int size = int(self->size());
|
int size = int(self->size());
|
||||||
if (i>=0 && i<size)
|
if (i>=0 && i<size)
|
||||||
return (*self)[i];
|
return (*self)[i];
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ namespace std {
|
||||||
self->pop_back();
|
self->pop_back();
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
const_reference get(int i) throw (std::out_of_range) {
|
bool get(int i) throw (std::out_of_range) {
|
||||||
int size = int(self->size());
|
int size = int(self->size());
|
||||||
if (i>=0 && i<size)
|
if (i>=0 && i<size)
|
||||||
return (*self)[i];
|
return (*self)[i];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue