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:
Marvin Greenberg 2014-01-30 16:37:07 -05:00
commit 843aa7cd65
5 changed files with 10 additions and 10 deletions

View file

@ -61,7 +61,7 @@ namespace std {
%rename(add) push_back;
void push_back(const value_type& x);
%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());
if (i>=0 && i<size)
return (*self)[i];