add in correct specialization for std::vector<bool> to follow C++ standard - to create compileable wrappers with vc++ and recent return by reference changes

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11153 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2009-03-16 19:33:38 +00:00
commit 956c57bb03
2 changed files with 51 additions and 5 deletions

View file

@ -46,6 +46,40 @@ namespace std {
}
}
};
// bool specialization
template<> class vector<bool> {
public:
typedef size_t size_type;
typedef bool value_type;
typedef bool const_reference;
vector();
vector(size_type n);
size_type size() const;
size_type capacity() const;
void reserve(size_type n);
%rename(isEmpty) empty;
bool empty() const;
void clear();
%rename(add) push_back;
void push_back(const value_type& x);
%extend {
const_reference get(int i) throw (std::out_of_range) {
int size = int(self->size());
if (i>=0 && i<size)
return (*self)[i];
else
throw std::out_of_range("vector index out of range");
}
void set(int i, const value_type& val) throw (std::out_of_range) {
int size = int(self->size());
if (i>=0 && i<size)
(*self)[i] = val;
else
throw std::out_of_range("vector index out of range");
}
}
};
}
%define specialize_std_vector(T)