SWIG (v1.3.29) generated C++ to Java Vector class not acting properly

The appropriate base type for wrapping std::vector in Java is java.util.AbstractList. Using java.util.Vector as a base would be odd because you’d end up with two sets of storage, one in the std::vector, and one in the java.util.Vector. The reason SWIG doesn’t do this for you though is because you can’t have AbstractList<double> in Java, it … Read more

gdb Could not find operator[]

My understanding is that the compiler/linker includes only the member functions present in the source code and those are the ones I can use in gdb. Your understanding is incorrect / incomplete. std::vector is a template class. Without explicit instantiation, the compiler is required to instantiate only the methods called (usually a subset of methods … Read more

vector and const

I’ve added a few lines to your code. That’s sufficient to make it clear why this is disallowed: void f(vector<const T*>& p) { static const T ct; p.push_back(&ct); // adds a const T* to nonConstVec ! } int main() { vector<T*> nonConstVec; f(nonConstVec); nonConstVec.back()->nonConstFunction(); }